public void GetByName() { Manufacturer trek = new Manufacturer(1, "Trek"); Manufacturer specialized = new Manufacturer(2, "Specialized"); Manufacturer cannondale = new Manufacturer(3, "Cannondale"); IManufacturerRepository repository = new ManufacturerRepository(); repository.Add(trek); repository.Add(specialized); repository.Add(cannondale); Manufacturer actual = repository.GetByName("specialized"); Assert.IsNotNull(actual); Assert.AreNotSame(specialized, actual); Assert.AreEqual(specialized.ID, actual.ID); }
public void RemoveExisting() { Manufacturer manufacturer = new Manufacturer(1, "Trek"); IManufacturerRepository repository = new ManufacturerRepository(); repository.Add(manufacturer); using(ISession session = SessionFactory.OpenSession()) { Assert.IsNotNull(session.Get<Manufacturer>(manufacturer.ID)); } repository.Remove(manufacturer); using(ISession session = SessionFactory.OpenSession()) { Assert.IsNull(session.Get<Manufacturer>(manufacturer.ID)); } }
public void UpdateExisting() { Manufacturer expected = new Manufacturer(1, "Trek"); IManufacturerRepository repository = new ManufacturerRepository(); repository.Add(expected); expected.Name = "Specialized"; repository.Update(expected); using(ISession session = SessionFactory.OpenSession()) { Manufacturer actual = session.Get<Manufacturer>(expected.ID); Assert.AreEqual(expected.Name, actual.Name); } }
public void AddNew() { Manufacturer manufacturer = new Manufacturer(1, "Trek"); IManufacturerRepository repository = new ManufacturerRepository(); repository.Add(manufacturer); }