Ejemplo n.º 1
0
        public void EmptyGroupReturnsNullNode()
        {
            var noLayers   = new List <SketchLayer>();
            var emptyGroup = new SketchGroup(new SketchLayer(CreateLayer(10, 10), noLayers));
            var builder    = new UxBuilder(new SymbolClassNameBuilder(), Substitute.For <IAssetEmitter>(), new MessageListLogger());
            var uxNode     = builder.BuildLayer(emptyGroup);

            Assert.That(uxNode, Is.InstanceOf(typeof(NullNode)));
        }
Ejemplo n.º 2
0
        UxNode BuildGroup(SketchGroup group)
        {
            if (group.Layers.Count == 0)
            {
                return(new NullNode(new UxComment("Skipped empty group '" + group.Name + "'")));
            }
            var node = new UxNode
            {
                ClassName       = "Panel",
                SketchLayerName = group.Name
            };

            return(BuildLayout(group, node));
        }
Ejemplo n.º 3
0
        public void BuildUxForSketchShapeGroupWithoutMaskingGivesNoWarnings()
        {
            var rectangle = new SketchRectangle(
                CreateLayer(5, 5),
                new SketchPath(CurvePointUtils.RectanglePath(new CornerRadius(2)), true),
                SketchBooleanOperation.NoOperation);

            var parentGroup =
                new SketchGroup(
                    new SketchLayer(
                        new SketchLayer(
                            Guid.Empty,
                            new SketchLayer(
                                CreateLayer(20, 20),
                                new List <SketchLayer>()),
                            new SketchRect(0, 0, 10, 10, false),
                            "Dummy",
                            false,
                            DummyAlignment(),
                            0, false, false,
                            Optional.None(),
                            new List <SketchLayer>()),
                        new List <SketchLayer> {
                rectangle
            }));

            rectangle.Parent = parentGroup;

            var log       = new MessageListLogger();
            var uxBuilder = new UxBuilder(new SymbolClassNameBuilder(), Substitute.For <IAssetEmitter>(), log);

            var uxNode = uxBuilder.BuildLayer(parentGroup);

            Assert.That(uxNode, Is.Not.Null);

            var ux = uxNode.SerializeUx(new UxSerializerContext());

            Assert.That(ux, Is.EqualTo("<Panel Width=\"50%\" Height=\"50%\" Alignment=\"TopLeft\" Margin=\"0\">\n\t<!-- Dummy -->\n\t<Rectangle CornerRadius=\"2\" Width=\"50%\" Height=\"50%\" Alignment=\"TopLeft\" Margin=\"0\">\n\t\t<!-- Dummy -->\n\t</Rectangle>\n</Panel>"));
            Assert.That(log.ErrorsAndWarnings(), Is.Empty);
        }
Ejemplo n.º 4
0
        public void BuildUxForSketchShapeGroupWithMaskingGivesUnsupportedWarnings()
        {
            var shapeGroup = new SketchShapeGroup(
                new SketchLayer(CreateLayer(5, 5), new List <SketchLayer>()),
                Mask);

            var parentGroup =
                new SketchGroup(
                    new SketchLayer(
                        new SketchLayer(
                            Guid.Empty,
                            new SketchLayer(
                                CreateLayer(20, 20),
                                new List <SketchLayer>()),
                            new SketchRect(0, 0, 10, 10, false),
                            "Dummy",
                            false,
                            DummyAlignment(),
                            0, false, false,
                            Optional.None(),
                            new List <SketchLayer>()),
                        new List <SketchLayer> {
                shapeGroup
            }));

            shapeGroup.Parent = parentGroup;

            var log       = new MessageListLogger();
            var uxBuilder = new UxBuilder(new SymbolClassNameBuilder(), Substitute.For <IAssetEmitter>(), log);

            var uxNode = uxBuilder.BuildLayer(parentGroup);

            Assert.That(uxNode, Is.Not.Null);

            var ux = uxNode.SerializeUx(new UxSerializerContext());

            Assert.That(ux, Is.EqualTo("<Panel Width=\"50%\" Height=\"50%\" Alignment=\"TopLeft\" Margin=\"0\">\n\t<!-- Dummy -->\n\t<!-- Masked shape group is not supported in UX -->\n</Panel>"));
            Assert.That(log.ErrorsAndWarnings().First(), Does.Match("WARNING:\tMasked shapes are not supported Dummy"));
        }