예제 #1
0
        public void GetById_NoVehicleFound_Returns404()
        {
            mockVehicleRepo.Setup(x => x.Read(It.IsAny <int>())).Returns((Vehicle)null);
            controller = new VehiclesController(mockVehicleRepo.Object);

            var result = controller.GetById(1);

            Assert.IsType(typeof(HttpNotFoundResult), result);
        }
        public void SearchVehicle()
        {
            var existingVehicle = GetEmptyVehicle();

            _repositoryMock.Get(Arg.Any <long>()).Returns(existingVehicle);
            _unitOfWorkMock.Vehicles.Returns(_repositoryMock);


            var controller = new VehiclesController(_unitOfWorkMock);

            var response = controller.GetById(1);

            Assert.AreEqual(existingVehicle.Code, response.Code);
        }
예제 #3
0
        public void GetById_VehicleFound_Returns200()
        {
            mockVehicleRepo.Setup(x => x.Read(It.IsAny <int>())).Returns(GenerateTestVehicle(1));
            controller = new VehiclesController(mockVehicleRepo.Object);

            var result   = controller.GetById(1);
            var okObject = result as HttpOkObjectResult;

            Assert.NotNull(okObject);
            var v = okObject.Value as Vehicle;

            Assert.NotNull(v);
            Assert.True(v.Equals(GenerateTestVehicle(1)));
        }