public void GetAllLocations_ShouldWork() { VipServicesContextTest contextTest = new VipServicesContextTest(keepExistingDB: false); VipServicesManager m = new VipServicesManager(new UnitOfWork(contextTest)); m.AddLocation("Brussel"); m.AddLocation("Gent"); m.AddLocation("Antwerpen"); m.AddLocation("Brugge"); m.AddLocation("Luik"); Action act = () => { m.GetAllLocations(); }; act.Should().NotThrow <Exception>(); Assert.AreEqual(5, contextTest.Locations.Local.Count); Assert.AreEqual(5, m.GetAllLocations().Count); }
/// <summary> /// Zoek naar het locatie document en voeg iedere locatie toe aan de DB /// </summary> public static void InitializeLocations(string path, VipServicesManager manager) { using (StreamReader r = new StreamReader(path)) { string line; string locationName; while ((line = r.ReadLine()) != null) { string[] ss = line.Split(',').Select(x => x.Trim()).ToArray(); locationName = ss[0]; manager.AddLocation(locationName); } } }
public void AddLocation_ShouldWork() { VipServicesContextTest contextTest = new VipServicesContextTest(keepExistingDB: false); VipServicesManager m = new VipServicesManager(new UnitOfWork(contextTest)); Location location = new Location("Brussel"); Action act = () => { m.AddLocation("Brussel"); }; act.Should().NotThrow <Exception>(); Assert.AreEqual(1, contextTest.Locations.Local.Count); var locationInDB = contextTest.Locations.First(); Assert.AreEqual(locationInDB.Town, location.Town); }