public string CreateLongAddress(AatfAddressData address)
        {
            if (address != null)
            {
                string siteAddressLong = address.Name + ",<br/>" + address.Address1;

                if (address.Address2 != null)
                {
                    siteAddressLong += ",<br/>" + address.Address2;
                }

                siteAddressLong += ",<br/>" + address.TownOrCity;

                if (address.CountyOrRegion != null)
                {
                    siteAddressLong += ",<br/>" + address.CountyOrRegion;
                }

                if (address.Postcode != null)
                {
                    siteAddressLong += ",<br/>" + address.Postcode;
                }

                siteAddressLong += ",<br/>" + address.CountryName;

                return(siteAddressLong);
            }
            else
            {
                return("&nbsp");
            }
        }
        public void Map_GivenSource_AddressDataIsMapped()
        {
            Guid   countryId   = Guid.NewGuid();
            string countryName = "Country";

            AatfAddressData addressData = new AatfAddressData("Name", "Address1", "Address2", "Town", "County", "Postcode", countryId, countryName);

            var result = map.Map(addressData);

            result.Name.Should().Be("Name");
            result.Address1.Should().Be("Address1");
            result.Address2.Should().Be("Address2");
            result.TownOrCity.Should().Be("Town");
            result.CountyOrRegion.Should().Be("County");
            result.Postcode.Should().Be("Postcode");
            result.CountryId.Should().Be(countryId);
        }
        public void CreateLongAddress_WithoutOptionalFields_ReturnsCorrectAddress()
        {
            AatfAddressData address = new AatfAddressData()
            {
                Name        = "Name",
                Address1    = "Address 1",
                TownOrCity  = "Town",
                CountryName = "Country"
            };

            string expected = "Name,<br/>Address 1,<br/>Town,<br/>Country";

            SentOnSiteSummaryListViewModel viewModel = new SentOnSiteSummaryListViewModel();

            string result = viewModel.CreateLongAddress(address);

            Assert.Equal(expected, result);
        }
Beispiel #4
0
        public async void IndexGet_GivenValidViewModel_MapperIsCalled()
        {
            var organisationId      = Guid.NewGuid();
            var returnId            = Guid.NewGuid();
            var aatfId              = Guid.NewGuid();
            var weeeSentOnId        = Guid.NewGuid();
            var siteAddressData     = new AatfAddressData("TEST", "TEST", "TEST", "TEST", "TEST", "TEST", Guid.NewGuid(), "TEST");
            var operatorAddressData = new AatfAddressData("TEST", "TEST", "TEST", "TEST", "TEST", "TEST", Guid.NewGuid(), "TEST");
            var weeeSentOn          = new WeeeSentOnData()
            {
                SiteAddress     = siteAddressData,
                OperatorAddress = operatorAddressData
            };

            A.CallTo(() => apiClient.SendAsync(A <string> ._, A <GetWeeeSentOnById> .That.Matches(w => w.WeeeSentOnId == weeeSentOnId))).Returns(weeeSentOn);

            await controller.Index(organisationId, returnId, aatfId, weeeSentOnId);

            A.CallTo(() => mapper.Map(A <ReturnAndAatfToSentOnRemoveSiteViewModelMapTransfer> .That.Matches(t => t.OrganisationId == organisationId &&
                                                                                                            t.ReturnId == returnId &&
                                                                                                            t.AatfId == aatfId &&
                                                                                                            t.WeeeSentOn == weeeSentOn))).MustHaveHappened(Repeated.Exactly.Once);
        }
        public void GenerateAddress_GivenAddressData_LongAddressNameShouldBeCreatedCorrectly()
        {
            var siteAddress     = new AatfAddressData("Site name", "Site address 1", "Site address 2", "Site town", "Site county", "GU22 7UY", Guid.NewGuid(), "Site country");
            var siteAddressLong = "Site name<br/>Site address 1<br/>Site address 2<br/>Site town<br/>Site county<br/>GU22 7UY<br/>Site country";

            var siteAddressWithoutAddress2     = new AatfAddressData("Site name", "Site address 1", null, "Site town", "Site county", "GU22 7UY", Guid.NewGuid(), "Site country");
            var siteAddressWithoutAddress2Long = "Site name<br/>Site address 1<br/>Site town<br/>Site county<br/>GU22 7UY<br/>Site country";

            var siteAddressWithoutCounty     = new AatfAddressData("Site name", "Site address 1", "Site address 2", "Site town", null, "GU22 7UY", Guid.NewGuid(), "Site country");
            var siteAddressWithoutCountyLong = "Site name<br/>Site address 1<br/>Site address 2<br/>Site town<br/>GU22 7UY<br/>Site country";

            var siteAddressWithoutPostcode     = new AatfAddressData("Site name", "Site address 1", "Site address 2", "Site town", "Site county", null, Guid.NewGuid(), "Site country");
            var siteAddressWithoutPostcodeLong = "Site name<br/>Site address 1<br/>Site address 2<br/>Site town<br/>Site county<br/>Site country";

            var result = controller.GenerateAddress(siteAddress);
            var resultWithoutAddress2 = controller.GenerateAddress(siteAddressWithoutAddress2);
            var resultWithoutCounty   = controller.GenerateAddress(siteAddressWithoutCounty);
            var resultWithoutPostcode = controller.GenerateAddress(siteAddressWithoutPostcode);

            result.Should().Be(siteAddressLong);
            resultWithoutAddress2.Should().Be(siteAddressWithoutAddress2Long);
            resultWithoutCounty.Should().Be(siteAddressWithoutCountyLong);
            resultWithoutPostcode.Should().Be(siteAddressWithoutPostcodeLong);
        }
 protected FacilityViewModelBase()
 {
     SiteAddressData = new AatfAddressData();
 }
 public AddFacilityViewModelBase()
 {
     ContactData     = new AatfContactData();
     SiteAddressData = new AatfAddressData();
 }