public void GetByCode_ReturnsHop() { try { // Run the test against one instance of the context using (var context = new DatabaseContext(options)) { Warehouse wh = new Warehouse() { Code = "123456789", Description = "yo dawg", ProcessingDelayMins = 1 }; context.Hops.Add(wh); context.SaveChanges(); } // Use a separate instance of the context to verify correct data was saved to database using (var context = new DatabaseContext(options)) { IHopRepository service = new HopRepository(context, NullLogger <HopRepository> .Instance); Warehouse wh = (Warehouse)service.GetByCode("123456789"); Assert.Equal("123456789", wh.Code); Assert.Equal("yo dawg", wh.Description); } } finally { } }
public void GetByCode_ThrowsHopNotFoundExpection() { try { using (var context = new DatabaseContext(options)) { IHopRepository service = new HopRepository(context, NullLogger <HopRepository> .Instance); Warehouse wh = new Warehouse() { Code = "123456789", Description = "yo boi", ProcessingDelayMins = 1 }; Assert.Throws <HopNotFoundExpection>(() => service.GetByCode("123456789")); } } finally { } }