Exemplo n.º 1
0
        public async Task Handle_WhenCommandIsHandled_ThenShouldUpdateInvitationStatus(
            ProviderRegistrationsDbContext setupContext,
            ProviderRegistrationsDbContext confirmationContext,
            AddedPayeSchemeCommandHandler handler,
            AddedPayeSchemeCommand command,
            Invitation invitation)
        {
            //arrange
            invitation.UpdateStatus((int)InvitationStatus.InvitationSent, DateTime.Now);
            command.CorrelationId = invitation.Reference.ToString();
            setupContext.Invitations.Add(invitation);
            await setupContext.SaveChangesAsync();

            //act
            await((IRequestHandler <AddedPayeSchemeCommand, Unit>)handler).Handle(command, new CancellationToken());

            //assert
            var savedInvitation = await confirmationContext.Invitations.FirstAsync();

            savedInvitation.Status.Should().Be((int)InvitationStatus.PayeSchemeAdded);
        }
Exemplo n.º 2
0
        public async Task Handle_WhenInvalidStatusCommandIsHandled_ThenNoChangesAreMade(
            ProviderRegistrationsDbContext setupContext,
            ProviderRegistrationsDbContext confirmationContext,
            AddedPayeSchemeCommandHandler handler,
            AddedPayeSchemeCommand command,
            Invitation invitation)
        {
            //arrange
            invitation.UpdateStatus((int)InvitationStatus.LegalAgreementSigned, DateTime.Now);
            setupContext.Invitations.Add(invitation);
            await setupContext.SaveChangesAsync();

            command.CorrelationId = invitation.Reference.ToString();

            //act
            await((IRequestHandler <AddedPayeSchemeCommand, Unit>)handler).Handle(command, new CancellationToken());

            //assert
            // Confirm nothing has changed.
            var invite = await confirmationContext.Invitations.FirstAsync();

            invite.Status.Should().Be((int)InvitationStatus.LegalAgreementSigned);
        }
Exemplo n.º 3
0
        public async Task Handle_WhenDoesntExistCommandIsHandled_ThenNoChangesAreMade(
            ProviderRegistrationsDbContext setupContext,
            ProviderRegistrationsDbContext confirmationContext,
            AddedPayeSchemeCommandHandler handler,
            AddedPayeSchemeCommand command,
            Invitation invitation)
        {
            //arrange
            setupContext.Invitations.Add(invitation);
            await setupContext.SaveChangesAsync();

            var statusBefore = invitation.Status;

            command.CorrelationId = invitation.Reference.ToString();

            //act
            await((IRequestHandler <AddedPayeSchemeCommand, Unit>)handler).Handle(command, new CancellationToken());

            //assert
            // Confirm nothing has changed.
            var invite = await confirmationContext.Invitations.FirstAsync();

            invite.Status.Should().Be(statusBefore);
        }