Esempio n. 1
0
        public async Task WhenGivenATenancyRef_Index_ShouldRespondWithFormattedJson()
        {
            var listTenancies = new ListTenanciesStub();

            listTenancies.AddTenancyResponse("000001/01", new ListTenancies.ResponseTenancy
            {
                TenancyRef                 = "000001/01",
                PropertyRef                = "prop/01",
                Tenure                     = "SEC",
                LastActionCode             = "CALLED",
                LastActionDate             = "2018-01-01 00:00:00Z",
                CurrentBalance             = "10.66",
                ArrearsAgreementStatus     = "ACTIVE",
                PrimaryContactName         = "Steven Leighton",
                PrimaryContactShortAddress = "123 Test Street",
                PrimaryContactPostcode     = "AB12 C12"
            });

            var response = await GetIndex(listTenancies, new List <string> {
                "000001/01"
            });

            var actualJson   = ResponseJson(response);
            var expectedJson = JsonConvert.SerializeObject(
                new Dictionary <string, object>
            {
                {
                    "tenancies", new List <Dictionary <string, object> >
                    {
                        new Dictionary <string, object>
                        {
                            { "ref", "000001/01" },
                            { "prop_ref", "prop/01" },
                            { "tenure", "SEC" },
                            { "current_balance", "10.66" },
                            { "current_arrears_agreement_status", "ACTIVE" },
                            {
                                "latest_action", new Dictionary <string, string>
                                {
                                    { "code", "CALLED" },
                                    { "date", "2018-01-01 00:00:00Z" }
                                }
                            },
                            {
                                "primary_contact", new Dictionary <string, string>
                                {
                                    { "name", "Steven Leighton" },
                                    { "short_address", "123 Test Street" },
                                    { "postcode", "AB12 C12" }
                                }
                            }
                        }
                    }
                }
            }
                );

            Assert.Equal(expectedJson, actualJson);
        }
Esempio n. 2
0
        public async Task WhenGivenNoTenancyRefs_Index_ShouldRespondWithNoResults()
        {
            var listTenancies = new ListTenanciesStub();
            var response      = await GetIndex(listTenancies, new List <string>());

            Assert.NotNull(response);

            var actualJson   = ResponseJson(response);
            var expectedJson = JsonConvert.SerializeObject
                               (
                new Dictionary <string, object> {
                { "tenancies", new List <Dictionary <string, object> >() }
            }
                               );

            Assert.Equal(expectedJson, actualJson);
        }
Esempio n. 3
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);
        }