Example #1
0
        public async Task And_Both_AccountLegalEntityId_And_ProviderId_Then_Not_Valid(
            ChangeOfPartyCommand command,
            ChangeOfPartyCommandValidator validator)
        {
            var result = await validator.ValidateAsync(command);

            result.IsValid().Should().BeFalse();
            result.ValidationDictionary.Keys.Should().Contain(nameof(command.ProviderId));
        }
Example #2
0
        public async Task And_Guid_And_ProviderId_Then_Is_Valid(
            ChangeOfPartyCommand command,
            ChangeOfPartyCommandValidator validator)
        {
            command.AccountLegalEntityId = null;

            var result = await validator.ValidateAsync(command);

            result.IsValid().Should().BeTrue();
        }
Example #3
0
        public async Task And_Default_Guid_Then_Not_Valid(
            ChangeOfPartyCommand command,
            ChangeOfPartyCommandValidator validator)
        {
            command.ReservationId        = Guid.Empty;
            command.AccountLegalEntityId = null;

            var result = await validator.ValidateAsync(command);

            result.IsValid().Should().BeFalse();
            result.ValidationDictionary.Keys.Should().Contain(nameof(command.ReservationId));
        }
        public void And_Command_Fails_Validation_Then_Throws_ArgumentException(
            ChangeOfPartyCommand command,
            string propertyName,
            [Frozen] ValidationResult validationResult,
            ChangeOfPartyCommandHandler handler)
        {
            validationResult.AddError(propertyName);

            var act = new Func <Task>(async() => await handler.Handle(command, CancellationToken.None));

            act.Should().Throw <ArgumentException>()
            .WithMessage($"The following parameters have failed validation*{propertyName}*");
        }
        public async Task Then_Clones_Existing_Reservation_And_Returns_New_ReservationId(
            ChangeOfPartyCommand command,
            Guid newReservationId,
            [Frozen] ValidationResult validationResult,
            [Frozen] Mock <IAccountReservationService> mockService,
            ChangeOfPartyCommandHandler handler)
        {
            validationResult.ValidationDictionary.Clear();
            mockService
            .Setup(service => service.ChangeOfParty(
                       It.Is <ChangeOfPartyServiceRequest>(request =>
                                                           request.ReservationId == command.ReservationId)))
            .ReturnsAsync(newReservationId);

            var result = await handler.Handle(command, CancellationToken.None);

            result.ReservationId.Should().Be(newReservationId);
        }