Beispiel #1
0
        public async Task ValidationMappingFlight_when_validate_pilot_OK_then_map()
        {
            var       validator = new FlightDTOValidator();
            FlightDTO correct   = new FlightDTO()
            {
                Number        = 1,
                Destination   = "dest",
                DepartureFrom = "depFrom"
            };

            FlightDTO incorrect = new FlightDTO()
            {
                Number          = 2,
                TimeOfDeparture = new System.DateTime(2018, 10, 10),
                Destination     = "dest"
            };

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

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

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

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

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

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