예제 #1
0
        public void ShouldReturnValidationErrorForClimate()
        {
            var planet       = StarWarsMockCore.GetPlanetFail();
            var resultMapped = _mapper.Map <Planet>(planet);

            _planetValidator.ShouldHaveValidationErrorFor(e => e.Climate, resultMapped.Climate);
        }
예제 #2
0
        public void ShoulReturnErrorForNoId()
        {
            var planet       = StarWarsMockCore.GetPlanetFail();
            var resultMapped = _mapper.Map <Planet>(planet);

            _planetValidator.ShouldHaveValidationErrorFor(e => e.Id, resultMapped.Id);
        }
예제 #3
0
        public void ShouldReturnNoValidationErrorForTerrain()
        {
            var planet       = StarWarsMockCore.GetPlanetOK();
            var resultMapped = _mapper.Map <Planet>(planet);

            _planetValidator.ShouldNotHaveValidationErrorFor(e => e.Terrain, resultMapped.Terrain);
        }
예제 #4
0
        public void ShoudReturnNoErrorForAutoMapperDomainToViewModel()
        {
            var planet       = StarWarsMockCore.GetPlanetDomain();
            var resultMapped = _mapper.Map <PlanetViewModel>(planet);
            var type         = resultMapped.GetType();

            Assert.True(type.Equals(typeof(PlanetViewModel)));
        }
예제 #5
0
        public async Task ShoudReturn4Planets()
        {
            //Arrange
            var mockRepo = new Mock <IPlanetApplicationService>();

            mockRepo.Setup(repo => repo.GetAllPlanets()).ReturnsAsync(StarWarsMockCore.GetAllPlanets());
            var controller = new PlanetsController(mockRepo.Object, _mapper);

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

            //Assert
            var objectResult = Assert.IsType <ObjectResult>(result);
            var model        = Assert.IsAssignableFrom <List <PlanetViewModel> >(objectResult.Value);

            Assert.Equal(4, model.Count());
        }