コード例 #1
0
        public async Task IntegrationTestAddCombatResults()
        {
            // Arrange
            WorldRepository  repository        = new WorldRepository(DevelopmentStorageAccountConnectionString);
            Guid             SessionId         = new Guid("2CDE3217-B8F2-4FDA-8E7A-3B6B6FA4C747");
            Guid             combatId          = new Guid("4B0286E6-6DBE-4F86-A87C-1CF776F41437");
            Guid             attackingRegionId = new Guid("4CD8D6E1-8FFE-48E1-8FE0-B89BCDD0AA96");
            Guid             defendingRegionId = new Guid("E0FE9A73-4125-4DA1-A113-25ED927EA7B4");
            CombatTableEntry combat            = new CombatTableEntry(SessionId, 1, combatId, CombatType.Invasion);

            combat.SetCombatArmy(new List <ICombatArmy>
            {
                new CombatArmy(attackingRegionId, "AttackingUser", Core.CombatArmyMode.Attacking, 3),
                new CombatArmy(defendingRegionId, "DefendingUser", Core.CombatArmyMode.Defending, 2)
            });
            CombatResultTableEntry tableEntry = new CombatResultTableEntry(SessionId, combatId, new List <ICombatRoundResult>
            {
                new CombatRoundResult(
                    new List <ICombatArmyRoundResult>
                {
                    new CombatArmyRoundResult(attackingRegionId, "AttackingUser", new List <UInt32> {
                        2, 3, 4
                    }, 1),
                    new CombatArmyRoundResult(defendingRegionId, "DefendingUser", new List <UInt32> {
                        1, 1
                    }, 2),
                }
                    )
            });

            CloudTable testTable = SessionRepository.GetTableForSessionData(TableClient, SessionId);

            testTable.CreateIfNotExists();

            // Act
            await repository.AddCombatResults(SessionId, 1, new List <ICombatResult>
            {
                tableEntry
            });

            // Assert
            TableOperation operation = TableOperation.Retrieve <CombatResultTableEntry>(SessionId.ToString(), "Result_" + combatId.ToString());
            TableResult    result    = await testTable.ExecuteAsync(operation);

            Assert.IsNotNull(result.Result);
            Assert.IsInstanceOfType(result.Result, typeof(CombatResultTableEntry));
            CombatResultTableEntry resultStronglyTyped = result.Result as CombatResultTableEntry;

            AssertCombat.IsResultValid(1, combat, resultStronglyTyped);

            AssertCombat.IsArmyResult(attackingRegionId, 1, 1, resultStronglyTyped);
            AssertCombat.IsArmyResult(defendingRegionId, 1, 2, resultStronglyTyped);
        }
コード例 #2
0
        public void IntegrationTestCombatRoundResultCreateFromAzureString()
        {
            // Arrange
            String testString = "E63BC819-A1D2-4876-AE76-BBD63EBAEC99#AttackingUser#1#2#3#4@223AA4AE-AF1A-4169-A39C-3E6BA8F5B981#DefendingUser#2#1";

            // Act
            CombatRoundResult result = CombatRoundResult.CreateFromAzureString(testString);

            // Assert
            CombatResultTableEntry resultHelper = new CombatResultTableEntry(Guid.NewGuid(), Guid.NewGuid(), new List <ICombatRoundResult> {
                result
            });

            AssertCombat.IsArmyResult(new Guid("E63BC819-A1D2-4876-AE76-BBD63EBAEC99"), 1, 1, resultHelper);
            AssertCombat.IsArmyResult(new Guid("223AA4AE-AF1A-4169-A39C-3E6BA8F5B981"), 1, 2, resultHelper);
        }