Exemple #1
0
        public void Should_PostPricingStrategyItem()
        {
            PricingStrategyItem testPricingStrategyItem = new PricingStrategyItem {
                Id = 1, Name = "Test1", Description = "Test", Price = 5, PricingStrategyId = 1
            };

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

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

            PricingStrategyItemsController controller = new PricingStrategyItemsController(mock.Object);
            var pricingStrategyItems = controller.PostPricingStrategyItem(testPricingStrategyItem);

            Assert.IsType <CreatedAtActionResult>(pricingStrategyItems);
        }
Exemple #2
0
        public void ShouldNot_PostPricingStrategyItem_ModelStateError()
        {
            PricingStrategyItem testPricingStrategyItem = new PricingStrategyItem {
                Id = 1, Name = "Test1", Description = "Test", Price = 5, PricingStrategyId = 1
            };

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

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

            PricingStrategyItemsController controller = new PricingStrategyItemsController(mock.Object);

            controller.ModelState.AddModelError("TestError", "Error");
            var pricingStrategyItems = controller.PostPricingStrategyItem(testPricingStrategyItem);

            Assert.IsType <BadRequestObjectResult>(pricingStrategyItems);
        }