Exemplo n.º 1
0
            public void AllowModificationWithOutChangeset()
            {
                string batchRequestsDirectory = Path.Combine(TestUtil.ServerUnitTestSamples, @"tests\BatchRequests");

                using (OpenWebDataServiceHelper.EntitySetAccessRule.Restore())
                    using (OpenWebDataServiceHelper.ServiceOperationAccessRule.Restore())
                    {
                        CustomRowBasedContext.PreserveChanges = false;
                        TestUtil.RunCombinations(
                            new string[] { "4.0" },
                            (dataServiceVersion) =>
                        {
                            Type contextType      = typeof(CustomRowBasedContext);
                            string requestContent = File.ReadAllText(Path.Combine(batchRequestsDirectory, "ModificationOutsideChangesetbatch" + ".txt"));

                            string responseFileName = "ModificationOutsideChangesetresponse.txt";

                            responseFileName = Path.Combine(batchRequestsDirectory, responseFileName);
                            using (ChangeScope.GetChangeScope(contextType))
                            {
                                string actualResponse = BatchTestUtil.GetResponse(requestContent, contextType, WebServerLocation.InProcess, dataServiceVersion);
                                BatchTestUtil.CompareBatchResponse(responseFileName, actualResponse);
                            }
                        });
                    }
            }
Exemplo n.º 2
0
            public void SampleBatchTest()
            {
                using (OpenWebDataServiceHelper.EntitySetAccessRule.Restore())
                    using (OpenWebDataServiceHelper.ServiceOperationAccessRule.Restore())
                    {
                        CustomRowBasedContext.PreserveChanges = false;
                        string batchRequestsDirectory = Path.Combine(TestUtil.ServerUnitTestSamples, @"tests\BatchRequests");
                        TestUtil.RunCombinations(
                            Directory.GetFiles(batchRequestsDirectory, "*batch*"),
                            (fileName) =>
                        {
                            string batchRequest     = File.ReadAllText(fileName);
                            string responseFileName = fileName.Replace("batch", "response");

                            string RequestMaxVersion = "4.0";

                            TestUtil.RunCombinations(
                                new Type[] { typeof(CustomDataContext), typeof(CustomRowBasedContext) },
                                (contextType) =>
                            {
                                if (contextType == typeof(CustomRowBasedContext))
                                {
                                    // Hide Region navigation property on the Customer ResponseType to make
                                    // both contexts look identical
                                    OpenWebDataServiceHelper.EntitySetAccessRule.Value = new Dictionary <string, EntitySetRights>()
                                    {
                                        { "Regions", EntitySetRights.None },
                                        { "*", EntitySetRights.All }
                                    };

                                    // Hide service operations returning hidden types.
                                    OpenWebDataServiceHelper.ServiceOperationAccessRule.Value = new Dictionary <string, ServiceOperationRights>()
                                    {
                                        { "GetRegionByName", ServiceOperationRights.None },
                                        { "*", ServiceOperationRights.All }
                                    };
                                }

                                TestUtil.RunCombinations(
                                    new WebServerLocation[] { WebServerLocation.InProcess },
                                    (location) =>
                                {
                                    using (ChangeScope.GetChangeScope(contextType))
                                    {
                                        string actualResponse = BatchTestUtil.GetResponse(batchRequest, contextType, location, RequestMaxVersion);
                                        BatchTestUtil.CompareBatchResponse(responseFileName, actualResponse);
                                    }
                                });
                            });
                        });
                    }
            }
Exemplo n.º 3
0
            public void SampleServiceOperationBatch()
            {
                string batchRequestsDirectory = Path.Combine(TestUtil.ServerUnitTestSamples, @"tests\BatchRequests");

                foreach (string fileName in Directory.GetFiles(batchRequestsDirectory, "*serviceoperationrequest*"))
                {
                    string batchRequest     = File.ReadAllText(fileName);
                    string responseFileName = fileName.Replace("request", "response");

                    using (CustomDataContext.CreateChangeScope())
                    {
                        string actualResponse = BatchTestUtil.GetResponse(batchRequest, typeof(OpenBatchDataService), WebServerLocation.InProcess);
                        BatchTestUtil.CompareBatchResponse(responseFileName, actualResponse);
                    }
                }
            }
Exemplo n.º 4
0
            [Ignore] // Remove Atom
            // [TestCategory("Partition2"), TestMethod, Variation]
            public void UriCompositionRulesChangedOnServer()
            {
                string batchRequestsDirectory = Path.Combine(TestUtil.ServerUnitTestSamples, @"tests\BatchRequests");

                using (OpenWebDataServiceHelper.EntitySetAccessRule.Restore())
                    using (OpenWebDataServiceHelper.ServiceOperationAccessRule.Restore())
                    {
                        CustomRowBasedContext.PreserveChanges = false;
                        TestUtil.RunCombinations(
                            new string[] { "4.0" },
                            UnitTestsUtil.BooleanValues,
                            (dataServiceVersion, insertForwardSlashCharacter) =>
                        {
                            Type contextType      = typeof(CustomRowBasedContext);
                            string requestContent = File.ReadAllText(Path.Combine(batchRequestsDirectory, "UriCompositionReproRequest.txt"));
                            if (insertForwardSlashCharacter)
                            {
                                requestContent = requestContent.Replace("{InsertForwardSlash}", "/");
                            }
                            else
                            {
                                requestContent = requestContent.Replace("{InsertForwardSlash}", string.Empty);
                            }

                            string responseFileName = "UriCompositionSucessResponse.txt";
                            if (insertForwardSlashCharacter)
                            {
                                // if the DSV is set to v3 and the post and bind uris start with a forward slash,
                                // the absolute uris produced by the RequestUriProcessor will be based at a different location.
                                responseFileName = "UriCompositionErrorResponse.txt";
                            }

                            responseFileName = Path.Combine(batchRequestsDirectory, responseFileName);
                            using (ChangeScope.GetChangeScope(contextType))
                            {
                                string actualResponse = BatchTestUtil.GetResponse(requestContent, contextType, WebServerLocation.InProcess, dataServiceVersion);
                                BatchTestUtil.CompareBatchResponse(responseFileName, actualResponse);
                            }
                        });
                    }
            }