Example #1
0
        static void Main(string[] args)
        {
            Uri oDataUri = new Uri(ODataEntityPath, UriKind.Absolute);
            var context  = new Resources(oDataUri);


            context.BuildingRequest += (sender, e) =>
            {
                var uriBuilder = new UriBuilder(e.RequestUri);
                // Requires a reference to System.Web and .NET 4.6.1+
                var paramValues = HttpUtility.ParseQueryString(uriBuilder.Query);
                if (paramValues.GetValues("cross-company") == null)
                {
                    paramValues.Add("cross-company", "true");
                    uriBuilder.Query = paramValues.ToString();
                    e.RequestUri     = uriBuilder.Uri;
                }
            };


            context.SendingRequest2 += new EventHandler <SendingRequest2EventArgs>(delegate(object sender, SendingRequest2EventArgs e)
            {
                var authenticationHeader = OAuthHelper.GetAuthenticationHeader(useWebAppAuthentication: true);
                e.RequestMessage.SetHeader(OAuthHelper.OAuthHeader, authenticationHeader);
            });

            StreamWriter stream = File.CreateText(filePath);

            stream.WriteLine("Entity, TestType, Workload, Duration");
            stream.Flush();
            stream.Close();

            Console.WriteLine("Connected To " + ClientConfiguration.Default.UriString);

            SalesValues values;

            int loopCount = 100;

            Stopwatch sw = new Stopwatch();

            values = SalesOrderHeaderV2Tester.getRandomCombination();

            for (int i = 0; i < loopCount; i++)
            {
                SalesOrderHeaderV2Tester.createAndDeleteWithSimpleEntity(context, filePath, SalesOrderTester.TestType.Repetitive, SalesOrderTester.TestWorkload.DeleteSimple, "USMF", "US-010");
            }

            for (int i = 0; i < loopCount; i++)
            {
                SalesOrderHeaderV2Tester.createAndDeleteWithCompoundEntity(context, filePath, SalesOrderTester.TestType.Repetitive, SalesOrderTester.TestWorkload.DeleteCompound, "USMF", "US-010");
            }

            for (int i = 0; i < loopCount; i++)
            {
                SalesOrderHeaderV2Tester.createAndDeleteWithSingleEntity(context, filePath, SalesOrderTester.TestType.Repetitive, SalesOrderTester.TestWorkload.DeleteSingle, "USMF", "US-010");
            }

            Console.WriteLine("Complete. Press enter.");
            Console.ReadLine();
        }