public void GetAllCustomers_ShouldWork() { VipServicesContextTest contextTest = new VipServicesContextTest(keepExistingDB: false); VipServicesManager m = new VipServicesManager(new UnitOfWork(contextTest)); Action act = () => { m.AddCustomer("Jan", "BE0502358347", new Address("Groenlaan", "17", "Herzele"), CategoryType.geen); m.AddCustomer("Bob", "", new Address("Dorpstraat", "101", "Antwerpen"), CategoryType.concertpromotor); m.AddCustomer("Piet", "", new Address("Schoolstraat", "80", "Blankenberge"), CategoryType.huwelijksplanner); }; act.Should().NotThrow <DomainException>(); Assert.AreEqual(3, contextTest.Customers.Local.Count); }
/// <summary> /// Zoek naar het klanten document en voeg iedere klant toe aan de DB /// </summary> public static void InitializeCustomers(string path, VipServicesManager manager) { using (StreamReader r = new StreamReader(path)) { string line; string name; string BtwNumber; string addressString; string streetName; string streetNumber; string town; while ((line = r.ReadLine()) != null) { string[] ss = line.Split(',').Select(x => x.Trim()).ToArray(); name = ss[1]; CategoryType category = (CategoryType)Enum.Parse(typeof(CategoryType), ss[2]); BtwNumber = ss[3]; addressString = ss[4]; string[] addresItems = addressString.Split(' ').Select(x => x.Trim()).ToArray(); streetName = addresItems[0]; streetNumber = addresItems[1]; town = addresItems[3]; Address address = new Address(streetName, streetNumber, town); manager.AddCustomer(name, BtwNumber, address, category); } } }
public void AddCustomer_ShouldWork() { VipServicesContextTest contextTest = new VipServicesContextTest(keepExistingDB: false); VipServicesManager m = new VipServicesManager(new UnitOfWork(contextTest)); Address address = new Address("Groenlaan", "17", "Herzele"); Customer customer = new Customer("Jan", "BE0502358347", address, CategoryType.geen); Action act = () => { m.AddCustomer("Jan", "BE0502358347", address, CategoryType.geen); }; act.Should().NotThrow <DomainException>(); Assert.AreEqual(1, contextTest.Customers.Local.Count); var customerInDb = contextTest.Customers.First(); Assert.AreEqual(customerInDb.Name, customer.Name); Assert.AreEqual(customerInDb.BtwNumber, customer.BtwNumber); Assert.AreEqual(customerInDb.Address, customer.Address); Assert.AreEqual(customerInDb.Category, customer.Category); }