Ejemplo n.º 1
0
        public async Task LeaveClanAsync_WhenNotMember_ShouldBeOfTypeValidationResultWithErrors()
        {
            // Arrange
            var ownerId = new UserId();
            var clan    = new Clan("test", ownerId);

            var service = new ClanService(TestMock.ClanRepository.Object);

            // Act
            var result = await service.LeaveClanAsync(clan, new UserId());

            // Assert
            result.Should().BeOfType <DomainValidationResult <Clan> >();
            result.Errors.Should().NotBeEmpty();
        }
Ejemplo n.º 2
0
        public async Task LeaveClanAsync_WhenOwner_ShouldBeOfTypeValidationResult()
        {
            // Arrange
            var ownerId = new UserId();
            var clan    = new Clan("test", ownerId);

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

            TestMock.ClanRepository.Setup(repository => repository.Delete(It.IsAny <Clan>())).Verifiable();

            var service = new ClanService(TestMock.ClanRepository.Object);

            // Act
            var result = await service.LeaveClanAsync(clan, ownerId);

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