Example #1
0
        public async Task When_FindAllCard_Then_ReturnAllExistingCars()
        {
            var carService = new Mock <ICarService>(MockBehavior.Strict);

            carService.Setup(p => p.GetCars()).Returns(Task.FromResult <IList <Car> >(new List <Car>()));

            WC.CarController carController = new WC.CarController(carService.Object);
            var result = await carController.GetCars();

            Assert.That(result, Is.TypeOf <OkObjectResult>());
            Assert.AreEqual((((result as OkObjectResult)?.Value as IList <Car>).Count), 0);
            carService.VerifyAll();
        }
Example #2
0
        public void When_RunWithoutService_Then_GetNullReferenceException()
        {
            var controller = new WC.CarController(null);

            Assert.That(async() => await controller.GetCars(), Throws.TypeOf <NullReferenceException>());
        }