Esempio n. 1
0
        public void Should_Calculate_Building_Metrics_For_All_SubDivisionSite_Type(decimal width, decimal length, decimal siteCoverage, decimal avgLotSize)
        {
            var subDivisionConfigurationStub = new SubDivisionConfiguration(new Percent(siteCoverage), avgLotSize);
            var subDivisionSite = new SubDivisionSite(width, length, subDivisionConfigurationStub);
            var output          = subDivisionSite.Metrics();

            Assert.Equal(5000m, subDivisionSite.SiteArea);
            Assert.Equal(300m, subDivisionSite.SitePerimeter);


            Assert.NotNull(output);
            Assert.Equal(15m, output.NumberOfLots);
        }
Esempio n. 2
0
        /// <summary>
        /// Factory Method to instantiate different development sites
        /// </summary>
        /// <param name="input">an InputModel instance from which development site will be instantiated</param>
        /// <returns>IDevelopmentSite</returns>
        /// <exception cref="ApplicationException">throws exception if InputModel.DevelopmentType is not valid</exception>
        public static IDevelopmentSite ToDevelopmentSite(this InputModel input)
        {
            if (input == null)
            {
                return(null);
            }
            IDevelopmentSite site;

            switch (input.site_config.development_type)
            {
            case DevelopmentType.apartment:
            {
                site = new ApartmentSite(input.Width, input.Length, new ApartmentConfiguration(input.site_config.num_storeys, new Percent(input.site_config.site_coverage), input.site_config.avg_apt_area));
                break;
            }

            case DevelopmentType.commercial:
            {
                site = new CommercialSite(input.Width, input.Length, new CommercialConfiguration(input.site_config.num_storeys, new Percent(input.site_config.site_coverage), input.site_config.commerical_mix, input.site_config.retail_mix));
                break;
            }

            case DevelopmentType.mixed_use:
            {
                site = new MixedSite(input.Width, input.Length, new MixedConfiguration(input.site_config.num_storeys, new Percent(input.site_config.site_coverage), input.site_config.commerical_mix, input.site_config.retail_mix, input.site_config.residential_mix, input.site_config.avg_apt_area));
                break;
            }

            case DevelopmentType.subdivision:
            {
                site = new SubDivisionSite(input.Width, input.Length, new SubDivisionConfiguration(new Percent(input.site_config.site_coverage), input.site_config.avg_lot_size));
                break;
            }

            default:
                throw new ApplicationException($"Not valid Development Type:{input.site_config.development_type}");
            }

            return(site);
        }