Exemplo n.º 1
0
        public void Given_I_Have_A_Update_When_I_Update_A_ContentType_I_Should_See_The_Modified_ContentType()
        {
            //Arrange
            //The Modifyed ContentType
            var modifiedContentType = new ContentType
            {
                Id       = 1,
                Category = "Definitions",
                Group    = "Definitions",
                BookType = "IET100"
            };

            //Seting up the repository to include the modified ContentType
            _mockContentTypeRepository.Setup(d => d.Update(modifiedContentType)).Returns(modifiedContentType);
            _mockDataRepositoryFactory.Setup(d => d.GetDataRepository <IContentTypeRepository>()).Returns(_mockContentTypeRepository.Object);
            //Act
            //Modifying the ContentType
            var result = _contentTypeService.UpdateContentType(modifiedContentType);

            //Assert
            //Verifying the Put method was called on the Service and the changes was made to the ContentType.
            _mockContentTypeRepository.Verify(d => d.Update(modifiedContentType), Times.Exactly(1));
            Assert.AreEqual("IET100", result.BookType);
        }