Exemplo n.º 1
0
        public void TestBrokenRelatedLinks()
        {
            PivotCollection collection = new PivotCollection();
            collection.FacetCategories.Add(new PivotFacetCategory("alpha", PivotFacetType.String));

            PivotItem item = new PivotItem("0", collection);
            item.AddFacetValues("alpha", "alpha");
            item.AddRelatedLink(new PivotLink(null, "http://pauthor.codeplex.com"));
            collection.Items.Add(item);

            item = new PivotItem("1", collection);
            item.AddFacetValues("alpha", "bravo");
            item.AddRelatedLink(new PivotLink("charlie", null));
            collection.Items.Add(item);

            PivotCollectionBuffer buffer = new PivotCollectionBuffer(collection);
            String targetPath = Path.Combine(WorkingDirectory, "sample.cxml");
            LocalCxmlCollectionTarget target = new LocalCxmlCollectionTarget(targetPath);
            target.Write(buffer);

            AssertCxmlSchemaValid(targetPath);

            CxmlCollectionSource targetAsSource = new CxmlCollectionSource(targetPath);
            buffer.Write(targetAsSource);

            AssertEqual("Related Link", buffer.Collection.Items[0].RelatedLinks.First().Title);
            AssertEqual("http://pauthor.codeplex.com", buffer.Collection.Items[0].RelatedLinks.First().Url);
            AssertEqual(0, buffer.Collection.Items[1].RelatedLinks.Count());
        }
        public void TestCsvToCxmlWithTemplate()
        {
            String sourcePath = Path.Combine(this.ResourceDirectory, @"CSV\sample_missing_images.csv");
            String templatePath = Path.Combine(this.ResourceDirectory, @"CSV\template-1.htm");
            String targetPath = Path.Combine(WorkingDirectory, "sample.cxml");

            PauthorProgram.Main(new String[] {
                "/source", "csv", sourcePath, "/html-template", templatePath, "/target", "cxml", targetPath });

            AssertCxmlSchemaValid(targetPath);
            AssertFileExists(@"sample.cxml");
            AssertFileExists(@"sample_images\0.png");

            IPivotCollectionSource source = new CsvCollectionSource(sourcePath);
            IPivotCollectionSource targetAsSource = new CxmlCollectionSource(targetPath);
            PivotCollectionBuffer buffer = new PivotCollectionBuffer();
            buffer.Write(source);
            PivotCollection expected = buffer.Collection;
            buffer.Write(targetAsSource);
            PivotCollection actual = buffer.Collection;

            AssertEqual(expected.Name, actual.Name);
            AssertEqual(expected.Icon, actual.Icon);
            AssertEqual(expected.FacetCategories[0].Name, actual.FacetCategories[0].Name);
            AssertEqual(expected.FacetCategories.Count, actual.FacetCategories.Count);
            AssertEqual(expected.Items[0].Name, actual.Items[0].Name);
            AssertNotEqual(expected.Items[0].Image, actual.Items[0].Image);
        }