public void Update_State() { var stateToSave = new State(); stateToSave.Name = "Buenos Aires"; stateToSave.Id = 1; var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: "Update_State") .Options; using (var context = new ApplicationDbContext(options)) { var service = new StatesService(context); service.AddState(stateToSave); var stateSaved = service.GetStateById(1); stateSaved.Name = "updatedName"; service.UpdateState(stateSaved); Assert.Equal("updatedName", service.GetStateById(1).Name); } }
public void Get_State_By_Id() { var stateToSave = new State(); stateToSave.Name = "Buenos Aires"; stateToSave.Id = 1; var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: "Get_All_state_in_database") .Options; using (var context = new ApplicationDbContext(options)) { var service = new StatesService(context); service.AddState(stateToSave); Assert.NotNull(service.GetStateById(1)); } }