Exemplo n.º 1
0
        public async Task ValidationMappingPlane_when_validate_pilot_OK_then_map()
        {
            var      validator = new PlaneDTOValidator();
            PlaneDTO correct   = new PlaneDTO()
            {
                Id        = 1,
                PlaneType = new PlaneTypeDTO()
                {
                    Id = 5, Model = "model"
                }
            };

            PlaneDTO incorrect = new PlaneDTO()
            {
                Id          = 2,
                ReleaseDate = new System.DateTime(2012, 10, 10)
            };

            bool correctRes = validator.Validate(correct).IsValid;

            Assert.True(correctRes);
            var mapped = _mapper.Map <PlaneDTO, Plane>(correct);

            if (correctRes)
            {
                await _service.Post(mapped);
            }

            bool incorrectRes = validator.Validate(incorrect).IsValid;

            Assert.False(incorrectRes);
            var mappedIncorrect = _mapper.Map <PlaneDTO, Plane>(incorrect);

            if (incorrectRes)
            {
                await _service.Post(mapped);
            }
        }