Esempio n. 1
0
        public async void GetAirplane_IdDoesExist_ShouldSucceed()
        {
            SetUpMocksAndServices();
            _aircraftRepositoryMock.Read(validId).Returns(new Airplane());
            var result = await _aircraftService.FindById(validId);

            Assert.True(result.Success);
        }
Esempio n. 2
0
        public async Task <AircraftResponseObject <T> > FindById(int id)
        {
            try
            {
                var aircraft = await _aircraftRepository.Read(id);

                if (aircraft == null)
                {
                    return(new AircraftResponseObject <T>($"No aircraft found with id:  {id}"));
                }
                return(new AircraftResponseObject <T>(aircraft));
            }
            catch (Exception e)
            {
                return(new AircraftResponseObject <T>($"The following error occured when locating the aircraft: {e.Message}"));
            }
        }