Beispiel #1
0
        public void TestPublicAPIWithMultiAccounts()
        {
            isPublicAPILogin = PublicAuthentication.Authenticate(AuthenticationInfoProvider.Current.DefaultAppKey, AuthenticationInfoProvider.Current.DefaultAppSecret);

            Assert.IsTrue(isPublicAPILogin);
            Dictionary <string, object> parameters = new Dictionary <string, object>()
            {
                { "request_type", "1" }
            };
            ReadResponseData <Partition> result = PublicApiAdapter.CreateAdapterForDefaultConnection().ReadSuccess <Partition>(parameters);

            Assert.NotNull(result);
            Assert.NotNull(result.Items);
            Assert.AreEqual(result.Items.Count, 1);
            Assert.AreEqual(result.Items[0].Id, AuthenticationInfoProvider.Current.DefaultPartition);

            isPublicAPILogin = PublicAuthentication.Authenticate(PublicAPIConfig.GetValueFromConfig("AppId2"),
                                                                 PublicAPIConfig.GetValueFromConfig("AppSecret2"));

            Assert.IsTrue(isPublicAPILogin);
            parameters = new Dictionary <string, object>()
            {
                { "request_type", "1" }
            };
            result = PublicApiAdapter.CreateAdapterForDefaultConnection().ReadSuccess <Partition>(parameters);
            Assert.NotNull(result);
            Assert.NotNull(result.Items);
            Assert.AreEqual(result.Items.Count, 1);
            Assert.AreEqual(result.Items[0].Id, PublicAPIConfig.GetValueFromConfig("Partition2"));
        }
Beispiel #2
0
        public void TestReadOptionFullParameters()
        {
            string alias = PublicAPIConfig.GetValueFromConfig("Client_OptionPhase_1");
            Dictionary <string, object> parameters = new Dictionary <string, object>()
            {
                { Parttion, AuthenticationInfoProvider.Current.DefaultPartition },
                { "alias", alias },
                { "enabled", -1 },
                { "count", 5 },
                { "level", -1 }
            };
            ReadResponseData <Option> result = PublicApiAdapter.CreateAdapterForDefaultConnection().ReadSuccess <Option>(parameters);

            Assert.AreEqual(Enums.PublicAPIResultCode.Success, result.Code, string.Format(Enums.Message.READ_RESOURCE_FAILED, "Activity"));

            //Verify existing of XML element
            ResourceHelper.VerifyListContainElement(result.Items, fields.Keys.ToList());

            //Verify the Alias
            foreach (Option option in result.Items)
            {
                Assert.AreEqual(alias, option.Alias, Enums.Message.ALIAS_ERROR);
            }

            //Verify the Count
            Assert.LessOrEqual(result.Items.Count, 5, Enums.Message.COUNT_ERROR);

            //Verify the Level
            Assert.Greater(GetNumberItemByLevel(-1), 0, Enums.Message.LEVEL_ERROR);

            //Verify the type of fields
            ResourceHelper.VerifyTypeOfField(result.Items, fields);
            ResourceHelper.VerifyTypeOfField(ConvertArrayListItemsToOptionList(result.Items), fields);
        }