示例#1
0
        public void ShouldNot_DeletePricingStrategyItem_NotFound()
        {
            PricingStrategyItem testPricingStrategyItem = new PricingStrategyItem {
                Id = 10
            };

            Mock <IUnitOfWork> mock = new Mock <IUnitOfWork>();

            mock.Setup(f => f.PricingStrategyItems.GetById(10)).Returns((PricingStrategyItem)null);

            PricingStrategyItemsController controller = new PricingStrategyItemsController(mock.Object);
            var result = controller.DeletePricingStrategyItem(10);

            Assert.IsType <NotFoundResult>(result);
        }
示例#2
0
        public void Should_DeletePricingStrategyItem()
        {
            PricingStrategyItem testPricingStrategyItem = new PricingStrategyItem {
                Id = 1
            };

            Mock <IUnitOfWork> mock = new Mock <IUnitOfWork>();

            mock.Setup(f => f.PricingStrategyItems.GetById(1)).Returns(testPricingStrategyItem);
            mock.Setup(f => f.PricingStrategyItems.Delete(testPricingStrategyItem)).Returns(true);

            PricingStrategyItemsController controller = new PricingStrategyItemsController(mock.Object);
            var result = controller.DeletePricingStrategyItem(1);

            Assert.IsType <OkObjectResult>(result);
        }
示例#3
0
        public void ShouldNot_DeletePricingStrategyItem_ModelStateError()
        {
            PricingStrategyItem testPricingStrategyItem = new PricingStrategyItem {
                Id = 1
            };

            Mock <IUnitOfWork> mock = new Mock <IUnitOfWork>();

            mock.Setup(f => f.PricingStrategyItems.Delete(testPricingStrategyItem)).Returns(true);

            PricingStrategyItemsController controller = new PricingStrategyItemsController(mock.Object);

            controller.ModelState.AddModelError("TestError", "Error");
            var result = controller.DeletePricingStrategyItem(1);

            Assert.IsType <BadRequestObjectResult>(result);
        }