예제 #1
0
        public void Setup()
        {
            if (_repo != null)
            {
                return;
            }

            CallContext <GameConfigRepository> .SetData("GameConfigRepository", new GameConfigRepository());

            _repo = new GameDataRepository();
            _repo.Add(new FactionRecord(0, 0, 0));
            _repo.Add(new StackRecord(1, PointI.Zero));
            _repo.Add(new StackRecord(1, PointI.Zero));
        }
예제 #2
0
 static Repository()
 {
     Repo = new GameDataRepository();
     Repo.Add(new FactionRecord(0, 0, 0)); // Barbarians
     Repo.Add(new SettlementRecord(0, 1, new PointI(12, 9), "Testville"));
     Repo.Add(new StackRecord(1, new PointI(12, 9)));
     Repo.Add(new UnitRecord(100, 1));
     Repo.Add(new StackRecord(1, new PointI(15, 7)));
     Repo.Add(new UnitRecord(0, 2));
     Repo.Add(new StackRecord(1, new PointI(12, 9)));
     Repo.Add(new UnitRecord(1, 3));
 }
예제 #3
0
        public void Faction_tests()
        {
            _repo.FactionUpdated += FactionUpdated;

            var factionRecord = new FactionRecord(0, 0, 0);

            _repo.Add(factionRecord);
            var id = factionRecord.Id;

            factionRecord = _repo.GetFactionById(id);

            Assert.AreEqual(id, factionRecord.Id);
            Assert.AreEqual(0, factionRecord.RaceTypeId.Value);
            Assert.AreEqual(0, factionRecord.GoldInTreasury.Value);
            Assert.AreEqual(0, factionRecord.ManaInTreasury.Value);

            var updatedFaction = new FactionRecord(factionRecord, new GoldInTreasury(10), new ManaInTreasury(20));

            _repo.Update(updatedFaction);
            factionRecord = _repo.GetFactionById(id);
            Assert.AreEqual(0, factionRecord.RaceTypeId.Value);
            Assert.AreEqual(10, factionRecord.GoldInTreasury.Value);
            Assert.AreEqual(20, factionRecord.ManaInTreasury.Value);

            updatedFaction = new FactionRecord(factionRecord, new GoldInTreasury(25));
            _repo.Update(updatedFaction);
            factionRecord = _repo.GetFactionById(id);
            Assert.AreEqual(0, factionRecord.RaceTypeId.Value);
            Assert.AreEqual(25, factionRecord.GoldInTreasury.Value);
            Assert.AreEqual(20, factionRecord.ManaInTreasury.Value);

            updatedFaction = new FactionRecord(factionRecord, new ManaInTreasury(50));
            _repo.Update(updatedFaction);
            factionRecord = _repo.GetFactionById(id);
            Assert.AreEqual(0, factionRecord.RaceTypeId.Value);
            Assert.AreEqual(25, factionRecord.GoldInTreasury.Value);
            Assert.AreEqual(50, factionRecord.ManaInTreasury.Value);
        }