public async Task ShouldUpdateCrewName() { // Create 2 crews await CreateCrew(_crewName2); await CreateCrew(_crewName3); // Update one CrewService crewService = new CrewService(_dbContext, _mainEventProvider); CrewController crewController = new CrewController(crewService); CrewVm crewNewData = new CrewVm { CrewId = 2, CrewName = "New Name" }; await crewController.UpdateCrewAsync(crewNewData); // Check that only one has been changed Crew crew1 = _dbContext.Crews.Find(2); Assert.AreEqual(crewNewData.CrewName, crew1.Name); Crew crew2 = _dbContext.Crews.Find(3); Assert.AreEqual(crew2.Name, _crewName3); }
public void ShouldNotUpdateCrewIfDoesntExist() { CrewService crewService = new CrewService(_dbContext, _mainEventProvider); CrewController crewController = new CrewController(crewService); var ex = Assert.ThrowsAsync <HttpException>(async() => { ActionResult <CrewVm> result = await crewController.UpdateCrewAsync(new CrewVm { CrewId = 123, CrewName = "New Name" }); }); Assert.That(ex.Message == "Fant ikke arbeidslaget: New Name"); }