public ActionResult <Bank> Edit(int bankId, [FromBody] Bank editBank) { try { editBank.Id = bankId; return(Ok(_bs.Edit(editBank))); } catch (System.Exception e) { return(BadRequest(e.Message)); } }
public void EditMethodShouldEditBank() { var dbContext = YourMoney.Tests.Base.BaseServiceTests.GetDatabase(); var item = new Bank() { Id = 1, Name = "ProCredit" }; var items = new BanksService(dbContext); items.Add(item.Name); items.Edit(item.Id, "DSK"); var result = dbContext.Banks.FirstOrDefault(x => x.Name == "DSK"); Assert.AreEqual("DSK", result.Name); }
public void EditMethodShouldEditBank() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: "AddBank_Banks_DB") .Options; var dbContext = new ApplicationDbContext(options); var item = new Bank() { Id = 1, Name = "ProCredit" }; var items = new BanksService(dbContext); items.Add(item.Name); items.Edit(item.Id, "DSK"); var result = dbContext.Banks.FirstOrDefault(x => x.Name == "DSK"); Assert.AreEqual("DSK", result.Name); }