Exemple #1
0
        public async Task WhenATenancyRefIsGiven_ResponseShouldIncludePaymentsForThatTenancy()
        {
            var gateway = new StubTenanciesGateway();
            var payment = Fake.GeneratePaymentTransactionDetails();

            gateway.SetPaymentTransactionDetails(payment.TenancyRef, payment);

            var listAllPayments = new ListAllPayments(gateway);
            var response        = await listAllPayments.ExecuteAsync(payment.TenancyRef);

            var expectedResponse = new ListAllPayments.PaymentTransactionResponse
            {
                PaymentTransactions = new List <ListAllPayments.PaymentTransaction>
                {
                    new ListAllPayments.PaymentTransaction
                    {
                        Ref         = payment.TransactionRef,
                        Amount      = payment.Amount.ToString("C"),
                        Date        = string.Format("{0:u}", payment.Date),
                        Type        = payment.Type,
                        PropertyRef = payment.PropertyRef,
                        Description = payment.Description
                    }
                }
            };

            expectedResponse.PaymentTransactions[0].Should().BeEquivalentTo(response.PaymentTransactions[0]);
        }
        public void WhenATenancyRefIsGiven_ResponseShouldIncludeActionDiaryForThatTenancy()
        {
            var gateway     = new StubTenanciesGateway();
            var actionDiary = Fake.GenerateActionDiary();

            gateway.SetActionDiaryDetails(actionDiary.TenancyRef, actionDiary);

            var listAllActionDiary = new ListAllArrearsActions(gateway);
            var response           = listAllActionDiary.Execute(actionDiary.TenancyRef);

            var expectedResponse = new ListAllArrearsActions.ArrearsActionDiaryResponse
            {
                ActionDiaryEntries = new List <ListAllArrearsActions.ArrearsActionDiaryEntry>
                {
                    new ListAllArrearsActions.ArrearsActionDiaryEntry
                    {
                        Balance = actionDiary.Balance.ToString("C"),
                        Date    = string.Format("{0:u}", actionDiary.Date),
                        Code    = actionDiary.Code,
                        Type    = actionDiary.Type,
                        Comment = actionDiary.Comment,
                        UniversalHousingUsername = actionDiary.UniversalHousingUsername
                    }
                }
            };

            Assert.Equal(expectedResponse.ActionDiaryEntries, response.ActionDiaryEntries);
        }
Exemple #3
0
        public void WhenATenancyRefIsGiven_ResponseShouldIncludeDetailsOnThatTenancy_Example1()
        {
            var gateway = new StubTenanciesGateway();
            var tenancy = Fake.GenerateTenancyListItem();

            gateway.SetTenancyListItem(tenancy.TenancyRef, tenancy);

            var listTenancies  = new ListTenancies(gateway);
            var actualResponse = listTenancies.Execute(new List <string> {
                tenancy.TenancyRef
            });
            var expectedResponse = new ListTenancies.Response
            {
                Tenancies = new List <ListTenancies.ResponseTenancy>
                {
                    new ListTenancies.ResponseTenancy
                    {
                        TenancyRef                 = tenancy.TenancyRef,
                        PropertyRef                = tenancy.PropertyRef,
                        Tenure                     = tenancy.Tenure,
                        LastActionCode             = tenancy.LastActionCode,
                        LastActionDate             = String.Format("{0:u}", tenancy.LastActionDate),
                        CurrentBalance             = tenancy.CurrentBalance.ToString("C"),
                        ArrearsAgreementStatus     = tenancy.ArrearsAgreementStatus,
                        PrimaryContactName         = tenancy.PrimaryContactName,
                        PrimaryContactShortAddress = tenancy.PrimaryContactShortAddress,
                        PrimaryContactPostcode     = tenancy.PrimaryContactPostcode
                    }
                }
            };

            Assert.Equal(expectedResponse.Tenancies, actualResponse.Tenancies);
        }
Exemple #4
0
        public void WhenGivenATenancyRef_ShouldReturnATenancyResponse()
        {
            var gateway       = new StubTenanciesGateway();
            var listTenancies = new ListTenancies(gateway);
            var response      = listTenancies.Execute(new List <string>());

            Assert.IsType(typeof(ListTenancies.Response), response);
        }
Exemple #5
0
        public void WhenThereAreNoTenancyRefsGiven_ShouldReturnNone()
        {
            var gateway       = new StubTenanciesGateway();
            var listTenancies = new ListTenancies(gateway);
            var response      = listTenancies.Execute(new List <string>());

            Assert.Empty(response.Tenancies);
        }
        public void WhenGivenATenancyRefThatDoesntExist_ShouldReturnAnEmptyArrearsActionsResponse()
        {
            var gateway        = new StubTenanciesGateway();
            var listAllActions = new ListAllArrearsActions(gateway);
            var response       = listAllActions.Execute("");

            Assert.IsType(typeof(ListAllArrearsActions.ArrearsActionDiaryResponse), response);
            Assert.Empty(response.ActionDiaryEntries);
        }
