Example #1
0
        private static void TestRestStopUpdate(ResourceVerification verification, string httpMethod, string preferHeader, bool useBatch, DSPMetadata roadTripMetadata)
        {
            var restStop = SpatialTestUtil.CreateRestStopResource(
                roadTripMetadata,
                verification.Id,
                verification.PropertyValues.RestStopGeography,
                useComplexType: false,
                modifyPropertyValues: null);

            ExecuteUpdate(restStop, verification.Id, verification.Request, httpMethod, preferHeader, useBatch, verification.PayloadFormat);

            // Verify that the operation was successful by querying the same data again
            verification.GetAndVerifyRestStop();
        }
Example #2
0
        public void SerializeGeodeticPropertiesInResource()
        {
            var testCases = new[]
            {
                new
                {
                    GeographyType = typeof(GeographyPoint),
                    DefaultValues = TestPoint.DefaultValues
                },
                new
                {
                    GeographyType = typeof(GeographyLineString),
                    DefaultValues = TestLineString.DefaultValues
                },
            };

            var responseFromats = new string[] { UnitTestsUtil.AtomFormat };

            TestUtil.RunCombinations(testCases, responseFromats, (testCase, responseFormat) =>
            {
                GeographyPropertyValues defaultValues = testCase.DefaultValues;

                DSPUnitTestServiceDefinition roadTripServiceDefinition = GetRoadTripServiceDefinition(testCase.GeographyType, defaultValues);
                using (TestWebRequest request = roadTripServiceDefinition.CreateForInProcess())
                {
                    request.StartService();
                    request.Accept = responseFormat;

                    ResourceVerification verification = GetResourceVerification(responseFormat, SpatialTestUtil.DefaultId, defaultValues, request);

                    // Geography property followed by another geography property
                    verification.GetAndVerifyTripLeg();

                    // Geography property followed by another non-geography property
                    verification.GetAndVerifyAmusementPark();

                    // Geography property at the end of the entry
                    verification.GetAndVerifyRestStop();
                }
            });
        }
Example #3
0
        private static void TestRestStopUpdate(ResourceVerification verification, string httpMethod, string preferHeader, bool useBatch, DSPMetadata roadTripMetadata)
        {
            var restStop = SpatialTestUtil.CreateRestStopResource(
                roadTripMetadata,
                verification.Id,
                verification.PropertyValues.RestStopGeography,
                useComplexType: false,
                modifyPropertyValues: null);

            ExecuteUpdate(restStop, verification.Id, verification.Request, httpMethod, preferHeader, useBatch, verification.PayloadFormat);

            // Verify that the operation was successful by querying the same data again
            verification.GetAndVerifyRestStop();
        }
Example #4
0
        public void InsertAndUpdateGeodeticProperties()
        {
            var testCases = new[]
            {
                new
                {
                    GeographyType = typeof(Geography),
                    DefaultValues = TestLineString.DefaultValues,
                    NewValues     = TestLineString.NewValues,
                },
                new
                {
                    GeographyType = typeof(GeographyPoint),
                    DefaultValues = TestPoint.DefaultValues,
                    NewValues     = TestPoint.NewValues,
                },
                new
                {
                    GeographyType = typeof(GeographyLineString),
                    DefaultValues = TestLineString.DefaultValues,
                    NewValues     = TestLineString.NewValues,
                },
            };

            TestUtil.RunCombinations(testCases, UnitTestsUtil.BooleanValues, UnitTestsUtil.ResponseFormats, (testCase, enableTypeConversion, payloadFormat) =>
            {
                GeographyPropertyValues defaultValues = testCase.DefaultValues;
                bool useComplexType = false;
                DSPUnitTestServiceDefinition roadTripServiceDefinition = GetRoadTripServiceDefinition(testCase.GeographyType, defaultValues, useComplexType);

                // EnableTypeConversion is interesting here because it affects whether or not we pay attention to the type that's specified on the wire, instead of metadata
                // Since spatial types can specify Geography in metadata but GeographyPoint as the value, we need to verify it works either way
                roadTripServiceDefinition.EnableTypeConversion = enableTypeConversion;

                using (TestWebRequest request = roadTripServiceDefinition.CreateForInProcess())
                {
                    request.StartService();

                    TestUtil.RunCombinations(
                        new string[] { "POST", "PUT", "PATCH", "PATCH" },
                        new string[] { null, "return=representation", "return=minimal" },
                        UnitTestsUtil.BooleanValues,
                        (httpMethod, preferHeader, useBatch) =>
                    {
                        bool isPost = httpMethod == "POST";
                        bool expectedReturnContent = preferHeader == "return=representation" || isPost && preferHeader == null;

                        DSPMetadata roadTripMetadata = roadTripServiceDefinition.Metadata;
                        DSPContext changeScopeData   = SpatialTestUtil.PopulateRoadTripData(roadTripMetadata, defaultValues, useComplexType);
                        using (IDisposable changeScope = roadTripServiceDefinition.CreateChangeScope(changeScopeData))
                        {
                            int id = isPost ? 2 : SpatialTestUtil.DefaultId;

                            ResourceVerification verification = GetResourceVerification(payloadFormat, id, testCase.NewValues, request);

                            TestTripLegUpdate(verification, httpMethod, preferHeader, useBatch, roadTripMetadata);
                            TestAmusementParkUpdate(verification, httpMethod, preferHeader, useBatch, roadTripMetadata);
                            TestRestStopUpdate(verification, httpMethod, preferHeader, useBatch, roadTripMetadata);
                        }
                    });
                }
            });
        }