public async void PostEditNotFound() { using (var database = new TestDb()) { var controller = new IndividualsController(database.Context); IActionResult result = await controller.Edit(50, new Individual(50, "Test Individual Modified", 2)); CheckMessage(result, "The selected Individual could not be found."); } }
public async void PostEditNullBreedId() { using (var database = new TestDb()) { var controller = new IndividualsController(database.Context); IActionResult result = await controller.Edit(2, new Individual { Id = 2, Name = "Fido" }); CheckMessage(result, "You must select a Breed for this Individual."); } }
public async void PostEditBreedDoesntExist() { using (var database = new TestDb()) { var controller = new IndividualsController(database.Context); IActionResult result = await controller.Edit(2, new Individual(2, "Fido", 100)); CheckMessage(result, "The selected Breed could not be found."); } }
public async void PostEditNoName() { using (var database = new TestDb()) { var controller = new IndividualsController(database.Context); IActionResult result = await controller.Edit(2, new Individual(2, string.Empty, 2)); CheckMessage(result, "An Individual must have a name."); } }
public async void PostEditNegativeBreedId() { using (var database = new TestDb()) { var controller = new IndividualsController(database.Context); IActionResult result = await controller.Edit(2, new Individual(2, "Fido", -1)); CheckMessage(result, $"The Breed ID must be between 1 and {int.MaxValue}."); } }
public async void PostEditMismatchedIds() { using (var database = new TestDb()) { var controller = new IndividualsController(database.Context); IActionResult result = await controller.Edit(1, new Individual { Id = 2 }); CheckMessage(result, "The Individual ID provided was invalid."); } }
public async void PostEditZeroId() { using (var database = new TestDb()) { var controller = new IndividualsController(database.Context); IActionResult result = await controller.Edit(0, new Individual()); CheckMessage(result, $"The Individual ID must be between 1 and {int.MaxValue}."); } }
public async void GetEditNullId() { using (var database = new TestDb()) { var controller = new IndividualsController(database.Context); IActionResult result = await controller.Edit(null); CheckMessage(result, "The Individual ID provided was invalid."); } }
public async void GetEditFound() { using (var database = new TestDb()) { var controller = new IndividualsController(database.Context); IActionResult result = await controller.Edit(2); IndividualViewModel viewModel = CheckViewModel(result); Individual individual = database.Context.Individuals.SingleOrDefault(i => i.Id == 2); Assert.Equal(2, viewModel.Individual.Id); Assert.Equal(individual.Name, viewModel.Individual.Name); Assert.NotEmpty(viewModel.Breeds); } }
public async void PostEditSaved() { using (var database = new TestDb()) { var controller = new IndividualsController(database.Context); IActionResult result = await controller.Edit(6, new Individual(6, "Modified Individual", 4)); RedirectToActionResult redirect = Assert.IsType <RedirectToActionResult>(result); Assert.Equal("Index", redirect.ActionName); Individual individual = database.Context.Individuals.SingleOrDefault(b => b.Id == 6); Assert.Equal("Modified Individual", individual.Name); } }