public ParkingLotTest() { var context = new ParkingContext(dbContextOptions); userRepository = new UserRepository(context); _userBusiness = new UserBussiness(userRepository); parkingLotRepository = new ParkingRepository(context); _parkingLotBusiness = new ParkingBusiness(parkingLotRepository); IConfigurationBuilder _configuration = new ConfigurationBuilder(); _configuration.AddJsonFile("appsettings.json"); configuration = _configuration.Build(); parkingLotController = new ParkingLotController(_parkingLotBusiness); registrationController = new RegistrationController(_userBusiness, configuration); }
public async Task ReturnAllParkingLots_When_GetIsCalled() { // Arrange var parkingLot = new ParkingLot(); var parkingLots = new List <ParkingLot> { parkingLot }; _mock.Setup(r => r.GetAllAsync()).Returns(Task.FromResult(parkingLots)); var controller = new ParkingLotController(_mock.Object); // Act var actionResult = await controller.Get(); if (actionResult is OkObjectResult viewResult) { var actualParkingLots = viewResult.Value as ParkingLot; // Assert Assert.AreEqual(parkingLots, actualParkingLots); } }
public async Task ReturnParkingLot_When_GetIsCalledWithId() { // Arrange var parkingLot = new ParkingLot { ParkingLotId = 2 }; _mock.Setup(r => r.GetByIdAsync(parkingLot.ParkingLotId)).Returns(Task.FromResult(parkingLot)); var controller = new ParkingLotController(_mock.Object); // Act var actionResult = await controller.Get(parkingLot.ParkingLotId); if (actionResult is OkObjectResult viewResult) { var actualParkingLot = viewResult.Value as ParkingLot; // Assert Assert.AreEqual(actualParkingLot, parkingLot); } }