Beispiel #1
0
        public void ParseHousePriceCsvRowMatchesExpectedHousePriceDao()
        {
            var housePriceFields =
                "E06000001,Hartlepool,E05008943,De Bruce,38000,38000,37000,30500,30000,30500,29500,31500,37000,39950,40000,42000,32000,32000,34750,35750,35750,35000,32450,34975,36650,43500,53372.5,52875,54995,57500,50497.5,48997.5,49475,48750,58187,62995,62995,60000,58475,57500,57500,59500,62575,72000,79000,79000,83000,86500,86000,90000,92500,97500,100000,112000,119500,108000,96500,92500,90000,85000,98000,98000,99997.5,99997.5,90000,98942.5,90000,81250,79975,76000,72412.5,68000,80000,85000,100000,90000,83000,75000,72500,82000,81000,82250,81000,78000,80000,80000,87000,100975,107225,115000,118250,124950,130000,126500,127975,124950,121375,128000,135000,131475,,,,,"
                .Split(",");
            var expectedHousePrice = new HousePrice
            {
                AverageHousePrice      = 131475,
                LocalAuthorityDistrict = new LocalAuthorityDistrict
                {
                    Code = "E06000001",
                    Name = "Hartlepool"
                },
                Ward = new Ward
                {
                    Code = "E05008943",
                    Name = "De Bruce"
                }
            };
            var expectedList = new List <HousePrice> {
                expectedHousePrice
            };

            _textFieldParser.ReadFields().Returns(housePriceFields)
            .AndDoes((action) => _textFieldParser.EndOfData.Returns(true));

            var actualList = _housePriceParser.Parse();

            Assert.AreEqual(expectedList, actualList);
        }
Beispiel #2
0
        public void ComputedEnumerableIsCorrect()
        {
            var housePrice1 = new HousePrice
            {
                AverageHousePrice = 100.00,
            };
            var housePrice2 = new HousePrice
            {
                AverageHousePrice = 200.00,
            };
            var housePrice3 = new HousePrice
            {
                AverageHousePrice = 300.00,
            };
            var housePrice4 = new HousePrice
            {
                AverageHousePrice = 400.00,
            };

            var housePrices = new List <HousePrice> {
                housePrice2, housePrice4, housePrice1, housePrice3
            };

            var expectedResult = new List <HousePrice> {
                housePrice1, housePrice2, housePrice3, housePrice4
            };

            var result = _sortHousePricesByAverageHousePricesQuery
                         .Compute(housePrices, null)
                         .Cast <HousePrice>()
                         .ToList();

            Assert.AreEqual(expectedResult, result);
        }
        public void ComputedEnumerableIsCorrect()
        {
            var lsoa1 = new LowerLayerSuperOutputArea
            {
                Code = "L1",
            };
            var lsoa2 = new LowerLayerSuperOutputArea
            {
                Code = "L2",
            };
            var lsoa3 = new LowerLayerSuperOutputArea
            {
                Code = "L3",
            };

            var ward1 = new Ward
            {
                Code = "W1",
            };
            var ward2 = new Ward
            {
                Code = "W2",
            };
            var ward3 = new Ward
            {
                Code = "W3",
            };


            var housePrice1 = new HousePrice
            {
                Ward = ward1,
            };
            var housePrice2 = new HousePrice
            {
                Ward = ward2,
            };
            var housePrice3 = new HousePrice
            {
                Ward = ward3,
            };

            var input = new List <LowerLayerSuperOutputArea> {
                lsoa2, lsoa3
            };
            var dataset = new Dataset
            {
                LowerLayerSuperOutputAreaCodeToWardCode = new Dictionary <string, string>
                {
                    { lsoa1.Code, ward1.Code },
                    { lsoa2.Code, ward2.Code },
                    { lsoa3.Code, ward3.Code },
                },
                HousePrices = new List <HousePrice> {
                    housePrice1, housePrice2, housePrice3
                },
            };

            var expectedResult = new List <HousePrice> {
                housePrice2, housePrice3
            };

            var actualResult = _getHousePricesOfLowerLayerSuperOutputAreasQuery
                               .Compute(input, dataset)
                               .Cast <HousePrice>()
                               .ToList();

            Assert.AreEqual(expectedResult, actualResult);
        }