Ejemplo n.º 1
0
        public void SkinPack_ThrowsWhenSkinFileIsMissing()
        {
            string skinpack = @"{
    ""Version"": ""1.2.3"",
    ""Name"": ""Test Pack"",
    ""Description"": ""Test skin pack"",
    ""Skins"": [
        {
          ""Name"": ""A clock"",
          ""Description"": ""A test clock for testing"",
          ""Definition"": ""skin.json""
        }
    ]
}";

            var fileReaderMock = new Mock <IFileReader>();

            fileReaderMock.Setup(f => f.FileExists(It.IsAny <string>())).Returns((string s) => s == "skinpack.json");
            fileReaderMock.Setup(f => f.GetString("skinpack.json")).Returns(skinpack);

            Assert.Throws <SkinPack.ValidationFailedException>(() =>
            {
                SkinPack.Load(fileReaderMock.Object);
            });
        }
Ejemplo n.º 2
0
        public void SkinPackIndex_CanBeLoaded()
        {
            var files = new Dictionary <string, string>
            {
                { "skinpack.json", @"{
    ""Version"": ""1.2.3"",
    ""Name"": ""Test Pack"",
    ""Description"": ""Test skin pack"",
    ""Skins"": [
        {
          ""Name"": ""A clock"",
          ""Description"": ""A test clock for testing"",
          ""Definition"": ""testclock.json""
        }
    ]
}" },
                { "testclock.json", @"{}" }
            };
            var fileReader = new FakeFileReader(files);
            var sut        = SkinPack.Load(fileReader);

            Assert.IsNotNull(sut);
            Assert.AreEqual(1, sut.Skins.Count);
            var skin = sut.Skins[0];

            Assert.AreEqual("A clock", skin.Name);
            Assert.AreEqual("testclock.json", skin.Definition);
            Assert.IsEmpty(skin.Variables);
        }
Ejemplo n.º 3
0
        public void SkinPack_ThrowsWhenIndexIsMissing()
        {
            var io = Mock.Of <IFileReader>(r => r.FileExists(It.IsAny <string>()) == false);

            Assert.Throws <EntryPointNotFoundException>(() =>
            {
                SkinPack.Load(io);
            });
        }
Ejemplo n.º 4
0
        public void SkinPack_UpdatesVariables()
        {
            var files = new Dictionary <string, string>
            {
                { "skinpack.json", @"{
    ""Version"": ""1.2.3"",
    ""Name"": ""Test Pack"",
    ""Description"": ""Test skin pack"",
    ""Skins"": [
        {
            ""Name"": ""A clock"",
            ""Description"": ""A test clock for testing"",
            ""Definition"": ""clock.json"",
            ""Variables"": {
                ""col"": ""1"",
                ""color"": ""red""
            }
        }
    ]
}" },
                { "clock.json", @"{
  ""Width"": 100,
  ""Height"": 100,
  ""Layers"": [
    {
      ""$type"": ""SolidLayer"",
      ""BackgroundColor"": ""#fff"",
      ""Shapes"": [
        {
          ""$type"": ""RectangleShape"",
          ""Left"": $col,
          ""Top"": 0.0,
          ""Width"": 50.0,
          ""Height"": 50.0,
          ""Color"": ""$color""
        }
      ],
    }
  ]
}" }
            };
            var fileReader = new FakeFileReader(files);
            var skinpack   = SkinPack.Load(fileReader);

            var shape = skinpack.Skins.First().Canvas.Layers.First().Shapes.First() as RectangleShape;

            Assert.IsNotNull(shape);
            Assert.AreEqual("red", shape.Color);
            Assert.AreEqual(1, shape.Left);
        }