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

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

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

            _planetValidator.ShouldNotHaveValidationErrorFor(e => e.Terrain, resultMapped.Terrain);
        }
Esempio n. 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)));
        }
Esempio n. 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());
        }