public void GetByID_RemovedItem_ReturnsCorrectObject() { // Arrange var id1 = Guid.NewGuid(); var id2 = Guid.NewGuid(); PCMapProgression entity1 = new PCMapProgression { ID = id1 }; PCMapProgression entity2 = new PCMapProgression { ID = id2 }; // Act MessageHub.Instance.Publish(new OnCacheObjectSet <PCMapProgression>(entity1)); MessageHub.Instance.Publish(new OnCacheObjectSet <PCMapProgression>(entity2)); MessageHub.Instance.Publish(new OnCacheObjectDeleted <PCMapProgression>(entity1)); // Assert Assert.Throws <KeyNotFoundException>(() => { _cache.GetByID(id1); }); Assert.AreNotSame(entity2, _cache.GetByID(id2)); }
private void SaveMapProgression(NWArea area, NWPlayer player) { var map = _data.GetAll <PCMapProgression>().SingleOrDefault(x => x.PlayerID == player.GlobalID && x.AreaResref == area.Resref); int areaSize = area.Width * area.Height; DatabaseActionType action = DatabaseActionType.Update; if (map == null || areaSize != map.Progression.Length) { if (map != null) { _data.SubmitDataChange(map, DatabaseActionType.Delete); } map = new PCMapProgression { PlayerID = player.GlobalID, AreaResref = area.Resref, Progression = string.Empty.PadLeft(areaSize, '0') }; action = DatabaseActionType.Insert; } string progression = string.Empty; for (int x = 0; x < area.Width; x++) { for (int y = 0; y < area.Height; y++) { bool visible = _.GetTileExplored(player, area, x, y) == TRUE; progression += visible ? '1' : '0'; } } map.Progression = progression; _data.SubmitDataChange(map, action); }