コード例 #1
0
        public void Create_IsSaved()
        {
            try
            {
                // Run the test against one instance of the context
                using (var context = new DatabaseContext(options))
                {
                    IWarehouseRepository service = new WarehouseRepository(context, NullLogger <WarehouseRepository> .Instance);
                    Warehouse            wh      = new Warehouse()
                    {
                        Code = "123456789", Description = "yo dawg", ProcessingDelayMins = 1
                    };
                    service.Create(wh);
                }

                // Use a separate instance of the context to verify correct data was saved to database
                using (var context = new DatabaseContext(options))
                {
                    Assert.Equal(1, context.Hops.Count());
                    Assert.Equal("123456789", context.Hops.Single().Code);
                    Assert.Equal("yo dawg", context.Hops.Single().Description);
                }
            }
            finally { }
        }
コード例 #2
0
        public void Create_ThrowsDuplicateHopExpection()
        {
            try
            {
                using (var context = new DatabaseContext(options))
                {
                    IWarehouseRepository service = new WarehouseRepository(context, NullLogger <WarehouseRepository> .Instance);
                    Warehouse            wh      = new Warehouse()
                    {
                        Code = "123456789", Description = "yo dawg", ProcessingDelayMins = 1
                    };
                    service.Create(wh);
                }

                using (var context = new DatabaseContext(options))
                {
                    IWarehouseRepository service = new WarehouseRepository(context, NullLogger <WarehouseRepository> .Instance);
                    Warehouse            wh      = new Warehouse()
                    {
                        Code = "123456789", Description = "yo dawg", ProcessingDelayMins = 1
                    };
                    Assert.Throws <DuplicateHopExpection>(() => service.Create(wh));
                }
            }
            finally { }
        }
コード例 #3
0
 public ActionResult Create(Warehouse model)
 {
     if (ModelState.IsValid)
     {
         int rowsAffected = repo.Create(model);
         if (rowsAffected > 0)
         {
             TempData["message"] = "Successfully Saved";
             return(RedirectToAction("Create"));
         }
         else
         {
             return(View(model));
         }
     }
     return(View(model));
 }
コード例 #4
0
 public void AddNewClothe(Warehouse ware)
 {
     warehouseRepository.Create(ware);
 }