public void GetAll_ShouldReturnSuccess() { //----------------------------------------------------------------------------------------------------------- // Arrange //----------------------------------------------------------------------------------------------------------- var expectedCount = _expectedModelReturn.NewsReleaseLog.Count; var expectedLogEntry = _expectedModelReturn.NewsReleaseLog.FirstOrDefault(); var mockRepository = CreateDataStore(); var controller = new NewsReleaseLogsController(mockRepository.Object, _logger.Object, _mapper.Object); //----------------------------------------------------------------------------------------------------------- // Act //----------------------------------------------------------------------------------------------------------- var result = controller.GetAll("0"); //----------------------------------------------------------------------------------------------------------- // Assert //----------------------------------------------------------------------------------------------------------- result.Should().BeOfType(typeof(OkObjectResult), "because the read operation should go smoothly"); var actual = ((result as OkObjectResult).Value as IEnumerable <NewsReleaseLogViewModel>); var actualLogEntry = actual.FirstOrDefault(); actual.Count().Should().Be(expectedCount); actualLogEntry.Id.Should().Be(expectedLogEntry.Id); actualLogEntry.ReleaseId.Should().Be(expectedLogEntry.ReleaseId); actualLogEntry.Description.Should().Be(expectedLogEntry.Description); }
public void Get_ShouldReturnSuccess() { //----------------------------------------------------------------------------------------------------------- // Arrange //----------------------------------------------------------------------------------------------------------- var mockRepository = CreateDataStore(); var controller = new NewsReleaseLogsController(mockRepository.Object, _logger.Object, _mapper.Object); //----------------------------------------------------------------------------------------------------------- // Act //----------------------------------------------------------------------------------------------------------- var result = controller.Get("0", 1); //----------------------------------------------------------------------------------------------------------- // Assert //----------------------------------------------------------------------------------------------------------- result.Should().BeOfType(typeof(OkObjectResult), "because the read operation should go smoothly"); }
public void Get_ShouldReturnNotFound_WhenGivenInvalidParameters(string releaseId, int logId, string because = null) { //----------------------------------------------------------------------------------------------------------- // Arrange //----------------------------------------------------------------------------------------------------------- var mockRepository = CreateDataStore(); var controller = new NewsReleaseLogsController(mockRepository.Object, _logger.Object, _mapper.Object); //----------------------------------------------------------------------------------------------------------- // Act //----------------------------------------------------------------------------------------------------------- var result = controller.Get(releaseId, logId); // does not exist... //----------------------------------------------------------------------------------------------------------- // Assert //----------------------------------------------------------------------------------------------------------- result.Should().BeOfType(typeof(NotFoundResult), because); }
public void GetAll_ShouldReturnNotFound_WhenGivenInvalidReleaseId() { //----------------------------------------------------------------------------------------------------------- // Arrange //----------------------------------------------------------------------------------------------------------- var mockRepository = CreateDataStore(); var controller = new NewsReleaseLogsController(mockRepository.Object, _logger.Object, _mapper.Object); //----------------------------------------------------------------------------------------------------------- // Act //----------------------------------------------------------------------------------------------------------- var result = controller.GetAll("-1"); // does not exist... //----------------------------------------------------------------------------------------------------------- // Assert //----------------------------------------------------------------------------------------------------------- result.Should().BeOfType(typeof(NotFoundResult), "because an invalid Id should not yield a result"); }