コード例 #1
0
        public void Sould_Add_New_MainCategory()
        {
            string newCategoryToAdd = "newCategoryToAdd";

            // Arrange
            CatalogController controller = new CatalogController();

            controller.AddMainCategory(newCategoryToAdd);

            // Assert
            Assert.AreEqual(controller.catalog.MainCategories.Count, 1);
        }
コード例 #2
0
        public void Sould_Not_Add_Duplicate_MainCategory()
        {
            //add the first category
            string newCategoryToAdd = "newCategoryToAdd";
            CatalogController controller = new CatalogController();
            controller.AddMainCategory(newCategoryToAdd);

            ArgumentException expectedException = null;

            try
            {
                //attempt to add again the same category
                controller.AddMainCategory(newCategoryToAdd);
            }
            catch (ArgumentException ex)
            {
                expectedException = ex;
            }

            // Assert
            Assert.IsNotNull(expectedException);
            Assert.AreEqual(controller.catalog.MainCategories.Count, 1);
        }
コード例 #3
0
 public void TestInitialize()
 {
     _mockCategoryService = new Mock<ICategoryService>();
     _controller = new CatalogController(_mockCategoryService.Object);
 }