Exemplo n.º 1
0
        public void EntitySetDeclaredInReferencedModelE2E()
        {
            // Query Entity Set in GPS
            TestClientContext.MergeOption = MergeOption.OverwriteChanges;
            var vehicleGPSSetInGPS = TestClientContext.VehicleGPSSetInGPS;

            foreach (var vehicleGPS in vehicleGPSSetInGPS)
            {
                Assert.IsTrue(vehicleGPS != null);
            }
            Assert.AreEqual(3, vehicleGPSSetInGPS.Count());

            // Create an entity in VehicleGPSSetInGPS
            var newVehicleGPS = new VehicleGPSType()
            {
                Key           = "101",
                VehicleSpeed  = 100.1,
                StartLocation = new GeoLocation()
                {
                    Lat  = 1,
                    Long = 2,
                },
                EndLocation = new GeoLocation()
                {
                    Lat  = 3,
                    Long = 4,
                },
                CurrentLocation = new GeoLocation()
                {
                    Lat  = 1.2,
                    Long = 2.4,
                },
                LostSignalAlarm = new GPSLostSignalAlarmType()
                {
                    Severity          = 1,
                    LastKnownLocation = new GeoLocation()
                    {
                        Lat  = 2.1,
                        Long = 1.2,
                    }
                },
                Map = new MapType()
                {
                    MBytesDownloaded = 1.2,
                    ProviderName     = "TESTNEW",
                    Uri = "TESTNEW.TEST",
                }
            };

            TestClientContext.AddToVehicleGPSSetInGPS(newVehicleGPS);
            TestClientContext.SaveChanges();

            // Get the created entity
            var            queryable  = TestClientContext.VehicleGPSSetInGPS.Where(vehicleGPS => vehicleGPS.Key == "101");
            VehicleGPSType newCreated = queryable.Single();

            Assert.AreEqual(100.1, newCreated.VehicleSpeed);

            // Update the created entity
            newCreated.VehicleSpeed = 200.1;
            TestClientContext.UpdateObject(newCreated);
            TestClientContext.SaveChanges();

            // Query and Delete entity
            VehicleGPSType updated = queryable.Single();

            Assert.AreEqual(200.1, newCreated.VehicleSpeed);

            TestClientContext.DeleteObject(updated);
            TestClientContext.SaveChanges();
            Assert.AreEqual(3, vehicleGPSSetInGPS.Count());
        }
 public double GetVehicleSpeed(VehicleGPSType targetVehicleGPS)
 {
     return(targetVehicleGPS.VehicleSpeed);
 }
Exemplo n.º 3
0
        public void AddNavigationProperty()
        {
            TestClientContext.MergeOption = MergeOption.OverwriteChanges;
            var truck = (TestClientContext.Trucks.Where(t => t.Key == "Key1")).Single();

            // Add Navigation Property to VehicleGPS in TruckType
            var newVehicleGPS = new VehicleGPSType()
            {
                Key           = "99",
                VehicleSpeed  = 100.1,
                StartLocation = new GeoLocation()
                {
                    Lat  = 1,
                    Long = 2,
                },
                EndLocation = new GeoLocation()
                {
                    Lat  = 3,
                    Long = 4,
                },
                CurrentLocation = new GeoLocation()
                {
                    Lat  = 1.2,
                    Long = 2.4,
                },
                LostSignalAlarm = new GPSLostSignalAlarmType()
                {
                    Severity          = 1,
                    LastKnownLocation = new GeoLocation()
                    {
                        Lat  = 2.1,
                        Long = 1.2,
                    }
                },
                Map = new MapType()
                {
                    MBytesDownloaded = 1.2,
                    ProviderName     = "TESTNEW",
                    Uri = "TESTNEW.TEST",
                }
            };

            TestClientContext.AddRelatedObject(truck, "VehicleGPSGroup", newVehicleGPS);
            TestClientContext.SaveChanges();

            TestClientContext.LoadProperty(truck, "VehicleGPSGroup");
            Assert.AreEqual(2, truck.VehicleGPSGroup.Count);

            // Add Navigation Property to VehicleGPSGroupFromGPS in TruckType
            var newVehicleGPSInGPS = new VehicleGPSType()
            {
                Key           = "102",
                VehicleSpeed  = 100.1,
                StartLocation = new GeoLocation()
                {
                    Lat  = 1,
                    Long = 2,
                },
                EndLocation = new GeoLocation()
                {
                    Lat  = 3,
                    Long = 4,
                },
                CurrentLocation = new GeoLocation()
                {
                    Lat  = 1.2,
                    Long = 2.4,
                },
                LostSignalAlarm = new GPSLostSignalAlarmType()
                {
                    Severity          = 1,
                    LastKnownLocation = new GeoLocation()
                    {
                        Lat  = 2.1,
                        Long = 1.2,
                    }
                },
                Map = new MapType()
                {
                    MBytesDownloaded = 1.2,
                    ProviderName     = "TESTNEW",
                    Uri = "TESTNEW.TEST",
                }
            };

            TestClientContext.AddRelatedObject(truck, "VehicleGPSGroupFromGPS", newVehicleGPSInGPS);
            TestClientContext.SaveChanges();

            TestClientContext.LoadProperty(truck, "VehicleGPSGroupFromGPS");
            Assert.AreEqual(2, truck.VehicleGPSGroupFromGPS.Count);
        }
 public void ResetVehicleSpeed(VehicleGPSType targetVehicleGPS, double targetValue)
 {
     targetVehicleGPS.VehicleSpeed = targetValue;
 }