コード例 #1
0
        public async Task GIVEN_WEEKEND_CASE_RETURN_FLATRATES()
        {
            List <TestDomainObject> testCases = new List <TestDomainObject>()
            {
                new TestDomainObject()
                {
                    Entry    = new DateTime(2017, 12, 23, 9, 0, 0),  //23/12/2017 09:00 Sat
                    Exit     = new DateTime(2017, 12, 23, 10, 0, 0), //23/12/2017 10:00 Sat
                    Expected = new ParkingRates {
                        Name = "WEEKEND", Price = 10
                    }
                }
                ,
                new TestDomainObject()
                {
                    Entry    = new DateTime(2017, 12, 23, 00, 0, 0), //23/12/2017 00:00 Sat
                    Exit     = new DateTime(2017, 12, 24, 10, 0, 0), //24/12/2017 10:00 Sunday
                    Expected = new ParkingRates {
                        Name = "WEEKEND", Price = 10
                    }
                }
            };

            foreach (var c in testCases)
            {
                var returnResult = await _ParkingCalculator.Calculations(c.Entry, c.Exit);

                Assert.Equal(returnResult.Price, c.Expected.Price);
                Assert.Equal(returnResult.Name.ToString(), c.Expected.Name.ToString());
            }
        }
コード例 #2
0
ファイル: ParkingController.cs プロジェクト: ImranMA/Parking
        public async Task <IActionResult> Post(DateTime Start, DateTime End)
        {
            try
            {
                //Controller call to Domain operations Service
                var serviceResult = await _parkingRatesCalculator.Calculations(Start, End);

                //Domain Model to Resource Mapping
                var mappedResourceObject = _mapper.Map <ParkingRates, ParkingRatesResourceModel>(serviceResult);

                return(Ok(mappedResourceObject));
            }
            catch (Exception)
            {
                return(NotFound());
            }
        }