예제 #1
0
        public async Task ShouldAddCrewMember()
        {
            await CreateCrew(_crewName2);

            Crew     crew2    = _dbContext.Crews.Find(2);
            CrewUser crewUser = _dbContext.CrewUsers.Find(1);

            CrewService    crewService    = new CrewService(_dbContext, _mainEventProvider);
            CrewController crewController = new CrewController(crewService);

            ActionResult <List <CrewMembersListVm> > result = await crewController.GetCrewMembersAsync(crew2.Id);

            List <CrewMembersListVm> returnedCrewMembers = (List <CrewMembersListVm>)((OkObjectResult)result.Result).Value;

            Assert.AreEqual(0, returnedCrewMembers.Count);

            await crewController.AddCrewMemberAsync(crew2.Id, _createdUser1.Entity.Id);

            result = await crewController.GetCrewMembersAsync(crew2.Id);

            returnedCrewMembers = (List <CrewMembersListVm>)((OkObjectResult)result.Result).Value;
            Assert.AreEqual(1, returnedCrewMembers.Count);
            Assert.AreEqual(_createdUser1.Entity.Id, returnedCrewMembers[0].Id);
        }