Exemple #7
0
        public async Task WhenGivenATenancyRefThatDoesntExist_ShouldReturnAnEmptyPaymentResponse()
        {
            var gateway         = new StubTenanciesGateway();
            var listAllPayments = new ListAllPayments(gateway);
            var response        = await listAllPayments.ExecuteAsync("");

            Assert.IsType(typeof(ListAllPayments.PaymentTransactionResponse), response);
            Assert.Empty(response.PaymentTransactions);
        }
Exemple #8
0
        public void WhenGivenATenancyRefThatDoesntExist_ShouldReturnAnEmptyTenancyResponse()
        {
            var gateway = new StubTenanciesGateway();
            var tenancyDetailsForRef = new TenancyDetailsForRef(gateway);

            var response = tenancyDetailsForRef.Execute(" ");

            Assert.IsType(typeof(TenancyDetailsForRef.TenancyResponse), response);
            Assert.Equal(null, response.TenancyDetails.TenancyRef);
        }
Exemple #9
0
        public void WhenGivenATenancyRef_ShouldReturnAnTenancyResponse()
        {
            var gateway = new StubTenanciesGateway();
            var tenancyDetailsForRef = new TenancyDetailsForRef(gateway);

            var tenancy = Fake.GenerateTenancyDetails();

            gateway.SetTenancyDetails(tenancy.TenancyRef, tenancy);

            var response = tenancyDetailsForRef.Execute(tenancy.TenancyRef);

            Assert.IsType(typeof(TenancyDetailsForRef.TenancyResponse), response);
        }
        public void WhenGivenATenancyRef_ShouldReturnAnActionDiaryResponse()
        {
            var gateway        = new StubTenanciesGateway();
            var listAllActions = new ListAllArrearsActions(gateway);

            var actionDiary = Fake.GenerateActionDiary();

            gateway.SetActionDiaryDetails(actionDiary.TenancyRef, actionDiary);

            var response = listAllActions.Execute(actionDiary.TenancyRef);

            Assert.IsType(typeof(ListAllArrearsActions.ArrearsActionDiaryResponse), response);
        }
Exemple #11
0
        public async Task WhenGivenATenancyRef_ShouldReturnAPaymentResponse()
        {
            var gateway         = new StubTenanciesGateway();
            var listAllPayments = new ListAllPayments(gateway);

            var payment = Fake.GeneratePaymentTransactionDetails();

            gateway.SetPaymentTransactionDetails(payment.TenancyRef, payment);

            var response = await listAllPayments.ExecuteAsync(payment.TenancyRef);

            Assert.IsType(typeof(ListAllPayments.PaymentTransactionResponse), response);
        }
Exemple #12
0
        public void WhenGivenSomeTenanciesAndSomeVoid_ShouldReturnMatchedTenancies()
        {
            var gateway  = new StubTenanciesGateway();
            var tenancy1 = Fake.GenerateTenancyListItem();
            var tenancy2 = Fake.GenerateTenancyListItem();

            gateway.SetTenancyListItem(tenancy1.TenancyRef, tenancy1);
            gateway.SetTenancyListItem(tenancy2.TenancyRef, tenancy2);

            var listTenancies  = new ListTenancies(gateway);
            var actualResponse = listTenancies.Execute(new List <string> {
                tenancy1.TenancyRef, tenancy2.TenancyRef, "FAKE/01"
            });
            var expectedResponse = new ListTenancies.Response
            {
                Tenancies = new List <ListTenancies.ResponseTenancy>
                {
                    new ListTenancies.ResponseTenancy
                    {
                        TenancyRef                 = tenancy1.TenancyRef,
                        PropertyRef                = tenancy1.PropertyRef,
                        Tenure                     = tenancy1.Tenure,
                        LastActionCode             = tenancy1.LastActionCode,
                        LastActionDate             = String.Format("{0:u}", tenancy1.LastActionDate),
                        CurrentBalance             = tenancy1.CurrentBalance.ToString("C"),
                        ArrearsAgreementStatus     = tenancy1.ArrearsAgreementStatus,
                        PrimaryContactName         = tenancy1.PrimaryContactName,
                        PrimaryContactShortAddress = tenancy1.PrimaryContactShortAddress,
                        PrimaryContactPostcode     = tenancy1.PrimaryContactPostcode
                    },
                    new ListTenancies.ResponseTenancy
                    {
                        TenancyRef                 = tenancy2.TenancyRef,
                        PropertyRef                = tenancy2.PropertyRef,
                        Tenure                     = tenancy2.Tenure,
                        LastActionCode             = tenancy2.LastActionCode,
                        LastActionDate             = String.Format("{0:u}", tenancy2.LastActionDate),
                        CurrentBalance             = tenancy2.CurrentBalance.ToString("C"),
                        ArrearsAgreementStatus     = tenancy2.ArrearsAgreementStatus,
                        PrimaryContactName         = tenancy2.PrimaryContactName,
                        PrimaryContactShortAddress = tenancy2.PrimaryContactShortAddress,
                        PrimaryContactPostcode     = tenancy2.PrimaryContactPostcode
                    }
                }
            };

            Assert.Equal(expectedResponse.Tenancies, actualResponse.Tenancies);
        }
        public CreateArrearsActionDiaryUseCaseTests()
        {
            _fakeGateway          = new Mock <IArrearsActionDiaryGateway>();
            _stubTenanciesGateway = new StubTenanciesGateway();
            var credentialsService = new Mock <ICredentialsService>();

            credentialsService.Setup(s => s.GetUhSourceSystem()).Returns("TestSystem");
            credentialsService.Setup(s => s.GetUhUserCredentials()).Returns(new UserCredential
            {
                UserName     = "******",
                UserPassword = "******",
            });
            IArrearsServiceRequestBuilder requestBuilder = new ArrearsServiceRequestBuilder(credentialsService.Object);

            _classUnderTest = new CreateArrearsActionDiaryUseCase(_fakeGateway.Object, _stubTenanciesGateway, requestBuilder);
        }
