public void SavedObjectAddsObjectToLayout() { var puzzleObject = new FlatLayout.PuzzleObject { Type = "type", Position = new TilePos(1, 1), Properties = { new FlatLayout.PuzzleObject.Property { Key = "key", Type = "System.Boolean", Value = "true" } } }; _savedLayout.Objects.Add(puzzleObject); var gameLayout = new PuzzleLayout(); _sut.LoadFromFlatLayout(_savedLayout, gameLayout); var puzzleObjects = gameLayout.GetAllObjects(); puzzleObjects.Should().HaveCount(1); puzzleObjects[0].Type.Should().Be(puzzleObject.Type); puzzleObjects[0].Position.Should().Be(puzzleObject.Position); puzzleObjects[0].Properties.Should().HaveCount(1); var property = puzzleObjects[0].Properties.First().Value; property.Key.Should().Be("key"); property.Type.Should().Be(typeof(bool)); property.Value.Should().Be(true); }
public FlatLayout SaveToFlatLayout(PuzzleLayout layoutToSave) { return(new FlatLayout { Connections = layoutToSave.GetAllConnections(), Objects = layoutToSave.GetAllObjects() .Select(puzzleObject => new FlatLayout.PuzzleObject { Type = puzzleObject.Type, Position = puzzleObject.Position, Properties = puzzleObject.Properties.Values.Select(x => new FlatLayout.PuzzleObject.Property() { Key = x.Key, Value = x.Value.ToString(), Type = x.Type.ToString() }).ToList() }) .ToList() }); }