private async Task ClearLandmark(int id, Landmark linkedObject = null) { var landmarks = CreateMockLandmarkDbSet(); var context = CreateMockLocationContext(landmarks: landmarks.Object); var service = new LocationService(context.Object); await service.ClearLandmark(id); if (linkedObject != null) { Assert.True((linkedObject.Expiry - DateTimeOffset.Now).TotalSeconds < -DateTimeTolerance); context.Verify(c => c.SaveChangesAsync()); } else { context.Verify(c => c.SaveChangesAsync(), Times.Never); } }