public async Task RemoveLocation() { // Inject CreateIdentity(Users[0].Auth); // Arrange UserTrips trip; Locations locations; using (var a = factory.CreateDbContext()) { trip = new UserTrips() { UserId = Users[0].Id, Name = "Trip to somewhere 2", Transportation = "BICYCLING" }; locations = new Locations() { Lang = 5, PlaceId = "PlaceId3", Long = 3, Name = "aweawezsS", TripId = trip.Id }; trip.Locations.Add(locations); await a.AddAsync(trip); await a.SaveChangesAsync(); } var expected = mapper.Map <LocationsViewModel>(locations); // Act var result = await controller.RemoveLocation(trip.Id, locations.Id); // Assert Assert.Equal(Serialize(expected), Serialize(((OkObjectResult)result).Value)); }