示例#1
0
        public async Task Test_Get_EU_AuctionDataAsync()
        {
            var client         = new ApiClientAsync(Region.EU, Locale.en_GB, TestConstants.ApiKey);
            var getAuctionFile = await client.GetAuctionFileAsync(TestConstants.EU_en_GB_Realm);

            var someCachedValue = "14218549882000";

            var lm = from f in getAuctionFile.Files
                     select f.LastModified;

            if (!lm.Equals(someCachedValue))
            {
                var getAuction = await client.GetAuctionsAsync(TestConstants.EU_en_GB_Realm);

                var auction = getAuction.Auctions;

                string owner = "";
                using (auction.GetEnumerator())
                {
                    Parallel.ForEach(auction.Take(51), a =>
                    {
                        Assert.IsNotNull(a.Auc);
                        Assert.IsNotNull(a.Bid);
                        Assert.IsNotNull(a.Buyout);
                        Assert.IsNotNull(a.Context);
                        Assert.IsNotNull(a.Item);
                        owner = a.Owner;

                        Console.WriteLine(a.BidGold);
                        Console.WriteLine(a.BidSilver);
                        Console.WriteLine(a.BidCopper);
                    });
                }
            }
        }
示例#2
0
        public void SubmitAdRequestsAsync()
        {
            var mockery     = new MockRepository();
            var taskFactory = mockery.StrictMock <IVistarTaskFactory>();
            var adRequestor = mockery.StrictMock <IAdRequestor>();

            var adRequests = new List <AdRequest> {
                new AdRequest(),
                new AdRequest(),
                new AdRequest()
            };

            var expectedTasks = new List <Task <List <Advertisement> > > {
                new Task <List <Advertisement> >(null),
                new Task <List <Advertisement> >(null),
                new Task <List <Advertisement> >(null)
            };

            using (mockery.Record()) {
                Expect.Call(taskFactory.StartNew(adRequestor.RunSubmitAdRequest, adRequests[0])).Return(expectedTasks[0]);
                Expect.Call(taskFactory.StartNew(adRequestor.RunSubmitAdRequest, adRequests[1])).Return(expectedTasks[1]);
                Expect.Call(taskFactory.StartNew(adRequestor.RunSubmitAdRequest, adRequests[2])).Return(expectedTasks[2]);
            }

            using (mockery.Playback()) {
                var client = new ApiClientAsync(adRequestor, taskFactory);
                var tasks  = client.SubmitAdRequestsAsync(adRequests);
                Assert.AreEqual(expectedTasks, tasks);
            }
        }
示例#3
0
        public async Task <string> ApiDemo()
        {
            ApiClientAsync CheckoutClient;

            try
            {
                CheckoutConfiguration configuration = new CheckoutConfiguration()
                {
                    SecretKey = Environment.GetEnvironmentVariable("CKO_SECRET_KEY"),
                    DebugMode = true
                };

                CheckoutClient = new ApiClientAsync(configuration);

                CardTokenCharge cardTokenCharge = new CardTokenCharge()
                {
                    CardToken = Order.CardToken,
                    Currency  = Order.Currency,
                    Value     = (Order.Total * 100).ToString(),
                    Email     = Order.Cust.Email
                };
                HttpResponse <Charge> response = await CheckoutClient.ChargeServiceAsync.ChargeWithCardTokenAsync(cardTokenCharge);

                Charge charge = response.Model;
                return(charge.ResponseCode);
            }
            catch (Exception e)
            {
                Debug.WriteLine($"There was an exception: {e}");
                return("exception");
            }
        }
示例#4
0
        public async Task Test_CharacterRoot_Everything_EU_async()
        {
            var client = new ApiClientAsync(Region.EU, Locale.en_GB, TestConstants.ApiKey);

            var character = await client.GetCharacterAsync("hjortronsmak", CharacterOptions.AllOptions, TestConstants.EU_en_GB_Realm);

            Assert.IsTrue(character.TotalHonorableKills > 0);
            Assert.IsNotNull(character.Pvp.Brackets.ArenaBracket2v2.Rating);
            Assert.IsNotNull(character.AchievementPoints);
            Assert.IsNotNull(character.Achievements);
            Assert.IsNotNull(character.Appearance);
            Assert.IsNotNull(character.Battlegroup);
            Assert.IsNotNull(character.CalcClass);
            Assert.IsNotNull(character.Feed);
            Assert.IsNotNull(character.Guild);
            Assert.IsNotNull(character.Level);

            foreach (var raid in character.Progression.Raids)
            {
                var boss = from b in raid.Bosses
                           select b.Id;

                Assert.IsNotNull(boss);
            }

            Assert.AreEqual(CharacterClass.Priest, character.Class);

            Assert.AreEqual(CharacterRace.Pandaren_Alliance, character.Race);

            Console.WriteLine("Class: " + character.Class);
            Console.WriteLine("Race: " + character.Race);
            Console.WriteLine("Gender: " + character.Gender);
        }
示例#5
0
        //requires new guild to test against [TestMethod]
        public async Task Test_GetCharacter_FromGuildMembers()
        {
            var client = new ApiClientAsync(Region.EU, Locale.en_GB, TestConstants.ApiKey);
            //realm in getGuildAsync does not work (404 not found), why? setting realm in apiclient constructor works.
            var guild = await client.GetGuildAsync("method", GuildOptions.Members, "Twisting Nether");

            Assert.IsNotNull(guild);

            Stopwatch s1 = new Stopwatch();

            s1.Start();
            int iteration = 0;
            var charc     = await
                            client.GetCharactersInGuildAsync(guild.Members, CharacterOptions.AllOptions, 100, 60);

            foreach (var c in charc)
            {
                iteration++;

                Console.WriteLine("Iteration Nr: " + iteration + " ------------------------------");
                Console.WriteLine("Name: " + c.Name
                                  + "\nAchivement points: " + c.AchievementPoints
                                  + "\nLevel: " + c.Level);
                Console.WriteLine("----------------------------------------------");
            }

            Console.WriteLine("Asynchronous time: " + s1.Elapsed.TotalSeconds + " sec");
            s1.Stop();
        }
