public void ContentController_GetContentItem_Throws_On_Negative_ContentItemId() { //Arrange Mock<IDataService> mockDataService = new Mock<IDataService>(); ContentController controller = new ContentController(mockDataService.Object); //Act, Arrange Assert.Throws<ArgumentOutOfRangeException>(() => controller.GetContentItem(Null.NullInteger)); }
public void ContentController_GetContentItem_Returns_ContentItem_On_Valid_ContentItemId() { //Arrange Mock<IDataService> mockDataService = new Mock<IDataService>(); mockDataService.Setup(ds => ds.GetContentItem(Constants.CONTENT_ValidContentItemId)) .Returns(MockHelper.CreateValidContentItemReader()); ContentController controller = new ContentController(mockDataService.Object); //Act ContentItem content = controller.GetContentItem(Constants.CONTENT_ValidContentItemId); //Assert Assert.AreEqual(Constants.CONTENT_ValidContentItemId, content.ContentItemId); Assert.AreEqual(ContentTestHelper.GetContent(Constants.CONTENT_ValidContentItemId), content.Content); Assert.AreEqual(ContentTestHelper.GetContentKey(Constants.CONTENT_ValidContentItemId), content.ContentKey); }
public void ContentController_GetContentItem_Returns_Null_On_InValid_ContentItemId() { //Arrange Mock<IDataService> mockDataService = new Mock<IDataService>(); mockDataService.Setup(ds => ds.GetContentItem(Constants.CONTENT_InValidContentItemId)) .Returns(MockHelper.CreateEmptyContentItemReader()); ContentController controller = new ContentController(mockDataService.Object); //Act ContentItem content = controller.GetContentItem(Constants.CONTENT_InValidContentItemId); //Assert Assert.IsNull(content); }
public void ContentController_GetContentItem_Calls_DataService_On_Valid_ContentItemId() { //Arrange Mock<IDataService> mockDataService = new Mock<IDataService>(); mockDataService.Setup(ds => ds.GetContentItem(Constants.CONTENT_ValidContentItemId)) .Returns(MockHelper.CreateValidContentItemReader()); ContentController controller = new ContentController(mockDataService.Object); //Act ContentItem content = controller.GetContentItem(Constants.CONTENT_ValidContentItemId); //Assert mockDataService.Verify(ds => ds.GetContentItem(Constants.CONTENT_ValidContentItemId)); }