Example #1
0
        public async Task UpdateAsync_UpdateIssue_BoardValidationSuccess()
        {
            // Arrange
            var expected = new Issue();

            var issueDataAccess = new Mock <IIssueDataAccess>();

            issueDataAccess.Setup(x => x.UpdateAsync(issue))
            .ReturnsAsync(expected);

            var boardGetService    = new Mock <IBoardGetService>();
            var issueUpdateService = new IssueUpdateService(issueDataAccess.Object, boardGetService.Object);

            // Act
            var result = await issueUpdateService.UpdateAsync(issue);

            // Assert
            result.Should().Equals(expected);
        }
Example #2
0
        public async Task UpdateAsync_UpdateIssue_BoardValidationFailure()
        {
            // Arrange
            var fixture  = new Fixture();
            var expected = fixture.Create <string>();

            var boardGetService = new Mock <IBoardGetService>();

            boardGetService.Setup(x => x.ValidateAsync(issue))
            .Throws(new InvalidOperationException(expected));

            var issueDataAccess = new Mock <IIssueDataAccess>();

            var issueUpdateService = new IssueUpdateService(issueDataAccess.Object, boardGetService.Object);

            // Act
            var action = new Func <Task>(() => issueUpdateService.UpdateAsync(issue));

            // Assert
            await action.Should().ThrowAsync <InvalidOperationException>().WithMessage(expected);

            issueDataAccess.Verify(x => x.UpdateAsync(issue), Times.Never);
        }