public void ShouldNotGetCrewMembersFromCrewWithInvalidId() { CrewService crewService = new CrewService(_dbContext, _mainEventProvider); CrewController crewController = new CrewController(crewService); var ex = Assert.ThrowsAsync <HttpException>(async() => { ActionResult <List <CrewMembersListVm> > result = await crewController.GetCrewMembersAsync(123); }); Assert.That(ex.Message == "Fant ikke arbeidslaget med ID: 123"); }
public async Task ShouldGetCrewMembers() { Crew crew1 = _dbContext.Crews.Find(1); CrewService crewService = new CrewService(_dbContext, _mainEventProvider); CrewController crewController = new CrewController(crewService); ActionResult <List <CrewMembersListVm> > result = await crewController.GetCrewMembersAsync(crew1.Id); List <CrewMembersListVm> returnedCrewMembers = (List <CrewMembersListVm>)((OkObjectResult)result.Result).Value; Assert.AreEqual(1, returnedCrewMembers.Count); Assert.AreEqual(_createdUser1.Entity.Id, returnedCrewMembers[0].Id); }