示例#6
0
        public async Task Test_EU_Recipe_By_Id()
        {
            client2 = new ApiClientAsync(Region.EU, Locale.en_GB, TestConstants.ApiKey);

            var recipe = await client2.GetRecipeAsync(33994);

            var item = await client2.GetItemAsync("115542");

            Assert.IsNotNull(recipe.Id);
            Assert.IsNotNull(item.Id);
        }
示例#7
0
        public async Task Test_US_GetAuctionData()
        {
            var client   = new ApiClientAsync(Region.US, Locale.en_US, TestConstants.ApiKey);
            var auctions = await client.GetAuctionsAsync(TestConstants.US_en_US_Realm);

            Assert.IsNotNull(auctions);

            Parallel.ForEach(auctions.Auctions.Take(150), auction =>
            {
                Assert.IsNotNull(auction.Auc);
                Assert.IsNotNull(auction.Bid);
                Assert.IsNotNull(auction.Buyout);
                Assert.IsNotNull(auction.Context);
                Assert.IsNotNull(auction.Item);
            });
        }
示例#8
0
        //needs new guild, this is  moved/inactive or something [TestMethod]
        public async Task Test_GetCharacters_FromGuildMembersHashSet()
        {
            var client = new ApiClientAsync(Region.EU, Locale.en_GB, TestConstants.ApiKey, "Twisting Nether");

            //var guild = await client.GetGuildAsync("dress code purple", GuildOptions.Members);

            //var client = new ApiClientAsync(_Region.EU, _Locale.en_GB, TestConstants.ApiKey, "grim batol");
            //var guild = await client.GetGuildAsync("dress code purple", GuildOptions.Members);


            string[] dcp = { "Miizumi",      "Athènâ",      "Basiun",       "Xploz",        "Snoogypoo",   "Mizlol",
                             "Duridpls",     "Pórtello",    "Hjortronsmak", "Hjortronsylt", "Lingonberry",
                             "Nekja",        "Schweinhynd", "Restaurante",  "ßäcon",        "Lindelof",    "Meekz",
                             "Fantasmak",    "Tyiriel",     "Cermonia",     "Aarturius",    "Cazsi",       "Risrina",
                             "Swegirl",      "Kikhosta",    "Drunco",       "Kradashian",   "Smiskamig",   "Jensnn",
                             "Góranpersson", "Bluebearý",   "Lilgitler",    "Galavien",     "Dakniel",     "Tacoslam",
                             "Burritoheal",  "Forrko",      "Xzy",          "Tinuvíel",     "Amida",       "Saltmustasch","Catchlife",
                             "Skeyro",       "Creak",       "Vulkyra",      "Quirk",        "Funkalistic", "Kappabobqt",  "Pinglan",
                             "Turbotomte",   "Ourqt",       "Elementpimp",  "Ostpajen",     "Skalta",      "Bearmister",  "Tturbotomte",
                             "Spaceshipman", "Turbotanten", "Siljaline",    "Littlewing",   "Siljaa",      "Höken",
                             "Tturbotanten", "Missgutt",    "Zeachi",       "Hartis",       };



            string[] method = { "Aris",        "Maleficarium", "Isheriia",     "Rogeritsa",    "Rogerakos",    "Saabok",
                                "Faerko",      "Justtwo",      "Justnita",     "Justpaladin",  "Kuzfour",      "Zammy",
                                "Nxe",         "Noxe",         "Monstermunch", "Magulina",     "Pactjesaurus", "Blattardos",
                                "Blattard",    "Masouka",      "Gaiã",         "Lambroukos",   "Warcried",     "Justsham",
                                "Blattos",     "Isheria",      "Bellise",      "Razielakooze", "Fragmage",     "Smootiekin",
                                "Fluffyroger", "Oliviawilde",  "Noxo",         "Finalpandasy", "Tryhardlund",  "Isherya",
                                "Zaabok",      "Tbagin",       "Finshmstr",    "Fragdekay",    "Treckye",      "Lørglock",  "Noxbustion",
                                "Blattchi",    "Kreps",        "Åladya",       "Sparkgg" };


            /*var methodNames = client.GetGuildMembers(guild, 90);
             * Console.WriteLine(methodNames);
             * Console.WriteLine(methodNames.Length);
             */
            Console.WriteLine("Parsing: " + method.Length + "objects ");

            Stopwatch s1 = new Stopwatch();

            s1.Start();
            var mA2 = await client.GetCharactersInGuildAsync(method, CharacterOptions.None);

            s1.Stop();
            Console.WriteLine("mA2: " + s1.ElapsedMilliseconds + " ms");

            Thread.Sleep(2000);


            /*
             * foreach (var c in mA2)
             * {
             *  iteration++;
             *
             *  Console.WriteLine("Iteration Nr: " + iteration + " ------------------------------");
             *  Console.WriteLine("Name: " + c.Name
             + "\nAchivement points: " + c.AchievementPoints
             + "\nLevel: " + c.Level);
             +  Console.WriteLine("----------------------------------------------");
             +
             + }*/
        }
示例#9
0
        public BaseServiceTests()
        {
            var config = new ApiConfig();

            ApiClientAsync = new ApiClientAsync(config);
        }