Exemple #14
0
        public void WhenATenancyRefIsGiven_ResponseShouldIncludeTenancyDetails()
        {
            var gateway = new StubTenanciesGateway();
            var tenancy = Fake.GenerateTenancyDetails();

            gateway.SetTenancyDetails(tenancy.TenancyRef, tenancy);

            var tenancyDetails = new TenancyDetailsForRef(gateway);
            var response       = tenancyDetails.Execute(tenancy.TenancyRef);

            var expectedResponse = new TenancyDetailsForRef.TenancyResponse()
            {
                TenancyDetails = new TenancyDetailsForRef.Tenancy()
                {
                    TenancyRef                = tenancy.TenancyRef,
                    PropertyRef               = tenancy.PropertyRef,
                    Tenure                    = tenancy.Tenure,
                    Rent                      = tenancy.Rent.ToString("C"),
                    Service                   = tenancy.Service.ToString("C"),
                    OtherCharge               = tenancy.OtherCharge.ToString("C"),
                    CurrentBalance            = tenancy.CurrentBalance.ToString("C"),
                    PrimaryContactName        = tenancy.PrimaryContactName,
                    PrimaryContactLongAddress = tenancy.PrimaryContactLongAddress,
                    PrimaryContactPostcode    = tenancy.PrimaryContactPostcode,
                    ArrearsAgreementStatus    = tenancy.AgreementStatus,

                    ArrearsActionDiary = tenancy.ArrearsActionDiary.ConvertAll(tenancyActionDiary => new TenancyDetailsForRef.ArrearsActionDiaryEntry
                    {
                        Code    = tenancyActionDiary.Code,
                        Type    = tenancyActionDiary.Type,
                        Balance = tenancyActionDiary.Balance.ToString("C"),
                        Comment = tenancyActionDiary.Comment,
                        Date    = string.Format("{0:u}", tenancyActionDiary.Date),
                        UniversalHousingUsername = tenancyActionDiary.UniversalHousingUsername
                    }),

                    ArrearsAgreements = tenancy.ArrearsAgreements.ConvertAll(tenancyAgreement => new TenancyDetailsForRef.ArrearsAgreement
                    {
                        Amount       = tenancyAgreement.Amount.ToString("C"),
                        Breached     = tenancyAgreement.Breached.ToString(),
                        ClearBy      = string.Format("{0:u}", tenancyAgreement.ClearBy),
                        Frequency    = tenancyAgreement.Frequency,
                        StartBalance = tenancyAgreement.StartBalance.ToString("C"),
                        Startdate    = string.Format("{0:u}", tenancyAgreement.Startdate),
                        Status       = tenancyAgreement.Status
                    })
                }
            };

            Assert.Equal(expectedResponse.TenancyDetails.ArrearsAgreementStatus, response.TenancyDetails.ArrearsAgreementStatus);
            Assert.Equal(expectedResponse.TenancyDetails.CurrentBalance, response.TenancyDetails.CurrentBalance);
            Assert.Equal(expectedResponse.TenancyDetails.PropertyRef, response.TenancyDetails.PropertyRef);
            Assert.Equal(expectedResponse.TenancyDetails.Tenure, response.TenancyDetails.Tenure);
            Assert.Equal(expectedResponse.TenancyDetails.Rent, response.TenancyDetails.Rent);
            Assert.Equal(expectedResponse.TenancyDetails.Service, response.TenancyDetails.Service);
            Assert.Equal(expectedResponse.TenancyDetails.OtherCharge, response.TenancyDetails.OtherCharge);
            Assert.Equal(expectedResponse.TenancyDetails.PrimaryContactLongAddress, response.TenancyDetails.PrimaryContactLongAddress);
            Assert.Equal(expectedResponse.TenancyDetails.PrimaryContactName, response.TenancyDetails.PrimaryContactName);
            Assert.Equal(expectedResponse.TenancyDetails.PrimaryContactPostcode, response.TenancyDetails.PrimaryContactPostcode);
            Assert.Equal(expectedResponse.TenancyDetails.ArrearsActionDiary, response.TenancyDetails.ArrearsActionDiary);
            Assert.Equal(expectedResponse.TenancyDetails.ArrearsAgreements, response.TenancyDetails.ArrearsAgreements);
        }