Пример #1
0
 public void AddTenancyResponse(string tenancyRef, ListTenancies.ResponseTenancy tenancyResponse)
 {
     stubTenancies[tenancyRef] = tenancyResponse;
 }
Пример #2
0
        public async Task WhenGivenATenancyRef_Index_ShouldRespondWithTenancyInfoForThatTenancy()
        {
            var faker = new Faker();
            var expectedTenancyResponse = new ListTenancies.ResponseTenancy
            {
                TenancyRef                 = faker.Random.Hash(),
                PropertyRef                = faker.Random.Hash(),
                Tenure                     = faker.Random.Word(),
                LastActionCode             = faker.Random.Word(),
                LastActionDate             = faker.Date.Recent().ToLongDateString(),
                CurrentBalance             = faker.Finance.Amount().ToString("C"),
                ArrearsAgreementStatus     = faker.Random.Word(),
                PrimaryContactName         = faker.Person.FullName,
                PrimaryContactShortAddress = faker.Address.StreetAddress(),
                PrimaryContactPostcode     = faker.Address.ZipCode()
            };

            var listTenancies = new ListTenanciesStub();

            listTenancies.AddTenancyResponse(expectedTenancyResponse.TenancyRef, expectedTenancyResponse);

            var response = await GetIndex(listTenancies, new List <string> {
                expectedTenancyResponse.TenancyRef
            });

            var actualJson   = ResponseJson(response);
            var expectedJson = JsonConvert.SerializeObject(
                new Dictionary <string, object>
            {
                {
                    "tenancies", new List <Dictionary <string, object> >
                    {
                        new Dictionary <string, object>
                        {
                            { "ref", expectedTenancyResponse.TenancyRef },
                            { "prop_ref", expectedTenancyResponse.PropertyRef },
                            { "tenure", expectedTenancyResponse.Tenure },
                            { "current_balance", expectedTenancyResponse.CurrentBalance },
                            { "current_arrears_agreement_status", expectedTenancyResponse.ArrearsAgreementStatus },
                            {
                                "latest_action", new Dictionary <string, string>
                                {
                                    { "code", expectedTenancyResponse.LastActionCode },
                                    { "date", expectedTenancyResponse.LastActionDate }
                                }
                            },
                            {
                                "primary_contact", new Dictionary <string, string>
                                {
                                    { "name", expectedTenancyResponse.PrimaryContactName },
                                    { "short_address", expectedTenancyResponse.PrimaryContactShortAddress },
                                    { "postcode", expectedTenancyResponse.PrimaryContactPostcode }
                                }
                            }
                        }
                    }
                }
            }
                );

            Assert.Equal(expectedJson, actualJson);
        }