public void Given_I_Have_A_New_ContentType_When_I_Post_A_New_ContentType_A_New_ContentType_Should_Be_Created() { //Arrange var newContentType = new ContentType { Id = 29, Category = "IET Category", Group = "IET", BookType = "IET1" }; _mockContentTypeRepository.Setup(d => d.Add(newContentType)).Returns(newContentType); _mockDataRepositoryFactory.Setup(d => d.GetDataRepository<IContentTypeRepository>()).Returns(_mockContentTypeRepository.Object); //Act var result = _contentTypeService.AddContentType(newContentType); //Assert _mockContentTypeRepository.Verify(d => d.Add(newContentType), Times.Exactly(1)); Assert.AreEqual("IET1", result.BookType); }
public void Given_A_New_ContentType_I_Should_Get_The_Newly_Created_ContentType_Added_To_ContentType_List() { //Arrange //The New ContentType. var newContentType = new ContentType { Id = 29, Category = "IET Category", Group = "IET", BookType = "IET1" }; //Getting the list locally and adding the newly created ContentType var contentTypeList = _contentTypeList.GetContentTypeListData(); contentTypeList.Add(newContentType); //Seting up the service to include the newly created ContentType _mockContentTypeService.Setup(d => d.AddContentType(newContentType)).Returns(newContentType); //Act //Adding the newly Created ContentType var result = _contentTypesController.Post(newContentType); //Assert //Verifying the Post method was called and the newly created ContentType was added. _mockContentTypeService.Verify(d => d.AddContentType(newContentType), Times.Exactly(1)); Assert.AreEqual(29, contentTypeList.Count()); }
public void Given_An_Update_To_The_ContentType_I_Should_Get_See_The_Changes_To_The_ContentType() { //Arrange //The Modifyed ContentType var modifiedContentType = new ContentType { Id = 1, Category = "Definitions", Group = "Definitions", BookType = "IET1" }; //Seting up the service to include the modified ContentType _mockContentTypeService.Setup(d => d.UpdateContentType(modifiedContentType)).Returns(modifiedContentType); //Act //Modifying the ContentType var result = _contentTypesController.Put(modifiedContentType); //Assert //Verifying the Put method was called and the changes was made to the ContentType. _mockContentTypeService.Verify(d => d.UpdateContentType(modifiedContentType), Times.Exactly(1)); Assert.AreEqual("IET1", result.BookType); }
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); }
public ContentType UpdateContentType(ContentType contentType) { IContentTypeRepository contentTypeRepository = _dataFactoryRepository.GetDataRepository<IContentTypeRepository>(); return contentTypeRepository.Update(contentType); }
public ContentType AddContentType(ContentType contentType) { IContentTypeRepository contentTypeRepository = _dataFactoryRepository.GetDataRepository<IContentTypeRepository>(); return contentTypeRepository.Add(contentType); }