Пример #1
0
        private static TokenTextLayerPart <CommentLayerFragment> GetPart(
            bool fragments = true)
        {
            var part = new TokenTextLayerPart <CommentLayerFragment>
            {
                ItemId    = Guid.NewGuid().ToString(),
                RoleId    = "some-role",
                CreatorId = "zeus",
                UserId    = "another"
            };

            if (fragments)
            {
                for (int i = 1; i <= 3; i++)
                {
                    part.AddFragment(new CommentLayerFragment
                    {
                        Location = $"1.{i}",
                        Tag      = i > 1 ? "scholarly" : null,
                        Text     = "Text {i}.\nEnd."
                    });
                }
            }
            return(part);
        }
        public void GetDataPins_WithItem_2()
        {
            Item item = new Item
            {
                CreatorId   = "zeus",
                UserId      = "zeus",
                Title       = "Mock",
                Description = "A mock item",
                FacetId     = "default",
                SortKey     = "mock"
            };
            TokenTextPart textPart = new TokenTextPart
            {
                ItemId    = item.Id,
                CreatorId = item.CreatorId,
                UserId    = item.UserId,
            };

            textPart.Lines.Add(new TextLine
            {
                Text = "quae bixit annis X",
                Y    = 1
            });
            item.Parts.Add(textPart);

            TokenTextLayerPart <OrthographyLayerFragment> layerPart =
                new TokenTextLayerPart <OrthographyLayerFragment>();
            OrthographyLayerFragment fr;

            layerPart.AddFragment(fr = new OrthographyLayerFragment
            {
                Location = "1.2",
                Standard = "vixit",
            });
            item.Parts.Add(layerPart);

            List <DataPin> pins = fr.GetDataPins(item).ToList();

            Assert.Equal(2, pins.Count);

            DataPin pin = pins.Find(p => p.Name == "fr.orthography-txt");

            Assert.NotNull(pin);
            Assert.Equal("bixit", pin.Value);

            pin = pins.Find(p => p.Name == "fr.orthography-std");
            Assert.NotNull(pin);
            Assert.Equal("vixit", pin.Value);
        }
Пример #3
0
        private TokenTextLayerPart <CommentLayerFragment> GetCommentLayerPart(
            string[] locations)
        {
            TokenTextLayerPart <CommentLayerFragment> part =
                new TokenTextLayerPart <CommentLayerFragment>();

            for (int i = 0; i < locations.Length; i++)
            {
                part.AddFragment(new CommentLayerFragment
                {
                    Location = locations[i],
                    Tag      = "tag",
                    Text     = $"Comment {i + 1}"
                });
            }

            return(part);
        }