public async Task UpdateUserAsync() { // Arrange var user = new User() { IsDriver = true, IsRider = true, Email = "*****@*****.**", Name = "Me", IdentityUserId = Guid.NewGuid() }; var userAdded = _context.Users.Add(user); await _context.SaveChangesAsync(); user.Id = userAdded.Id; user.Name = "Myself"; // Act await _membershipService.UpdateUserAsync(user); // Assert var userInDb = await _context.Users.FirstAsync(); Assert.AreEqual("Myself", userInDb.Name); Assert.AreEqual(1, await _context.Users.CountAsync()); }
public async Task EditVehicleAsync() { // Arrange _context.Vehicles.Add(_testVehicle1); await _context.SaveChangesAsync(); var vehicle = _testVehicle1; vehicle.Condition = "Fair"; // Act await _vehicleService.EditVehicleAsync(vehicle); // Assert Assert.AreEqual(1, (await _context.Vehicles.ToListAsync()).Count); var vehicleInDb = await _context.Vehicles.FirstAsync(v => v.Id == vehicle.Id); Assert.AreEqual(vehicle.ModelYear.Model.Make.Name, vehicleInDb.ModelYear.Model.Make.Name); Assert.AreEqual(vehicle.Condition, vehicleInDb.Condition); }
public async Task AddRideLegAsync() { // Arrange _context.Rides.Add(_testRide1); await _context.SaveChangesAsync(); // Act await _rideService.AddRideLegsAsync(_testRide1, _testRideLeg1, _testRideLeg2); // Assert var testRideInDb = await _context.Rides.Include(r => r.RideLegs).FirstAsync(r => r.Id == _testRide1.Id); Assert.AreEqual(2, testRideInDb.RideLegs.Count); Assert.AreEqual(2, await _context.RideLegs.CountAsync()); Assert.AreEqual(1, await _context.Rides.CountAsync()); Assert.AreEqual(1, testRideInDb.RideLegs.Count(r => r.Origin.Address.Line1 == _testLocation1.Address.Line1)); Assert.AreEqual(1, testRideInDb.RideLegs.Count(r => r.Origin.Address.Line1 == _testLocation2.Address.Line1)); }