public void UpsertShouldModifyTheGivenExpense() { var options = new DbContextOptionsBuilder <ExpensesDbContext>() .UseInMemoryDatabase(databaseName: nameof(UpsertShouldModifyTheGivenExpense)) .Options; using (var context = new ExpensesDbContext(options)) { var expenseService = new ExpensesService(context); var added = new ExpensePostModel() { Description = "Variable", Type = "5", Location = "Sibiu", Date = Convert.ToDateTime("2019-05-05T11:11:11"), Currency = "USD", Sum = 555.77, Comments = new List <Comment>() { new Comment { Important = true, Text = "Very important expense", Owner = null } }, }; var toAdd = expenseService.Create(added, null); var update = new ExpensePostModel() { Description = "Variable-Updated" }; var toUp = expenseService.Create(update, null); var updateResult = expenseService.Upsert(toUp.Id, toUp); Assert.IsNotNull(updateResult); Assert.AreEqual(toUp.Description, updateResult.Description); } }