Inheritance: ContactBase
Beispiel #1
0
        /// <summary>
        /// Convert a nettiers collection to the ws proxy collection.
        /// </summary>
        public static Nettiers.AdventureWorks.Entities.Contact Convert(Nettiers.AdventureWorks.Entities.Contact outItem, WsProxy.Contact item)
        {
            if (item != null && outItem != null)
            {
                outItem.ContactId             = item.ContactId;
                outItem.NameStyle             = item.NameStyle;
                outItem.Title                 = item.Title;
                outItem.FirstName             = item.FirstName;
                outItem.MiddleName            = item.MiddleName;
                outItem.LastName              = item.LastName;
                outItem.Suffix                = item.Suffix;
                outItem.EmailAddress          = item.EmailAddress;
                outItem.EmailPromotion        = item.EmailPromotion;
                outItem.Phone                 = item.Phone;
                outItem.PasswordHash          = item.PasswordHash;
                outItem.PasswordSalt          = item.PasswordSalt;
                outItem.AdditionalContactInfo = item.AdditionalContactInfo;
                outItem.Rowguid               = item.Rowguid;
                outItem.ModifiedDate          = item.ModifiedDate;

                outItem.AcceptChanges();
            }

            return(outItem);
        }
		/// <summary>
		/// Inserts a mock Contact entity into the database.
		/// </summary>
		private void Step_01_Insert_Generated()
		{
			using (TransactionManager tm = CreateTransaction())
			{
				mock = CreateMockInstance(tm);
				Assert.IsTrue(DataRepository.ContactProvider.Insert(tm, mock), "Insert failed");
										
				System.Console.WriteLine("DataRepository.ContactProvider.Insert(mock):");			
				System.Console.WriteLine(mock);			
				
				//normally one would commit here
				//tm.Commit();
				//IDisposable will Rollback Transaction since it's left uncommitted
			}
		}
