示例#1
0
        public void NestedSketchSymbolCreatesUxInstance()
        {
            var childSymbol = DocumentBuilder.SketchSymbolMaster("Inner").WithLayer(DocumentBuilder.Rectangle("R1"));

            var document = DocumentBuilder.SketchDocument()
                           .WithSymbol(childSymbol)
                           .WithSymbol(DocumentBuilder.SketchSymbolMaster("Outer").WithLayer(DocumentBuilder.SymbolInstanceOf(childSymbol)));

            var logger  = new MessageListLogger();
            var builder = new SymbolsUxBuilder(logger);

            builder.Build(document, _outputDirectory);

            var files = Directory.EnumerateFiles(_outputDirectory);

            Assert.AreEqual(2, files.Count());
            Assert.IsTrue(files.First().EndsWith("Inner.ux"));
            Assert.IsTrue(files.Last().EndsWith("Outer.ux"));
            Assert.AreEqual(0, logger.ErrorsAndWarnings().Count);

            var ux = File.ReadAllText(files.Last());

            Assert.IsTrue(ux.Contains("<Sketch.Inner"));
            Assert.IsTrue(ux.Contains("</Sketch.Inner>"));
        }
示例#2
0
        public void NoSymbolsInSketchDocumentProducesInfo()
        {
            var document = DocumentBuilder.SketchDocument();
            var logger   = new MessageListLogger();
            var builder  = new SymbolsUxBuilder(logger);

            builder.Build(document, _outputDirectory);
            var files = Directory.EnumerateFiles(_outputDirectory);

            Assert.IsEmpty(files);
            Assert.AreEqual(1, logger.Messages.Count);
            Assert.That(logger.Messages.First(), Does.Match("INFO.*No UX generated"));
        }
示例#3
0
        public void OneSymbolCreateOneUxClass()
        {
            var sketchSymbolMaster = DocumentBuilder.SketchSymbolMaster("MySymbol");
            var document           = DocumentBuilder.SketchDocument()
                                     .WithSymbol(sketchSymbolMaster);

            var logger  = new MessageListLogger();
            var builder = new SymbolsUxBuilder(logger);

            builder.Build(document, _outputDirectory);

            var files = Directory.EnumerateFiles(_outputDirectory);

            Assert.AreEqual(1, files.Count());
            Assert.IsTrue(files.First().EndsWith("MySymbol.ux"));
        }
示例#4
0
        public void SymbolWithReservedNameGetsSkippedAndLogged()
        {
            var sketchSymbolMaster = DocumentBuilder.SketchSymbolMaster("class");
            var document           = DocumentBuilder.SketchDocument()
                                     .WithSymbol(sketchSymbolMaster);

            var logger  = new MessageListLogger();
            var builder = new SymbolsUxBuilder(logger);

            builder.Build(document, _outputDirectory);

            var files = Directory.EnumerateFiles(_outputDirectory);

            Assert.That(files.Count(), Is.EqualTo(0));
            Assert.That(logger.ErrorsAndWarnings().Count, Is.EqualTo(1));
            Assert.That(logger.ErrorsAndWarnings()[0], Does.Contain("The symbol name 'class' is a reserved word."));
        }
示例#5
0
        public void SymbolWithInvalidCharacterInNameGetsSkippedAndLogged()
        {
            var sketchSymbolMaster = DocumentBuilder.SketchSymbolMaster("a b");
            var document           = DocumentBuilder.SketchDocument()
                                     .WithSymbol(sketchSymbolMaster);

            var logger  = new MessageListLogger();
            var builder = new SymbolsUxBuilder(logger);

            builder.Build(document, _outputDirectory);

            var files = Directory.EnumerateFiles(_outputDirectory);

            Assert.That(files.Count(), Is.EqualTo(0));
            Assert.That(logger.ErrorsAndWarnings().Count, Is.EqualTo(1));
            Assert.That(logger.ErrorsAndWarnings()[0], Does.Contain("The symbol name 'a b' contains an invalid character"));
        }
示例#6
0
        public void SymbolWithNoLayersDoesNotGetWritten()
        {
            var document = DocumentBuilder.SketchDocument()
                           .WithSymbol(DocumentBuilder.SketchSymbolMasterWithNoLayers("Harry"));

            var logger  = new MessageListLogger();
            var builder = new SymbolsUxBuilder(logger);

            builder.Build(document, _outputDirectory);

            var file = Directory.EnumerateFiles(_outputDirectory);

            Assert.AreEqual(0, file.Count());

            Assert.AreEqual(1, logger.ErrorsAndWarnings().Count);
            Assert.That(logger.ErrorsAndWarnings().First(),
                        Does.Match("Skipping symbol 'Sketch.Harry' which has no supported layers."));
        }
示例#7
0
        public void TwoSketchSymbolsProducesTwoUxClassesInTwoFiles()
        {
            var document = DocumentBuilder.SketchDocument()
                           .WithSymbol(DocumentBuilder.SketchSymbolMaster("MySymbol").WithLayer(DocumentBuilder.Rectangle("R")))
                           .WithSymbol(DocumentBuilder.SketchSymbolMaster("MySymbol2").WithLayer(DocumentBuilder.Rectangle("R2")));

            var logger  = new MessageListLogger();
            var builder = new SymbolsUxBuilder(logger);

            builder.Build(document, _outputDirectory);


            var files = Directory.EnumerateFiles(_outputDirectory).ToList();

            Assert.AreEqual(2, files.Count());
            Assert.IsTrue(files.First().EndsWith("MySymbol.ux"));
            Assert.IsTrue(files.Last().EndsWith("MySymbol2.ux"));
            Assert.AreEqual(0, logger.ErrorsAndWarnings().Count);
        }
示例#8
0
        public void TwoSymbolsWithSameNameGivesErrorAndOnlyWritesOne()
        {
            var document = DocumentBuilder.SketchDocument()
                           .WithSymbol(DocumentBuilder.SketchSymbolMaster("NameOfTheGame").WithLayer(DocumentBuilder.Rectangle("R")))
                           .WithSymbol(DocumentBuilder.SketchSymbolMaster("NameOfTheGame").WithLayer(DocumentBuilder.Rectangle("R")));

            var logger  = new MessageListLogger();
            var builder = new SymbolsUxBuilder(logger);

            builder.Build(document, _outputDirectory);


            var files = Directory.EnumerateFiles(_outputDirectory).ToList();

            Assert.That(files.Count(), Is.EqualTo(1));
            Assert.That(files.First(), Does.EndWith("NameOfTheGame.ux"));
            Assert.That(logger.ErrorsAndWarnings().Count, Is.EqualTo(1));
            Assert.That(logger.ErrorsAndWarnings()[0], Does.Match("More than one symbol named 'NameOfTheGame' was found!"));
        }