コード例 #1
0
        public void Should_Fail_By_Empty_Id()
        {
            // arrange
            var command = GetInviteCommandFake.InvalidByEmptyId().Generate();
            var sut     = new GetInviteValidator
            {
                CascadeMode = FluentValidation.CascadeMode.Stop
            };

            // act
            var result = sut.Validate(command);

            // assert
            result.AssertErrorsCount(1);
        }
コード例 #2
0
        public void Should_Succeed()
        {
            // arrange
            var command = GetInviteCommandFake.Valid().Generate();
            var sut     = new GetInviteValidator
            {
                CascadeMode = FluentValidation.CascadeMode.Stop
            };

            // act
            var result = sut.Validate(command);

            // assert
            result.Should().NotBeNull()
            .And.BeOfType <ValidationResult>();
            result.IsValid.Should().BeTrue();
        }
コード例 #3
0
        public async Task Handle_Should_Succeed_With_ValidCommand()
        {
            // arrange
            var expectedInvite = InviteFake.ValidWithStatus(InviteStatuses.Accepted).Generate();
            var command        = GetInviteCommandFake.Valid(expectedInvite.Id).Generate();
            var repository     = InviteRepositoryMockBuilder.Create()
                                 .GetByIdSuccess(input: command.Id, output: expectedInvite).Build();
            var sut = new GetInviteHandler(repository);

            // act
            var result = await sut.Handle(command, default);

            // assert
            result.Should().NotBeNull().And.BeOfType <SuccessResult>();
            result.Success.Should().BeTrue();
            result.Errors.Should().BeEmpty();
            result.As <SuccessResult>().StatusCode.Should().Be(StatusCodes.Status200OK);
            result.Data.Should().NotBeNull().And.BeOfType <InviteTestProxy>();
            result.Data.As <Invite>().Id.Should().Be(expectedInvite.Id);
            result.Data.As <Invite>().GetGuild().Id.Should().Be(expectedInvite.GuildId.Value);
            result.Data.As <Invite>().GetMember().Id.Should().Be(expectedInvite.MemberId.Value);
        }