コード例 #1
0
        public async Task DeclineInvitationAsync_WhenDifferentUserId_ShouldBeOfTypeValidationResultWithErrors()
        {
            // Arrange
            var invitation = new Invitation(new UserId(), new ClanId());

            var service = new InvitationService(TestMock.InvitationRepository.Object, TestMock.ClanRepository.Object);

            // Act
            var result = await service.DeclineInvitationAsync(invitation, new UserId());

            // Assert
            result.Should().BeOfType <DomainValidationResult <Invitation> >();
            result.Errors.Should().NotBeEmpty();
        }
コード例 #2
0
        public async Task DeclineInvitationAsync_ShouldBeOfTypeValidationResult()
        {
            // Arrange
            var userId     = new UserId();
            var invitation = new Invitation(userId, new ClanId());

            TestMock.InvitationRepository.Setup(repository => repository.Delete(It.IsAny <Invitation>())).Verifiable();

            TestMock.InvitationRepository.Setup(repository => repository.UnitOfWork.CommitAsync(It.IsAny <bool>(), It.IsAny <CancellationToken>()))
            .Returns(Task.CompletedTask)
            .Verifiable();

            var service = new InvitationService(TestMock.InvitationRepository.Object, TestMock.ClanRepository.Object);

            // Act
            var result = await service.DeclineInvitationAsync(invitation, userId);

            // Assert
            result.Should().BeOfType <DomainValidationResult <Invitation> >();
            TestMock.InvitationRepository.Verify(repository => repository.Delete(It.IsAny <Invitation>()), Times.Once);
            TestMock.InvitationRepository.Verify(repository => repository.UnitOfWork.CommitAsync(It.IsAny <bool>(), It.IsAny <CancellationToken>()), Times.Once);
        }