public Faction(int factionId) { _gameConfigCache = CallContext <GameConfigCache> .GetData("GameConfigCache"); _gameDataRepository = CallContext <GameDataRepository> .GetData("GameDataRepository"); _factionRecord = _gameDataRepository.GetFactionById(factionId); _gameDataRepository.FactionUpdated += FactionUpdated; }
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); }