public void GetAllAvailable_ForSpecifiedVehicle() { var vehicleModel = new VehicleModel { Id = 1 }; var vehicles = new List <Vehicle> { new Vehicle { Id = 1, RegistrationNumber = "1", VehicleModel = vehicleModel }, new Vehicle { Id = 2, RegistrationNumber = "2", VehicleModel = vehicleModel }, new Vehicle { Id = 3, RegistrationNumber = "3", VehicleModel = vehicleModel }, }; var employees = new List <Employee> { new Employee { FirstName = "J.D", LastName = "Kyle", Vehicle = vehicles[1] }, new Employee { FirstName = "Ted", LastName = "Mosby", Vehicle = vehicles[0] }, }; var mockContext = new Mock <InstantDeliveryContext>(); mockContext.Setup(c => c.Employees).ReturnsDbSet(employees); mockContext.Setup(c => c.Vehicles).ReturnsDbSet(vehicles); mockContext.Setup(c => c.VehicleModels).ReturnsDbSet(vehicleModel); var controller = new VehiclesController(mockContext.Object); var result = controller.GetAllAvailable(new PageQuery { PageSize = 10, PageIndex = 1 }) as OkNegotiatedContentResult <PagedResult <VehicleDto> >; Assert.Equal(result?.Content.PageCollection.Count, 1); }