Esempio n. 1
0
		public static Customer CreateNewCustomer(int number)
		{
			var toReturn = new Customer();

			switch(number)
			{
				case 1:
					toReturn.CompanyName = ConstantsEnums.Customer1CompanyName;
					toReturn.CustomerSince = new DateTime(2000, 1, 1);
					toReturn.ContactPerson = ConstantsEnums.Customer1ContactPerson;
					toReturn.CompanyEmailAddress = ConstantsEnums.Customer1CompanyEmailAddress;
					break;
				case 2:
					toReturn.CompanyName = ConstantsEnums.Customer2CompanyName;
					toReturn.CustomerSince = new DateTime(1999, 12, 13);
					toReturn.ContactPerson = ConstantsEnums.Customer2ContactPerson;
					toReturn.CompanyEmailAddress = ConstantsEnums.Customer2CompanyEmailAddress;
					break;
				default:
					throw new ArgumentException("number should be 1 or 2", "number");
			}

			return toReturn;
		}
Esempio n. 2
0
		public void PhantomInsertPreventionTest()
		{
			var newCustomer = new Customer();
			var ba = new Address();
			var va = new Address();
			newCustomer.VisitingAddress = va;
			newCustomer.BillingAddress = ba;

			// as everything is empty, and Address isn't saved because it's not dirty, customer shouldn't be saved as well.
			using(var ctx = GetContext())
			{
				ctx.Customers.InsertOnSubmit(newCustomer);
				ctx.SubmitChanges();
				Assert.AreEqual(0, ba.AddressId);
				Assert.AreEqual(0, va.AddressId);
			}
		}