コード例 #1
0
        public void Create_ReturnsAViewResult()
        {
            //Arange
            var controller = new MedewerkersController(_calculationsService, _unitOfWork.Object, _medewerkerRepository.Object);

            //Act
            var result = controller.Create();

            //Assert
            var viewResult = Assert.IsType <ViewResult>(result);
        }
コード例 #2
0
        public async Task Detail_ReturnsANotFound()
        {
            //Arange
            var controller = new MedewerkersController(_calculationsService, _unitOfWork.Object, _medewerkerRepository.Object);

            //Act
            var result = await controller.Details(null);

            //Assert
            var contentResult = Assert.IsType <NotFoundResult>(result);
        }
コード例 #3
0
        public async Task Index_ReturnsAViewResult_WithAListOfMedewerkerDTOs()
        {
            //Arange
            _medewerkerRepository.Setup(repo => repo.GetAsync()).Returns(Task.FromResult(GetMedewerkers()));
            var controller = new MedewerkersController(_calculationsService, _unitOfWork.Object, _medewerkerRepository.Object);

            //Act
            var result = await controller.Index();

            //Assert
            var viewResult = Assert.IsType <ViewResult>(result);
            var model      = Assert.IsAssignableFrom <IEnumerable <MedewerkerDTO> >(
                viewResult.ViewData.Model);

            Assert.Equal(2, model.Count());
        }
コード例 #4
0
        public async Task Detail_ReturnsAViewResult_WithAMedewerkerDTO()
        {
            //Arange
            int medewerkerID = 1;
            var medewerker   = (GetMedewerkers().FirstOrDefault(m => m.MedewerkerID == medewerkerID));

            _medewerkerRepository.Setup(repo => repo.GetByIdAsync(medewerkerID)).Returns(Task.FromResult(medewerker));

            var controller = new MedewerkersController(_calculationsService, _unitOfWork.Object, _medewerkerRepository.Object);

            //Act
            var result = await controller.Details(1);

            //Assert
            var viewResult = Assert.IsType <ViewResult>(result);
            var model      = Assert.IsType <MedewerkerDTO>(
                viewResult.ViewData.Model);

            Assert.Equal(1, model.MedewerkerID);
            Assert.Equal("Francesca", model.Voornaam);
            Assert.Equal(DateTime.Parse("23-06-1979"), model.Geboortedatum);
        }