Ejemplo n.º 1
0
        public void ShouldNotGetCrewByIdIfDoesntExist()
        {
            CrewService    crewService    = new CrewService(_dbContext, _mainEventProvider);
            CrewController crewController = new CrewController(crewService);

            var ex = Assert.ThrowsAsync <HttpException>(async() =>
            {
                ActionResult <CrewVm> result = await crewController.GetCrewAsync(123);
            });

            Assert.That(ex.Message == "Fant ikke arbeidslaget med id 123");
        }
Ejemplo n.º 2
0
        public async Task ShouldGetCrewById()
        {
            // Create 2 crews
            await CreateCrew(_crewName2);
            await CreateCrew(_crewName3);

            // Check that we can get both by id
            CrewService    crewService    = new CrewService(_dbContext, _mainEventProvider);
            CrewController crewController = new CrewController(crewService);

            ActionResult <CrewVm> result1 = await crewController.GetCrewAsync(2);

            CrewVm returnedCrew1 = (CrewVm)((OkObjectResult)result1.Result).Value;

            Assert.AreEqual(2, returnedCrew1.CrewId);
            Assert.AreEqual(_crewName2, returnedCrew1.CrewName);

            ActionResult <CrewVm> result2 = await crewController.GetCrewAsync(3);

            CrewVm returnedCrew2 = (CrewVm)((OkObjectResult)result2.Result).Value;

            Assert.AreEqual(3, returnedCrew2.CrewId);
            Assert.AreEqual(_crewName3, returnedCrew2.CrewName);
        }