public void AnimatedScreenSurface_SaveLoad() { new SadConsole.Tests.BasicGameHost(); // CreateStatic uses // AnimationDuration = 1; // Repeat = true; // Name = "default"; AnimatedScreenSurface animation = AnimatedScreenSurface.CreateStatic(10, 10, 10, 0.5d); animation.Name = "Static Frames"; animation.Center = (2, 2); animation.Save("test.file"); AnimatedScreenSurface animation2 = AnimatedScreenSurface.Load("test.file"); Assert.AreEqual(animation.Width, animation2.Width); Assert.AreEqual(animation.Height, animation2.Height); Assert.AreEqual(animation.Name, animation2.Name); Assert.AreEqual(animation.Frames.Count, animation2.Frames.Count); Assert.AreEqual(animation.Font?.Name, animation2.Font?.Name); Assert.AreEqual(animation.FontSize, animation2.FontSize); Assert.AreEqual(animation.Center, animation2.Center); Assert.AreEqual(animation.Repeat, animation2.Repeat); Assert.AreEqual(animation.AnimationDuration, animation2.AnimationDuration); Assert.AreEqual(animation.CurrentFrameIndex, animation2.CurrentFrameIndex); var surfaceTest = new CellSurface(); var surface1Frames = animation.Frames.ToList(); var surface2Frames = animation2.Frames.ToList(); for (int i = 0; i < surface1Frames.Count; i++) { surfaceTest.Surface_Equals(surface1Frames[i], surface2Frames[i]); } }
public SerializationTests() : base(80, 23) { //Settings.SerializationIsCompressed = true; _controlsConsole = new ControlsConsole(80, 4); masterView = new Console(34, 15); loadedView = new Console(34, 15); masterView.Fill(Color.White, Color.Red, 0); loadedView.Fill(Color.White, Color.Blue, 0); UseMouse = true; // Add the consoles to the list. Children.Add(_controlsConsole); Children.Add(masterView); Children.Add(loadedView); // Setup main view masterView.Position = new Point(3, 6); // Setup sub view loadedView.Position = new Point(80 - 37, 6); // Setup controls _controlsConsole.Position = new Point(0, 0); optionButtonSurface = new SadConsole.UI.Controls.RadioButton(18, 1) { Text = "Surface", Position = new Point(1, 1), }; optionButtonSurface.IsSelectedChanged += OptionButton_IsSelectedChanged; _controlsConsole.Controls.Add(optionButtonSurface); optionButtonView = new SadConsole.UI.Controls.RadioButton(18, 1) { Text = "Surface View", Position = new Point(1, 2) }; optionButtonView.IsSelectedChanged += OptionButton_IsSelectedChanged; _controlsConsole.Controls.Add(optionButtonView); optionButtonAnimated = new SadConsole.UI.Controls.RadioButton(21, 1) { Text = "Animated Surface", Position = new Point(optionButtonSurface.Bounds.MaxExtentX + 1, 2) }; optionButtonAnimated.IsSelectedChanged += OptionButton_IsSelectedChanged; _controlsConsole.Controls.Add(optionButtonAnimated); var buttonSave = new SadConsole.UI.Controls.Button(17, 1) { Text = "Save and Load", Position = new Point(_controlsConsole.Width - 19, 1) }; buttonSave.Click += ButtonSave_Click; _controlsConsole.Controls.Add(buttonSave); basicSurface = new SadConsole.Console(34, 15); animatedSurface = SadConsole.AnimatedScreenSurface.CreateStatic(34, 15, 15, 0.3d); viewSurface = new Console(((CellSurface)basicSurface.Surface).GetSubSurface(new Rectangle(5, 2, 34 - 10, 15 - 4))); //emptySurface = (SadConsole.Surfaces.BasicSurface)loadedView.TextSurface; MakeBasicSurface(); optionButtonSurface.IsSelected = true; }