Exemplo n.º 1
0
        public void AddCategoryShouldReturnAViewForTheCategoryAddition()
        {
            // Arrange

            // Act
            var sut = new CategoryController(_mockDocumentSession.Object);
            var result = sut.Add();

            // Assert
            _mockDocumentSession.Verify();
            Assert.That(result, Is.TypeOf<ViewResult>());
        }
Exemplo n.º 2
0
        public void AddCategoryPostShouldRedirectToCategoryList()
        {
            // Arrange
            _mockDocumentSession.Setup(o => o.Store(It.IsAny<Category>())).Verifiable("Category should be saved");
            _mockDocumentSession.Setup(o=>o.SaveChanges()).Verifiable("Store should be saved");

            var category = new CategoryModel
            {
                Description = "Category"
            };

            // Act
            var sut = new CategoryController(_mockDocumentSession.Object);
            var result = sut.Add(category);

            // Assert
            Assert.That(result, Is.TypeOf<RedirectToRouteResult>());
        }
Exemplo n.º 3
0
        public void AddCategoryPostShouldRequireADescription()
        {
            // Arrange
            const string description = "Category";
            _mockDocumentSession.Setup(o => o.Store(It.Is<Category>(
                    x=>x.Description==description
                ))).Verifiable("Category should be saved");
            _mockDocumentSession.Setup(o=>o.SaveChanges()).Verifiable("Save the store");

            var categoryModel = new CategoryModel
                {
                    Description = description
                };

            // Act
            var sut = new CategoryController(_mockDocumentSession.Object);
            var result = sut.Add(categoryModel);

            // Assert
            _mockDocumentSession.Verify();
        }