コード例 #1
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 async Task GivenValidInput_GatewayResponseWith_Success()
        {
            //arrange
            Tenancy tenancy = Fake.GenerateTenancyDetails();

            _stubTenanciesGateway.SetTenancyDetails(tenancy.TenancyRef, tenancy);
            _fakeGateway.Setup(s => s.CreateActionDiaryEntryAsync(It.Is <ArrearsActionCreateRequest>(i =>
                                                                                                     i.ArrearsAction.TenancyAgreementRef.Equals(tenancy.TenancyRef) &&
                                                                                                     i.ArrearsAction.ActionBalance.Equals(tenancy.CurrentBalance)
                                                                                                     )))
            .ReturnsAsync(new ArrearsActionResponse
            {
                Success       = true,
                ArrearsAction = new ArrearsActionLogDto
                {
                    ActionBalance       = tenancy.CurrentBalance,
                    ActionCategory      = "Test",
                    ActionCode          = "HAC",
                    IsCommentOnly       = true,
                    UserName            = "******",
                    Id                  = 1,
                    TenancyAgreementRef = tenancy.TenancyRef
                }
            });
            var request = new ActionDiaryRequest
            {
                ActionCategory      = "Test",
                ActionCode          = "HAC",
                Username            = "******",
                TenancyAgreementRef = tenancy.TenancyRef
            };
            //act
            var response = await _classUnderTest.ExecuteAsync(request);

            //assert
            Assert.Equal(true, response.Success);
            Assert.Equal(tenancy.TenancyRef, response.ArrearsAction.TenancyAgreementRef);
            Assert.Equal(tenancy.CurrentBalance, response.ArrearsAction.ActionBalance);
        }
コード例 #3
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);
        }