Пример #1
0
        public static async Task <Web.Domain.Models.Player> PostPlayer(Web.Domain.Models.Player player)
        {
            var response = await _client.PostAsJsonAsync("api/player", player);

            response.EnsureSuccessStatusCode(); // Throw on error code

            var domainObject = await response.Content.ReadAsAsync <Web.Domain.Models.Player>();

            return(domainObject);
        }
Пример #2
0
        public static Web.Domain.Models.PlayerBattle ParsePlayerBattle(string json, Web.Domain.Models.Player player, Web.Domain.Models.Battle battle)
        {
            JObject jobject = JObject.Parse(json);

            var damageDealt    = (int)jobject[Personal]["damageDealt"];
            var damageReceived = (int)jobject[Personal]["damageReceived"];
            var tankName       = (string)jobject[Personal]["tankName"];
            // var tankId = (string)jobject[Personal]["tankId"]; // this tankId doesn't match the tank_id from the WoT API... because its typeCompDescr
            var typeCompDescr        = (int)jobject[Personal]["typeCompDescr"];
            var xp                   = (int)jobject[Personal]["xp"];
            var xpPenalty            = (int)jobject[Personal]["xpPenalty"];
            var tmenXP               = (int)jobject[Personal]["tmenXP"];
            var freeXP               = (int)jobject[Personal]["freeXP"];
            var eventXP              = (int)jobject[Personal]["eventXP"];
            var eventTMenXP          = (int)jobject[Personal]["eventTMenXP"];
            var eventFreeXP          = (int)jobject[Personal]["eventFreeXP"];
            var credits              = (int)jobject[Personal]["credits"];
            var autoRepairCost       = (int)jobject[Personal]["autoRepairCost"];
            var autoLoadCost         = (int)jobject[Personal]["autoLoadCost"][0];
            var autoEquipCost        = (int)jobject[Personal]["autoEquipCost"][0];
            var won                  = (bool)jobject[Personal]["won"];
            var kills                = (int)jobject[Personal]["kills"];
            var spotted              = (int)jobject[Personal]["spotted"];
            var capturePoints        = (int)jobject[Personal]["capturePoints"];
            var droppedCapturePoints = (int)jobject[Personal]["droppedCapturePoints"];

            return(new Web.Domain.Models.PlayerBattle()
            {
                BattleId = battle.BattleId,
                PlayerId = player.PlayerId,
                DamageDealt = damageDealt,
                DamageReceived = damageReceived,
                TankName = tankName,
                XP = xp,
                XPPenalty = xpPenalty,
                tmenXP = tmenXP,
                freeXP = freeXP,
                eventXP = eventXP,
                eventTMenXP = eventTMenXP,
                eventFreeXP = eventFreeXP,
                credits = credits,
                autoEquipCost = autoEquipCost,
                autoLoadCost = autoLoadCost,
                autoRepairCost = autoRepairCost,
                won = won,
                kills = kills,
                spotted = spotted,
                capturePoints = capturePoints,
                droppedCapturePoints = droppedCapturePoints,
                typeCompDescr = typeCompDescr
            });
        }
Пример #3
0
        public void Exercise_PostPlayer()
        {
            // Arrange
            var player = new Web.Domain.Models.Player() { AccountDBID = 123456789, Name = "ElmerFudd" };

            // Act
            var actual = WebApiService.PostPlayer(player).Result;

            // Assert
            Assert.AreEqual(player.AccountDBID, actual.AccountDBID);
            Assert.AreEqual(player.Name, actual.Name);
            Assert.AreNotEqual(0, actual.PlayerId);

            // TODO: Cleanup the record out of the database?  Or will we just recreate the database prior to each test
        }
Пример #4
0
        public void Exercise_PostPlayer()
        {
            // Arrange
            var player = new Web.Domain.Models.Player()
            {
                AccountDBID = 123456789, Name = "ElmerFudd"
            };

            // Act
            var actual = WebApiService.PostPlayer(player).Result;

            // Assert
            Assert.AreEqual(player.AccountDBID, actual.AccountDBID);
            Assert.AreEqual(player.Name, actual.Name);
            Assert.AreNotEqual(0, actual.PlayerId);

            // TODO: Cleanup the record out of the database?  Or will we just recreate the database prior to each test
        }
Пример #5
0
        public static Web.Domain.Models.PlayerBattle ParsePlayerBattle(string json, Web.Domain.Models.Player player, Web.Domain.Models.Battle battle)
        {
            JObject jobject = JObject.Parse(json);

            var damageDealt    = (int)jobject[Personal]["damageDealt"];
            var damageReceived = (int)jobject[Personal]["damageReceived"];
            var tankName       = (string)jobject[Personal]["tankName"];
            var xp             = (int)jobject[Personal]["xp"];
            var xpPenalty      = (int)jobject[Personal]["xpPenalty"];
            var tmenXP         = (int)jobject[Personal]["tmenXP"];
            var freeXP         = (int)jobject[Personal]["freeXP"];
            var eventXP        = (int)jobject[Personal]["eventXP"];
            var eventTMenXP    = (int)jobject[Personal]["eventTMenXP"];
            var eventFreeXP    = (int)jobject[Personal]["eventFreeXP"];
            var credits        = (int)jobject[Personal]["credits"];
            var autoRepairCost = (int)jobject[Personal]["autoRepairCost"];
            var autoLoadCost   = (int)jobject[Personal]["autoLoadCost"][0];
            var autoEquipCost  = (int)jobject[Personal]["autoEquipCost"][0];
            var won            = (bool)jobject[Personal]["won"];

            return(new Web.Domain.Models.PlayerBattle()
            {
                BattleId = battle.BattleId,
                PlayerId = player.PlayerId,
                DamageDealt = damageDealt,
                DamageReceived = damageReceived,
                TankName = tankName,
                XP = xp,
                XPPenalty = xpPenalty,
                tmenXP = tmenXP,
                freeXP = freeXP,
                eventXP = eventXP,
                eventTMenXP = eventTMenXP,
                eventFreeXP = eventFreeXP,
                credits = credits,
                autoEquipCost = autoEquipCost,
                autoLoadCost = autoLoadCost,
                autoRepairCost = autoRepairCost,
                won = won
            });
        }