private async Task testImportTemplateFail(string templateMain, string pagesTest, SemanticError[] expectedErrors, SemanticWarning[] expectedWarnings)
        {
            var tc = getTestContext();

            PersistingBlob blHeader = new PersistingBlob(templateMain.ToStream());
            PersistingBlob blTest = new PersistingBlob(pagesTest.ToStream());

            // Persist the blob contents:
            var sblobs = await tc.blrepo.PersistBlobs(blHeader, blTest);

            TreeNode trTemplate = new TreeNode.Builder(
                new List<TreeTreeReference>(0),
                new List<TreeBlobReference> {
                    new TreeBlobReference.Builder("main", sblobs[0].Value.ID),
                }
            );
            TreeNode trPages = new TreeNode.Builder(
                new List<TreeTreeReference>(0),
                new List<TreeBlobReference> {
                    new TreeBlobReference.Builder("test", sblobs[1].Value.ID)
                }
            );
            TreeNode trRoot = new TreeNode.Builder(
                new List<TreeTreeReference> {
                    new TreeTreeReference.Builder("template", trTemplate.ID),
                    new TreeTreeReference.Builder("pages", trPages.ID)
                },
                new List<TreeBlobReference>(0)
            );

            // Persist the trees:
            var trTask = await tc.trrepo.PersistTree(trRoot.ID, new ImmutableContainer<TreeID, TreeNode>(tr => tr.ID, trTemplate, trPages, trRoot));

            output(new TreePathStreamedBlob(trRoot.ID, (CanonicalBlobPath)"/templates/main", sblobs[0].Value));
            assumeFail(tc, new TreePathStreamedBlob(trRoot.ID, (CanonicalBlobPath)"/pages/test", sblobs[1].Value), expectedErrors, expectedWarnings);
        }
Beispiel #2
0
 protected void assumeFail(TestContext tc, string blob, IVO.CMS.SemanticError[] expectedErrors, SemanticWarning[] expectedWarnings)
 {
     var bl = new MemoryStreamedBlob(blob);
     assumeFail(tc, bl, new TreeID(), expectedErrors, expectedWarnings);
 }
Beispiel #3
0
        protected void assumeFail(TestContext tc, TreePathStreamedBlob item, IVO.CMS.SemanticError[] expectedErrors, SemanticWarning[] expectedWarnings)
        {
            output(item);

            var fragTask = tc.ce.RenderBlob(item);
            fragTask.Wait();

            var efrag = fragTask.Result;
            Assert.IsFalse(efrag.HasErrors);

            var frag = efrag.Value;
            output(frag);

            var errors = tc.ce.GetErrors();
            if (errors.Count > 0)
            {
                Console.Error.WriteLine("Error(s):");
                foreach (var err in errors)
                {
                    Console.Error.WriteLine("  {0} ({1}:{2}): {3}", err.Item.TreeBlobPath.Path, err.LineNumber, err.LinePosition, err.Message);
                }
            }

            var warns = tc.ce.GetWarnings();
            if (warns.Count > 0)
            {
                Console.Error.WriteLine("Warning(s):");
                foreach (var warn in warns)
                {
                    Console.Error.WriteLine("  {0} ({1}:{2}): {3}", warn.Item.TreeBlobPath.Path, warn.LineNumber, warn.LinePosition, warn.Message);
                }
            }

            Assert.AreEqual(expectedErrors.Length, errors.Count);
            CollectionAssert.AreEqual(expectedErrors, errors, new SemanticErrorMessageComparer());
            Assert.AreEqual(expectedWarnings.Length, warns.Count);
            CollectionAssert.AreEqual(expectedWarnings, warns, new SemanticWarningMessageComparer());
        }
Beispiel #4
0
 protected void assumeFail(string blob, IVO.CMS.SemanticError[] expectedErrors, SemanticWarning[] expectedWarnings)
 {
     var tc = getTestContext();
     assumeFail(tc, blob, expectedErrors, expectedWarnings);
 }
Beispiel #5
0
 protected void assumeFail(TestContext tc, IStreamedBlob bl, TreeID rootid, IVO.CMS.SemanticError[] expectedErrors, SemanticWarning[] expectedWarnings)
 {
     var item = new TreePathStreamedBlob(rootid, (CanonicalBlobPath)"/test", bl);
     assumeFail(tc, item, expectedErrors, expectedWarnings);
 }