public IHttpActionResult PostAirplaneInfo(AirplaneInfo airplaneInfo)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.AirplaneInfoes.Add(airplaneInfo);

            try
            {
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                if (AirplaneInfoExists(airplaneInfo.AirplaneTypeID, airplaneInfo.ClassID))
                {
                    return(Content(HttpStatusCode.Conflict, "This airplane type already existed in the database!"));
                }
                else
                {
                    while (ex.InnerException != null)
                    {
                        ex = ex.InnerException;
                    }
                    return(Content(HttpStatusCode.InternalServerError, ex.Message));
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = airplaneInfo.AirplaneTypeID }, airplaneInfo));
        }
Exemplo n.º 2
0
        public void AcceptAirplanePlaneGetsRemoved()
        {
            var ooga = new AirplaneInfo();

            ooga.Tag       = "SAS123";
            ooga.X         = 10001;
            ooga.Y         = 30002;
            ooga.Altitude  = 10003;
            ooga.TimeStamp = new DateTime(2019, 01, 01, 01, 01, 01, 111);

            var testList = new List <IAirplaneInfo>();

            testList.Add(ooga);


            _uut.AcceptAirplane(ooga);


            _fDetector.GetConditions().Returns(new List <SeparationCondition>());
            _fAirspace.GetAirplanes().Returns(testList);



            Assert.That(_fAirspace.GetAirplanes().Contains(ooga));
        }
Exemplo n.º 3
0
 public void TestSetUp()
 {
     _fakeTestPlane1 = new AirplaneInfo();
     _fakeTestPlane2 = new AirplaneInfo();
     _fakeData1      = "SAS123;95000;31289;6500;20191101172101543";
     _fakeData2      = "SAS123;94846;31169;6500;20191101172102226";
 }
Exemplo n.º 4
0
        public void AccelerateTest()
        {
            CarInfo      a = null; //new FlyingCar();
            AirplaneInfo b = null; //new FlyingCar();

            a.Accelerate(100);
            b.Accelerate(200);
        }
        public IHttpActionResult GetAirplaneInfo(int airplaneTypeID, int classID)
        {
            AirplaneInfo airplaneInfo = db.AirplaneInfoes
                                        .Where(ai => ai.AirplaneTypeID == airplaneTypeID && ai.ClassID == classID)
                                        .SingleOrDefault();

            if (airplaneInfo == null)
            {
                return(NotFound());
            }

            return(Ok(airplaneInfo));
        }
        public IHttpActionResult DeleteAirplaneInfo(int id)
        {
            AirplaneInfo airplaneInfo = db.AirplaneInfoes.Find(id);

            if (airplaneInfo == null)
            {
                return(NotFound());
            }

            db.AirplaneInfoes.Remove(airplaneInfo);
            db.SaveChanges();

            return(Ok(airplaneInfo));
        }
Exemplo n.º 7
0
        public void OnEventPrintsAirspaces()
        {
            var ooga = new AirplaneInfo();

            ooga.Tag       = "SAS123";
            ooga.X         = 10001;
            ooga.Y         = 10002;
            ooga.Altitude  = 10003;
            ooga.TimeStamp = new DateTime(2019, 01, 01, 01, 01, 01, 111);

            var testList = new List <IAirplaneInfo>();

            testList.Add(ooga);

            _fDetector.GetConditions().Returns(new List <SeparationCondition>());
            _fAirspace.GetAirplanes().Returns(testList);

            _uut.OnEvent(new List <string>());

            _fConsoleLogger.Received().Logs(LOGTYPE.AIRSPACE, Arg.Is <List <string> >(x => x.Count == 1));
        }
        public IHttpActionResult PutAirplaneInfo(int id, AirplaneInfo airplaneInfo)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != airplaneInfo.AirplaneTypeID)
            {
                return(BadRequest());
            }

            db.Entry(airplaneInfo).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                if (!AirplaneInfoExists(airplaneInfo.AirplaneTypeID, airplaneInfo.ClassID))
                {
                    return(NotFound());
                }
                else
                {
                    while (ex.InnerException != null)
                    {
                        ex = ex.InnerException;
                    }
                    return(Content(HttpStatusCode.InternalServerError, ex.Message));
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 9
0
 public static void Accelerate(this AirplaneInfo car, int speed)
 {
     //Accelerate Plane
 }