Beispiel #1
0
        public async Task TestGetCombat_WithSpoilsOfWar()
        {
            // Arrange
            ControllerMock primaryUser = new ControllerMock();

            primaryUser.SetupDummySession(SessionGuid)
            .SetupDummyWorldAsTree()
            .SetupSessionPhase(SessionPhase.SpoilsOfWar)
            .SetupRegionOwnership(ControllerMockRegionRepositoryExtensions.DummyWorldRegionB, DummyUserRepository.RegisteredUserIds[1])
            .SetupRegionOwnership(ControllerMockRegionRepositoryExtensions.DummyWorldRegionD, DummyUserRepository.RegisteredUserIds[2])
            .SetupSpoilsOfWar(ControllerMockRegionRepositoryExtensions.DummyWorldRegionA, ControllerMockRegionRepositoryExtensions.DummyWorldRegionB, 5, ControllerMockRegionRepositoryExtensions.DummyWorldRegionD, 1);

            // Act
            IEnumerable <ICombat> result = await primaryUser.WorldController.GetCombat(SessionGuid);

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.Count());
            Assert.AreEqual(CombatType.SpoilsOfWar, result.First().ResolutionType);
            Assert.AreEqual(3, result.First().InvolvedArmies.Count());

            AssertCombat.IsAttacking(ControllerMockRegionRepositoryExtensions.DummyWorldRegionB, 5, DummyUserRepository.RegisteredUserIds[1], result.First());
            AssertCombat.IsAttacking(ControllerMockRegionRepositoryExtensions.DummyWorldRegionD, 1, DummyUserRepository.RegisteredUserIds[2], result.First());
            AssertCombat.IsDefending(ControllerMockRegionRepositoryExtensions.DummyWorldRegionA, 0, primaryUser.OwnerId, result.First());
        }
Beispiel #2
0
        public async Task TestGetCombat_WithBorderClash()
        {
            // Arrange
            ControllerMock primaryUser = new ControllerMock();

            primaryUser.SetupDummySession(SessionGuid)
            .SetupDummyWorldAsTree()
            .SetupSessionPhase(SessionPhase.BorderClashes)
            .SetupRegionOwnership(ControllerMockRegionRepositoryExtensions.DummyWorldRegionD, DummyUserRepository.RegisteredUserIds[1])
            .SetupRegionTroops(ControllerMockRegionRepositoryExtensions.DummyWorldRegionA, 7)
            .SetupRegionTroops(ControllerMockRegionRepositoryExtensions.DummyWorldRegionD, 2)
            .SetupBorderClash(ControllerMockRegionRepositoryExtensions.DummyWorldRegionA, 5, ControllerMockRegionRepositoryExtensions.DummyWorldRegionD, 1);

            // Act
            IEnumerable <ICombat> result = await primaryUser.WorldController.GetCombat(SessionGuid);

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(3, result.Count());

            var borderClash = result.Where(combat => combat.ResolutionType == CombatType.BorderClash).FirstOrDefault();

            Assert.IsNotNull(borderClash);
            Assert.AreEqual(2, borderClash.InvolvedArmies.Count());
            AssertCombat.IsAttacking(ControllerMockRegionRepositoryExtensions.DummyWorldRegionA, 5, primaryUser.OwnerId, borderClash);
            AssertCombat.IsAttacking(ControllerMockRegionRepositoryExtensions.DummyWorldRegionD, 1, DummyUserRepository.RegisteredUserIds[1], borderClash);

            var invasionOfA = result.Where(combat => combat.ResolutionType == CombatType.Invasion && combat.InvolvedArmies.First().OriginRegionId == ControllerMockRegionRepositoryExtensions.DummyWorldRegionA).FirstOrDefault();

            Assert.IsNotNull(invasionOfA);
            Assert.AreEqual(1, invasionOfA.InvolvedArmies.Count());
            AssertCombat.IsDefending(ControllerMockRegionRepositoryExtensions.DummyWorldRegionA, 2, primaryUser.OwnerId, invasionOfA);

            var invasionOfD = result.Where(combat => combat.ResolutionType == CombatType.Invasion && combat.InvolvedArmies.First().OriginRegionId == ControllerMockRegionRepositoryExtensions.DummyWorldRegionD).FirstOrDefault();

            Assert.IsNotNull(invasionOfD);
            Assert.AreEqual(1, invasionOfD.InvolvedArmies.Count());
            AssertCombat.IsDefending(ControllerMockRegionRepositoryExtensions.DummyWorldRegionD, 1, DummyUserRepository.RegisteredUserIds[1], invasionOfD);
        }