コード例 #1
0
        public void TestTopDashboardValid(DashboardHelpers.TimePeriod timePeriod)
        {
            var handler = new DashboardManager();

            CreatePeriodSetting(timePeriod.ToString());
            var response = handler.SendTopDashboard <TopDashboardDataResponse>(HttpMethod.Get);

            PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK));

            //Verify data here
            VerifyData(response, timePeriod.ToString());
        }
コード例 #2
0
        private void VerifyData(DashboardHelpers.Options option, Owners owner, DashboardHelpers.SearchOwners searchOwner, DashboardHelpers.TimePeriod timePeriod, DashboardHelpers.Types type)
        {
            var handler = new DashboardSettingManager();
            var request = new Dictionary <string, string>
            {
                ["resource"] = searchOwner == DashboardHelpers.SearchOwners.Array || searchOwner == DashboardHelpers.SearchOwners.Random
                                              ? SearchOwnerValues[searchOwner]().First().ToString() : DashboardHelpers.Resources[searchOwner].ToString(),
                ["type"] = type.ToString().ToLower()
            };

            List <int> optionList = new List <int>();

            if (option == DashboardHelpers.Options.Array)
            {
                optionList = DashboardHelpers.OptionValues.Select(item => item.Value).ToList();
            }
            else
            if (option == DashboardHelpers.Options.Random)
            {
                optionList = RandOptionList;
            }
            else
            {
                optionList = new List <int> {
                    DashboardHelpers.OptionValues[option]
                };
            }

            var response = handler.GetDashboardSetting <DashboardSettingResponse>(request, HttpMethod.Get);

            PrAssume.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK));
            PrAssume.That(response.Result, PrIs.Not.Null.Or.Not.Empty);
            PrAssert.That(response.Result.Settings.Options, PrIs.Not.Null.And.EqualTo(optionList));
            PrAssert.That(response.Result.Settings.Owners.Agents, PrIs.Not.Null.And.EqualTo(OwnerValues[owner]()));
            PrAssert.That(response.Result.Settings.Owners.Depts, PrIs.Null.Or.Empty);
            PrAssert.That(response.Result.Settings.SearchOwners, PrIs.Not.Null.And.EqualTo(SearchOwnerValues[searchOwner]()));
            PrAssert.That(response.Result.Settings.TimePeriod.Type, PrIs.Not.Null.And.EqualTo(timePeriod.ToString()));
        }
コード例 #3
0
        public void TestDashboardRegistrationValid(DashboardHelpers.Options option, Owners owner, DashboardHelpers.SearchOwners searchOwner, DashboardHelpers.TimePeriod timePeriod, DashboardHelpers.Types type)
        {
            var handler = new DashboardManager(DashboardHelpers.DashboardRegistrationEndPoint);
            var request = GetRequestDashboardRegistrationValid(option, owner, searchOwner, timePeriod, type);

            var response = handler.SendDashboard <object>(request, HttpMethod.Put);

            PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.NoContent));
            PrAssert.That(response.Result, PrIs.Null.Or.Empty);

            //Verify data
            VerifyData(option, owner, searchOwner, timePeriod, type);
        }
コード例 #4
0
        private Dictionary <string, object> GetRequestDashboardRegistrationValid(DashboardHelpers.Options option, Owners owner, DashboardHelpers.SearchOwners searchOwner, DashboardHelpers.TimePeriod timePeriod, DashboardHelpers.Types type)
        {
            var originalRequest = new Dictionary <string, object>(DashboardHelpers.DashboardRegistrationDefaultParameters(UserIds));
            var request         = originalRequest["settings"] as Dictionary <string, object>;

            if (option == DashboardHelpers.Options.Array)
            {
                request["options"] = DashboardHelpers.OptionValues.Select(item => item.Value).ToList();
            }
            else
            if (option == DashboardHelpers.Options.Random)
            {
                request["options"] = RandOptionList;
            }
            else
            {
                request["options"] = new List <int> {
                    DashboardHelpers.OptionValues[option]
                };
            }

            request["owners"] = new Dictionary <string, List <int> >
            {
                ["agents"] = OwnerValues[owner](),
                ["depts"]  = new List <int>()
            };
            request["searchOwners"] = SearchOwnerValues[searchOwner]();
            request["timePeriod"]   = new Dictionary <string, string>
            {
                ["type"] = timePeriod.ToString()
            };
            originalRequest["type"]     = type.ToString().ToLower();
            originalRequest["settings"] = request;
            return(originalRequest);
        }