Beispiel #1
0
 public async Task <JsonResult> GetCars()
 {
     // Because services are loaded by magic, we don't need ugly database spells here.
     // Let our async ICarSalesman interface do the job.
     // One could do all the assertions and checking from browser provided parameters here, if there were any,
     // or possibly map view models to business models (and vice versa).
     return(Json(await carSalesman.GetCars()));
 }
        public async Task TestCarListing()
        {
            if (carSalesman == null)
            {
                throw new Exception("Setup must have gone wrong");
            }
            // The test but using our own mocked type now.
            var cars = await carSalesman.GetCars();

            Assert.That(cars.Any(), "GetCars() didn't product any car. Should be three.");
        }