Пример #1
0
        public async Task ValidationMappingPlaneType_when_validate_pilot_OK_then_map()
        {
            var          validator = new PlaneTypeDTOValidator();
            PlaneTypeDTO correct   = new PlaneTypeDTO()
            {
                Id    = 1,
                Model = "Model"
            };

            PlaneTypeDTO incorrect = new PlaneTypeDTO()
            {
                Id            = 2,
                NumberOfSeats = 25
            };

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

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

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

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

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

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