Ejemplo n.º 1
0
        public void T36CreateDepotSet()
        {
            var api = TestHelper.Authenticate();
            var user = TestHelper.GetOrCreateUser(api);
            var problem = TestHelper.CreateProblem(api, user, "CreateDepotSet");

            //##BEGIN EXAMPLE importdepots##

            var request = new ImportDepotSetRequest
            {
                Items = new List<UpdateDepotRequest>()
            };

            for (int i = 1; i < 4; i++)
            {
                var depot = new UpdateDepotRequest
                {
                    Name = "Depot0"+i,
                    Location = new LocationData { Coordinate = new CoordinateData { Latitude = 0, Longitude = 0, System = "Euclidian" } },
                    Capacities = new List<CapacityData> { new CapacityData { Amount = 10, Name = "weight" }, new CapacityData { Amount = 30, Name = "volume" } },
                    Info1 = "Info",
                    DataSource = "",
                    Type = "SomeType"
                };
                request.Items.Add(depot);
            }

            var response = api.Navigate<ResponseData>(problem.GetLink("import-depots"), request);

            var result = api.Navigate<DepotDataSet>(problem.GetLink("list-depots"));
            //##END EXAMPLE##

            Assert.AreEqual(3, result.Items.Count);
        }
Ejemplo n.º 2
0
        public void T37UpdateDepot()
        {
            var api = TestHelper.Authenticate();
            var user = TestHelper.GetOrCreateUser(api);
            var problem = TestHelper.CreateProblem(api, user, "CreateDepot");
            
            var depot = new UpdateDepotRequest
            {
                Name = "Depot",
                Location = new LocationData { Coordinate = new CoordinateData { Latitude = 0, Longitude = 0, System = "Euclidian" } },
                Capacities = new List<CapacityData> { new CapacityData { Amount = 10, Name = "weight" }, new CapacityData { Amount = 30, Name = "volume" } },
                Info1 = "Info",
                DataSource = "",
                Type = "SomeType"
            };

            var response = api.Navigate<ResponseData>(problem.GetLink("create-depot"), depot);

            //##BEGIN EXAMPLE updatedepot##
            var depotData = api.Navigate<DepotData>(response.Location);

            var update = new UpdateDepotRequest
            {
                Name = depotData.Name,
                Location = depotData.Location,
                Capacities = depotData.Capacities,
                Info1 = "UpdatedInfo",
                DataSource = depotData.DataSource,
                Type = depotData.Type
            };

            response = api.Navigate<ResponseData>(depotData.GetLink("update"), update);
            var updatedDepot = api.Navigate<DepotData>(response.Location);
            //##END EXAMPLE##

            Assert.AreEqual(update.Info1, updatedDepot.Info1);
        }
Ejemplo n.º 3
0
        public void T35CreateDepot()
        {
            var api = TestHelper.Authenticate();
            var user = TestHelper.GetOrCreateUser(api);
            var problem = TestHelper.CreateProblem(api, user, "CreateDepot");
            //##BEGIN EXAMPLE createdepot##
            var depot = new UpdateDepotRequest
            {
                Name = "Depot02",
                Location = new LocationData { Coordinate = new CoordinateData { Latitude = 0, Longitude = 0, System = "Euclidian" } },
                Capacities = new List<CapacityData> { new CapacityData { Amount = 10, Name = "weight" }, new CapacityData { Amount = 30, Name = "volume" } },
                Info1 = "Info",
                DataSource = "",
                Type = "SomeType"
            };

            var response = api.Navigate<ResponseData>(problem.GetLink("create-depot"), depot);

            var depotData = api.Navigate<DepotData>(response.Location);
            //##END EXAMPLE##
            Assert.AreEqual(depot.Name, depotData.Name);

            Assert.AreEqual(JsonConvert.SerializeObject(depot.Location.Coordinate), JsonConvert.SerializeObject(depotData.Location.Coordinate));
            Assert.AreEqual(JsonConvert.SerializeObject(depot.Capacities), JsonConvert.SerializeObject(depotData.Capacities));

        }