// ------------------------------------------------------------------------------
// This partial class was auto-generated for use with the Habanero Architecture.
// NB: This class is regenerated and you run the risk of losing any changes
// you make directly.  Try placing any custom code in the non "Def" code file.
// ------------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq.Expressions;
using <<|=BOPROJECTNAME|>>;
using Habanero.Base;
using Habanero.BO;
using Habanero.BO.ClassDefinition;
using NUnit.Framework;
using Habanero.Testability;

namespace <<|=BOTestProjectName|>>
{
	/// <summary>
	///Creates sample <<|=CLASSNAME|>> objects.
	/// If the default <see cref="BOTestFactory{T}"/> Creates invalid objects then uncomment the custom 
	/// factory (see Other part of this partial class). See the comments on <see cref="BOTestFactory{T}"/>
	/// for more details.
	/// </summary>
	public partial class TestUtils<<|=CLASSNAME|>>
	{
		///<summary>
		///Gets a valid PropValue given a specific search criteria
		///</summary> 
		public static TReturn GetValidPropValue<TReturn>(Expression<Func<<<|=CLASSNAME|>>,TReturn>> <<|=#CLASSNAME|>>)
		{
		return GetTestFactory().GetValidPropValue(<<|=#CLASSNAME|>>);
		}

		///<summary>
		///Gets a valid RelationshipValue given a specific search criteria
		///</summary> 
		public static TReturn GetValidRelationshipValue<TReturn>(Expression<Func<<<|=CLASSNAME|>>,TReturn>> <<|=#CLASSNAME|>>) where TReturn : IBusinessObject
		{
		return GetTestFactory().GetValidRelationshipValue(<<|=#CLASSNAME|>>);
		}

		/// <summary>
		/// Creates a new saved <<|=CLASSNAME|>> with valid random value assigned to all compulsoryProps
		/// <see cref="BOTestFactory"/>.<see cref="BOTestFactory.CreateValidBusinessObject"/>
		/// </summary>
		public static <<|=CLASSNAME|>> CreateSaved<<|=CLASSNAME|>>()
		{
			<<|=CLASSNAME|>> <<|=#CLASSNAME|>> = CreateUnsavedValid<<|=CLASSNAME|>>();
			<<|=#CLASSNAME|>>.Save();
			return <<|=#CLASSNAME|>>;
		}

		/// <summary>
		/// Creates a new unsaved <<|=CLASSNAME|>> with a random value assigned to all compulsory props
		///  <see cref="BOTestFactory"/>.<see cref="BOTestFactory.CreateValidBusinessObject"/>
		/// </summary>
		public static <<|=CLASSNAME|>> CreateUnsavedValid<<|=CLASSNAME|>>()
		{
			return GetTestFactory().CreateValidBusinessObject();
		}
		
		/// <summary>
		/// Creates a new unsaved <<|=CLASSNAME|>> where all properties are null, except ID properties
		/// and those with default values in the <see cref="IClassDef"/>.<see cref="IPropDef"/> rules.  
		/// If there are compulsory properties without
		/// defaults, saving the object will throw an exception if you try save it.<br/>
		///  <see cref="BOTestFactory"/>.<see cref="BOTestFactory.CreateDefaultBusinessObject"/>
		/// </summary>
		public static <<|=CLASSNAME|>> CreateUnsavedDefault<<|=CLASSNAME|>>()
		{
			return GetTestFactory().CreateDefaultBusinessObject();

		}
		
		/// <summary>
		/// Updates the compulsory properties for an <<|=CLASSNAME|>> with valid values.<br/>
		/// <see cref="BOTestFactory"/>.<see cref="BOTestFactory.UpdateCompulsoryProperties"/>
		/// </summary>
		/// <param name="<<|=#CLASSNAME|>>"></param>
		public static void UpdateCompulsoryProperties(<<|=CLASSNAME|>> <<|=#CLASSNAME|>>)
		{
			GetTestFactory().UpdateCompulsoryProperties(<<|=#CLASSNAME|>>);
		}

	}
}