public void API_GetSortedResult_SortParametersNotProvided_ReturnsNotImplementedException()
        {
            //We create an instance of this class because we need to authenticate ourselves before requesting any data
            IndicativeExchangeRates.Host.ExchangeRateAPI era = new Host.ExchangeRateAPI("muratyasar", "denemetry!4");

            var result = era.GetSortedData(null).Result;
        }
        public void API_GetFilteredResult_SortParametersAndOutputTypeProvided_ReturnsListOfObject()
        {
            //We create an instance of this class because we need to authenticate ourselves before requesting any data
            IndicativeExchangeRates.Host.ExchangeRateAPI era = new Host.ExchangeRateAPI("muratyasar", "denemetry!4");
            era.RequestedOutput = "OutputXML";

            List <ExpressionSort> sorts = new List <ExpressionSort>
            {
                new ExpressionSort
                {
                    PropertyName  = FilterSort.Enums.FilterColumNames.CurrencyCode,
                    SortDirection = FilterSort.Enums.SortDirection.Ascending
                },
                new ExpressionSort
                {
                    PropertyName  = FilterSort.Enums.FilterColumNames.ForexBuying,
                    SortDirection = FilterSort.Enums.SortDirection.Descending
                },
            };

            var result = era.GetSortedData(sorts).Result;

            Assert.IsNotNull(result, "Every compulsory parameter provided but we could't get sorted data result.");
            Assert.IsTrue(!string.IsNullOrEmpty(result.ToString()), "Every compulsory parameter provided but we could't get sorted data result.");
        }
        public void API_GetSortedResult_SortParametersProvided_ReturnsNotImplementedException()
        {
            //We create an instance of this class because we need to authenticate ourselves before requesting any data
            IndicativeExchangeRates.Host.ExchangeRateAPI era = new Host.ExchangeRateAPI("muratyasar", "denemetry!4");

            List <ExpressionSort> sorts = new List <ExpressionSort>
            {
                new ExpressionSort
                {
                    PropertyName  = FilterSort.Enums.FilterColumNames.CurrencyCode,
                    SortDirection = FilterSort.Enums.SortDirection.Ascending
                },
                new ExpressionSort
                {
                    PropertyName  = FilterSort.Enums.FilterColumNames.ForexBuying,
                    SortDirection = FilterSort.Enums.SortDirection.Descending
                },
            };

            var result = era.GetSortedData(sorts).Result;
        }
Ejemplo n.º 4
0
        private async void ButtonClick(string outputtype)
        {
            textboxAllData.Text             = string.Empty;
            labelAllData.Text               = string.Empty;
            labelFilteredData.Text          = string.Empty;
            labelSortedData.Text            = string.Empty;
            labelFilteredAndSortedData.Text = string.Empty;
            panel2.BackColor = SystemColors.Control;

            switch (outputtype)
            {
            case "OutputXML":
                era.RequestedOutput = "OutputXML";
                break;

            case "OutputCSV":
                era.RequestedOutput = "OutputCSV";
                break;

            case "OutputJSON":
                era.RequestedOutput = "OutputJSON";
                break;
            }

            System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
            stopwatch.Start();

            List <ExpressionFilter> filters = new List <ExpressionFilter>
            {
                new ExpressionFilter
                {
                    PropertyName    = FilterSort.Enums.FilterColumNames.CurrencyCode,
                    Value           = "USD",
                    Comparison      = FilterSort.Enums.Comparison.Equal,
                    LogicalOperator = FilterSort.Enums.LogicalOperation.Or
                },
                new ExpressionFilter
                {
                    PropertyName    = FilterSort.Enums.FilterColumNames.CurrencyCode,
                    Value           = "EUR",
                    Comparison      = FilterSort.Enums.Comparison.Equal,
                    LogicalOperator = FilterSort.Enums.LogicalOperation.Or
                }
            };

            List <ExpressionSort> sorts = new List <ExpressionSort>
            {
                new ExpressionSort
                {
                    PropertyName  = FilterSort.Enums.FilterColumNames.CurrencyCode,
                    SortDirection = FilterSort.Enums.SortDirection.Ascending
                },
                new ExpressionSort
                {
                    PropertyName  = FilterSort.Enums.FilterColumNames.ForexBuying,
                    SortDirection = FilterSort.Enums.SortDirection.Descending
                },
            };

            var resAllData = await era.GetAllData();

            stopwatch.Stop();
            labelAllData.Text = "GetAllData took " + stopwatch.ElapsedMilliseconds.ToString() + " ms";

            stopwatch.Reset();
            stopwatch.Start();
            var resFilteredData = await era.GetFilteredData(filters);

            stopwatch.Stop();
            labelFilteredData.Text = "GetFilteredData took " + stopwatch.ElapsedMilliseconds.ToString() + " ms";

            stopwatch.Reset();
            stopwatch.Start();
            var resSortedData = await era.GetSortedData(sorts);

            stopwatch.Stop();
            labelSortedData.Text = "GetSortedData took " + stopwatch.ElapsedMilliseconds.ToString() + " ms";

            stopwatch.Reset();
            stopwatch.Start();
            var resFilteredAndSortedData = await era.GetFilteredAndSortedData(filters, sorts);

            stopwatch.Stop();
            labelFilteredAndSortedData.Text = "FilteredAndSorted took " + stopwatch.ElapsedMilliseconds.ToString() + " ms";

            textboxAllData.Text =
                "-----All Data-----" +
                System.Environment.NewLine + System.Environment.NewLine +
                resAllData.ToString();
            textboxFilteredData.Text =
                "-----Filtered Data-----" +
                System.Environment.NewLine + System.Environment.NewLine +
                resFilteredData.ToString();
            textboxSortedData.Text =
                "-----Sorted Data-----" +
                System.Environment.NewLine + System.Environment.NewLine +
                resSortedData.ToString();
            textboxFilteredAndSortedData.Text =
                "-----Filtered And Sorted Data-----" +
                System.Environment.NewLine + System.Environment.NewLine +
                resFilteredAndSortedData.ToString();

            panel2.BackColor = Color.Khaki;
        }