Example #1
0
        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))
                {
                    IWarehouseRepository service = new WarehouseRepository(context, NullLogger <WarehouseRepository> .Instance);
                    Warehouse            wh      = service.GetByCode("123456789");
                    Assert.Equal("123456789", wh.Code);
                    Assert.Equal("yo dawg", wh.Description);
                }
            }
            finally { }
        }
Example #2
0
 public void GetByCode_ThrowsHopNotFoundExpection()
 {
     try
     {
         using (var context = new DatabaseContext(options))
         {
             IWarehouseRepository service = new WarehouseRepository(context, NullLogger <WarehouseRepository> .Instance);
             Warehouse            wh      = new Warehouse()
             {
                 Code = "123456789", Description = "yo boi", ProcessingDelayMins = 1
             };
             Assert.Throws <HopNotFoundExpection>(() => service.GetByCode("123456789"));
         }
     }
     finally { }
 }