Ejemplo n.º 1
0
        public async Task ShouldNotDoAnything_WhenGivenReferralAlreadyConfirmed(ReferralLeadState state)
        {
            // Arrange
            var fixture      = new ReferralLeadServiceTestsFixture();
            var confirmToken = "3l2k3h4lk";

            var referral = fixture.ReferralLeads.Single(x => x.ConfirmationToken == confirmToken);

            referral.State = state;

            // Act
            var result = await fixture.Service.ConfirmReferralLeadAsync(confirmToken);

            // Assert
            Assert.Equal(state, result.State);

            // Assert
            fixture.ReferralLeadRepositoryMock.Verify(
                x => x.UpdateAsync(
                    It.IsAny <ReferralLeadEncrypted>()),
                Times.Never);

            fixture.PropertyIntegrationClientMock.Verify(
                x => x.Api.RegisterLeadAsync(
                    It.IsAny <LeadRegisterRequestModel>()),
                Times.Never);

            fixture.NotificationPublisherServiceMock.Verify(
                x => x.LeadSuccessfullyConfirmedAsync(
                    It.IsAny <string>(),
                    It.IsAny <string>(),
                    It.IsAny <string>(),
                    It.IsAny <string>()),
                Times.Never);
        }
Ejemplo n.º 2
0
        public async Task ShouldInvalidOperationException_IfReferStatusNotConfirmed(ReferralLeadState state)
        {
            // Arrange
            var fixture      = new ReferralLeadServiceTestsFixture();
            var id           = Guid.Parse("57e80137-984c-44f0-ad6f-b555d46cd934");
            var approvalDate = DateTime.UtcNow;

            var referral = fixture.ReferralLeads.Single(x => x.Id == id);

            referral.State = state;

            // Act
            await Assert.ThrowsAsync <InvalidOperationException>(async() =>
            {
                await fixture.Service.ApproveReferralLeadAsync(id, approvalDate);
            });

            // Assert
            fixture.EventPublisher.Verify(
                x =>
                x.PublishAsync(It.IsAny <PropertyLeadApprovedReferralEvent>()),
                Times.Never);

            fixture.ReferralLeadRepositoryMock.Verify(
                x => x.UpdateAsync(
                    It.IsAny <ReferralLeadEncrypted>()),
                Times.Never);
        }
        private static ReferralLeadStatus GetStatus(ReferralLeadState state)
        {
            switch (state)
            {
            case ReferralLeadState.Pending:
                return(ReferralLeadStatus.Sent);

            case ReferralLeadState.Confirmed:
                return(ReferralLeadStatus.Accepted);

            case ReferralLeadState.Approved:
                return(ReferralLeadStatus.Approved);

            case ReferralLeadState.Rejected:
                return(ReferralLeadStatus.Rejected);

            default:
                throw new InvalidEnumArgumentException(nameof(state), (int)state, typeof(ReferralLeadState));
            }
        }