﻿
/*
	File Generated by NetTiers templates [www.nettiers.com]
	Important: Do not modify this file. Edit the file VProductAndDescriptionTest.cs instead.
*/
#region Using directives

using System;
using System.Xml;
using System.Xml.Serialization;
using NUnit.Framework;
using Nettiers.AdventureWorks.Entities;
using Nettiers.AdventureWorks.Data;

#endregion

namespace Nettiers.AdventureWorks.UnitTests
{
    /// <summary>
    /// Provides tests for the and <see cref="VProductAndDescription"/> objects (entity, collection and repository).
    /// </summary>
    public partial class VProductAndDescriptionTest
    {
    	// the VProductAndDescription instance used to test the repository.
		private VProductAndDescription mock;
		
		// the VList<VProductAndDescription> instance used to test the repository.
		private VList<VProductAndDescription> mockCollection;		

        /// <summary>
		/// This method is used to construct the test environment prior to running the tests.
		/// </summary>
        static private void Init_Generated()
        {
			System.Console.WriteLine(new String('-', 75));
			System.Console.WriteLine("-- Testing the VProductAndDescription Entity with the {0} --", Nettiers.AdventureWorks.Data.DataRepository.Provider.Name);
			System.Console.WriteLine(new String('-', 75));
        }
    
    	/// <summary>
		/// This method is used to restore the environment after the tests are completed.
		/// </summary>
        static private void CleanUp_Generated()
        {       	
			System.Console.WriteLine();
			System.Console.WriteLine();
        }
		
		/// <summary>
		/// Selects a page of VProductAndDescription objects from the database.
		/// </summary>
		private void Step_1_SelectAll_Generated()
		{
			int count = -1;
			mockCollection = DataRepository.VProductAndDescriptionProvider.GetPaged(null, 0, 10, out count);
			Assert.IsTrue(count >= 0, "Select Query Failed with GetPaged");
			System.Console.WriteLine("DataRepository.VProductAndDescriptionProvider.GetPaged():");			
			System.Console.WriteLine(mockCollection);			
		}
		
		/// <summary>
		/// Searches some VProductAndDescription objects from the database.
		/// </summary>
		private void Step_2_Search_Generated()
		{
			int count = -1;
			mockCollection = DataRepository.VProductAndDescriptionProvider.Find(null, null, "", 0, 10, out count);
			Assert.IsTrue(count >= 0 && mockCollection != null, "Query Failed to issue Find Command.");
			
			System.Console.WriteLine("DataRepository.VProductAndDescriptionProvider.Find():");			
			System.Console.WriteLine(mockCollection);
					
		}
		 //Find
			
		
		#region Serialization tests
		
		/// <summary>
		/// Serialize the mock VProductAndDescription entity into a temporary file.
		/// </summary>
		private void Step_6_SerializeEntity_Generated()
		{
			string fileName = "temp_VProductAndDescription.xml";
		
			XmlSerializer mySerializer = new XmlSerializer(typeof(VProductAndDescription)); 
			System.IO.StreamWriter myWriter = new System.IO.StreamWriter(fileName); 
			mySerializer.Serialize(myWriter, mock); 
			myWriter.Close();
			System.Console.WriteLine("mock correctly serialized to a temporary file.");			
		}
		
		/// <summary>
		/// Deserialize the mock VProductAndDescription entity from a temporary file.
		/// </summary>
		private void Step_7_DeserializeEntity_Generated()
		{
			string fileName = "temp_VProductAndDescription.xml";
		
			XmlSerializer mySerializer = new XmlSerializer(typeof(VProductAndDescription)); 
			System.IO.FileStream myFileStream = new System.IO.FileStream(fileName,  System.IO.FileMode.Open); 
			mock = (VProductAndDescription) mySerializer.Deserialize(myFileStream);
			myFileStream.Close();
			System.IO.File.Delete(fileName);
			
			System.Console.WriteLine("mock correctly deserialized from a temporary file.");
		}
		
		/// <summary>
		/// Serialize a VProductAndDescription collection into a temporary file.
		/// </summary>
		private void Step_8_SerializeCollection_Generated()
		{
			string fileName = "temp_VProductAndDescriptionCollection.xml";
		
			VList<VProductAndDescription> mockCollection = new VList<VProductAndDescription>();
			mockCollection.Add(mock);
		
			XmlSerializer mySerializer = new XmlSerializer(typeof(VList<VProductAndDescription>)); 
			System.IO.StreamWriter myWriter = new System.IO.StreamWriter(fileName); 
			mySerializer.Serialize(myWriter, mockCollection); 
			myWriter.Close();
			
			System.Console.WriteLine("VList<VProductAndDescription> correctly serialized to a temporary file.");					
		}
		
		
		/// <summary>
		/// Deserialize a VProductAndDescription collection from a temporary file.
		/// </summary>
		private void Step_9_DeserializeCollection_Generated()
		{
			string fileName = "temp_VProductAndDescriptionCollection.xml";
		
			XmlSerializer mySerializer = new XmlSerializer(typeof(VList<VProductAndDescription>)); 
			System.IO.FileStream myFileStream = new System.IO.FileStream(fileName,  System.IO.FileMode.Open); 
			VList<VProductAndDescription> mockCollection = (VList<VProductAndDescription>) mySerializer.Deserialize(myFileStream);
			myFileStream.Close();
			System.IO.File.Delete(fileName);
			System.Console.WriteLine("VList<VProductAndDescription> correctly deserialized from a temporary file.");	
		}
		#endregion
		
		#region Mock Instance
		///<summary>
		///  Returns a Typed VProductAndDescription Entity with mock values.
		///</summary>
		static public VProductAndDescription CreateMockInstance()
		{		
			VProductAndDescription mock = new VProductAndDescription();
						
			mock.ProductId = TestUtility.Instance.RandomNumber();
			mock.Name = TestUtility.Instance.RandomString(24, false);;
			mock.ProductModel = TestUtility.Instance.RandomString(24, false);;
			mock.CultureId = TestUtility.Instance.RandomString(6, false);;
			mock.Description = TestUtility.Instance.RandomString(199, false);;
		   return (VProductAndDescription)mock;
		}
		

		#endregion
    }
}
