Exemplo n.º 1
0
        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]);
            }
        }