public void ShouldNotGetCrewLeadersFromCrewWithInvalidId() { CrewService crewService = new CrewService(_dbContext, _mainEventProvider); CrewController crewController = new CrewController(crewService); var ex = Assert.ThrowsAsync <HttpException>(async() => { ActionResult <List <CrewMembersListVm> > result = await crewController.GetCrewLeadersAsync(123); }); Assert.That(ex.Message == "Fant ingen arbeidslagsledere til arbeidslaget med id 123"); }
public async Task ShouldAddCrewLeader() { await CreateCrew(_crewName2); Crew crew2 = _dbContext.Crews.Find(2); CrewService crewService = new CrewService(_dbContext, _mainEventProvider); CrewController crewController = new CrewController(crewService); ActionResult <List <CrewMembersListVm> > result = await crewController.GetCrewLeadersAsync(crew2.Id); List <CrewMembersListVm> returnedCrewLeaders = (List <CrewMembersListVm>)((OkObjectResult)result.Result).Value; Assert.AreEqual(0, returnedCrewLeaders.Count); await crewController.AddCrewLeaderAsync(crew2.Id, _createdUser2.Entity.Id); result = await crewController.GetCrewLeadersAsync(crew2.Id); returnedCrewLeaders = (List <CrewMembersListVm>)((OkObjectResult)result.Result).Value; Assert.AreEqual(1, returnedCrewLeaders.Count); Assert.AreEqual(_createdUser2.Entity.Id, returnedCrewLeaders[0].Id); }