Beispiel #3
0
        /// <summary>
        ///     Inserts a Nettiers.AdventureWorks.Entities.Contact object into the datasource using a transaction.
        /// </summary>
        /// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
        /// <param name="entity">Nettiers.AdventureWorks.Entities.Contact object to insert.</param>
        /// <remarks></remarks>
        /// <returns>Returns true if operation is successful.</returns>
        public override bool Insert(TransactionManager transactionManager, Nettiers.AdventureWorks.Entities.Contact entity)
        {
            WsProxy.AdventureWorksServices proxy = new WsProxy.AdventureWorksServices();
            proxy.Url = Url;

            try
            {
                WsProxy.Contact result = proxy.ContactProvider_Insert(Convert(entity));
                Convert(entity, result);
                return(true);
            }
            catch (SoapException soex)
            {
                System.Diagnostics.Debug.WriteLine(soex);
                throw soex;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex);
                throw ex;
            }
        }
		///<summary>
		///  Update the Typed Contact Entity with modified mock values.
		///</summary>
		static public void UpdateMockInstance_Generated(TransactionManager tm, Contact mock)
		{
			mock.NameStyle = TestUtility.Instance.RandomBoolean();
			mock.Title = TestUtility.Instance.RandomString(8, false);;
			mock.FirstName = TestUtility.Instance.RandomString(24, false);;
			mock.MiddleName = TestUtility.Instance.RandomString(24, false);;
			mock.LastName = TestUtility.Instance.RandomString(24, false);;
			mock.Suffix = TestUtility.Instance.RandomString(10, false);;
			mock.EmailAddress = TestUtility.Instance.RandomString(24, false);;
			mock.EmailPromotion = TestUtility.Instance.RandomNumber();
			mock.Phone = TestUtility.Instance.RandomString(11, false);;
			mock.PasswordHash = TestUtility.Instance.RandomString(63, false);;
			mock.PasswordSalt = TestUtility.Instance.RandomString(10, false);;
			mock.AdditionalContactInfo = "<test></test>";
			mock.ModifiedDate = TestUtility.Instance.RandomDateTime();
			
		}
		///<summary>
		///  Returns a Typed Contact Entity with mock values.
		///</summary>
		static public Contact CreateMockInstance_Generated(TransactionManager tm)
		{		
			Contact mock = new Contact();
						
			mock.NameStyle = TestUtility.Instance.RandomBoolean();
			mock.Title = TestUtility.Instance.RandomString(8, false);;
			mock.FirstName = TestUtility.Instance.RandomString(24, false);;
			mock.MiddleName = TestUtility.Instance.RandomString(24, false);;
			mock.LastName = TestUtility.Instance.RandomString(24, false);;
			mock.Suffix = TestUtility.Instance.RandomString(10, false);;
			mock.EmailAddress = TestUtility.Instance.RandomString(24, false);;
			mock.EmailPromotion = TestUtility.Instance.RandomNumber();
			mock.Phone = TestUtility.Instance.RandomString(11, false);;
			mock.PasswordHash = TestUtility.Instance.RandomString(63, false);;
			mock.PasswordSalt = TestUtility.Instance.RandomString(10, false);;
			mock.AdditionalContactInfo = "<test></test>";
			mock.ModifiedDate = TestUtility.Instance.RandomDateTime();
			
		
			// create a temporary collection and add the item to it
			TList<Contact> tempMockCollection = new TList<Contact>();
			tempMockCollection.Add(mock);
			tempMockCollection.Remove(mock);
			
		
		   return (Contact)mock;
		}
		/// <summary>
		/// Test methods exposed by the EntityHelper class.
		/// </summary>
		private void Step_20_TestEntityHelper_Generated()
		{
			using (TransactionManager tm = CreateTransaction())
			{
				mock = CreateMockInstance(tm);
				
				Contact entity = mock.Copy() as Contact;
				entity = (Contact)mock.Clone();
				Assert.IsTrue(Contact.ValueEquals(entity, mock), "Clone is not working");
			}
		}
		/// <summary>
		/// Serialize a Contact collection into a temporary file.
		/// </summary>
		private void Step_08_SerializeCollection_Generated()
		{
			using (TransactionManager tm = CreateTransaction())
			{
				string fileName = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "temp_ContactCollection.xml");
				
				mock = CreateMockInstance(tm);
				TList<Contact> mockCollection = new TList<Contact>();
				mockCollection.Add(mock);
			
				EntityHelper.SerializeXml(mockCollection, fileName);
				
				Assert.IsTrue(System.IO.File.Exists(fileName), "Serialized mock collection not found");
				System.Console.WriteLine("TList<Contact> correctly serialized to a temporary file.");					
			}
		}
		/// <summary>
		/// Serialize the mock Contact entity into a temporary file.
		/// </summary>
		private void Step_06_SerializeEntity_Generated()
		{	
			using (TransactionManager tm = CreateTransaction())
			{
				mock =  CreateMockInstance(tm);
				string fileName = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "temp_Contact.xml");
			
				EntityHelper.SerializeXml(mock, fileName);
				Assert.IsTrue(System.IO.File.Exists(fileName), "Serialized mock not found");
					
				System.Console.WriteLine("mock correctly serialized to a temporary file.");			
			}
		}
		/// <summary>
		/// Deep load all Contact children.
		/// </summary>
		private void Step_03_DeepLoad_Generated()
		{
			using (TransactionManager tm = CreateTransaction())
			{
				int count = -1;
				mock =  CreateMockInstance(tm);
				mockCollection = DataRepository.ContactProvider.GetPaged(tm, 0, 10, out count);
			
				DataRepository.ContactProvider.DeepLoading += new EntityProviderBaseCore<Contact, ContactKey>.DeepLoadingEventHandler(
						delegate(object sender, DeepSessionEventArgs e)
						{
							if (e.DeepSession.Count > 3)
								e.Cancel = true;
						}
					);

				if (mockCollection.Count > 0)
				{
					
					DataRepository.ContactProvider.DeepLoad(tm, mockCollection[0]);
					System.Console.WriteLine("Contact instance correctly deep loaded at 1 level.");
									
					mockCollection.Add(mock);
					// DataRepository.ContactProvider.DeepSave(tm, mockCollection);
				}
				
				//normally one would commit here
				//tm.Commit();
				//IDisposable will Rollback Transaction since it's left uncommitted
			}
		}
Beispiel #10
0
		/// <summary>
        /// Make any alterations necessary (i.e. for DB check constraints, special test cases, etc.)
        /// </summary>
        /// <param name="mock">Object to be modified</param>
        static private void SetSpecialTestData(Contact mock)
        {
            //Code your changes to the data object here.

            //Set the XML to null
            mock.AdditionalContactInfo = null;
            mock.EmailPromotion = 1;
        }
Beispiel #11
0
        ///<summary>
        ///  Update the Typed Contact Entity with modified mock values.
        ///</summary>
        static public void UpdateMockInstance(TransactionManager tm, Contact mock)
        {
            ContactTest.UpdateMockInstance_Generated(tm, mock);
            
			// make any alterations necessary 
            // (i.e. for DB check constraints, special test cases, etc.)
			SetSpecialTestData(mock);
        }
Beispiel #12
0
 /// <summary>
 /// Convert a nettiers collection to the ws proxy collection.
 /// </summary>
 public static Nettiers.AdventureWorks.Entities.Contact Convert(WsProxy.Contact item)
 {
     Nettiers.AdventureWorks.Entities.Contact outItem = item == null ? null : new Nettiers.AdventureWorks.Entities.Contact();
     Convert(outItem, item);
     return(outItem);
 }