public void Transformers_Overlayer_Familes()
        {
            Overlayer overlayer = new Overlayer(true, false, false);
            Document  docA      = new Document("1", null, null, new Dictionary <string, string>()
            {
                { "VOLUME", "test" }
            }, null);
            Document docB = new Document("1", null, null, new Dictionary <string, string>()
            {
                { "VOLUME", "overlay" }
            }, null);
            Document child = new Document("2", null, null, null, null);

            child.SetParent(docB);
            docB.Children.Add(child);

            Assert.IsFalse(child.Parent == docA);
            Assert.IsTrue(docA.Children == null);
            Assert.IsTrue(docB.Children.Contains(child));
            docA = overlayer.Overlay(docA, docB);

            Assert.IsTrue(docA.Children.Contains(child));
            Assert.IsTrue(child.Parent == docA);
            Assert.AreEqual("overlay", docB.Metadata["VOLUME"]);
            Assert.AreEqual("test", docA.Metadata["VOLUME"]);
        }
        public void Transformers_Overlayer_Exception()
        {
            Overlayer overlayer = new Overlayer(true, true, true);
            Document  docA      = new Document("1", null, null, null, null);
            Document  docB      = new Document("2", null, null, null, null);

            overlayer.Overlay(docA, docB);
        }
        public void Transformers_Overlayer_MetaData()
        {
            Overlayer overlayer = new Overlayer(false, true, false);
            Document  docA      = new Document("1", null, null, new Dictionary <string, string>()
            {
                { "VOLUME", "test" }
            }, null);
            Document docB = new Document("1", null, null, new Dictionary <string, string>()
            {
                { "VOLUME", "overlay" }, { "DOC", "meh" }
            }, null);

            Assert.AreEqual("test", docA.Metadata["VOLUME"]);
            docA = overlayer.Overlay(docA, docB);

            Assert.AreEqual("overlay", docA.Metadata["VOLUME"]);
            Assert.AreEqual("meh", docA.Metadata["DOC"]);
        }
        public void Transformers_Overlayer_Representatives()
        {
            Overlayer overlayer = new Overlayer(false, false, true);
            Document  docA      = new Document("1", null, null, null,
                                               new HashSet <Representative>()
            {
                new Representative(
                    Representative.FileType.Text,
                    new SortedDictionary <string, string>()
                {
                    { "1", "x:\\path\\1.txt" }
                }
                    )
            }
                                               );
            Document docB = new Document("1", null, null, null,
                                         new HashSet <Representative>()
            {
                new Representative(
                    Representative.FileType.Native,
                    new SortedDictionary <string, string>()
                {
                    { "1", "x:\\path\\file.ext" }
                }
                    )
            }
                                         );

            Assert.AreEqual(1, docA.Representatives.Count);
            docA = overlayer.Overlay(docA, docB);
            Assert.AreEqual(2, docA.Representatives.Count);

            foreach (var file in docA.Representatives)
            {
                if (file.Type.Equals(Representative.FileType.Native))
                {
                    Assert.AreEqual("x:\\path\\file.ext", file.Files.First().Value);
                }
                else
                {
                    Assert.AreEqual("x:\\path\\1.txt", file.Files.First().Value);
                }
            }
        }
        /// <summary>
        /// Adds a series of documents to the collection.
        /// </summary>
        /// <param name="documents">The documents to add to the collection.</param>
        public void AddRange(IEnumerable <Document> documents)
        {
            foreach (Document document in documents)
            {
                if (this.documentGlossary.ContainsKey(document.Key))
                {
                    Overlayer overlayer = new Overlayer(true, true, true);
                    Document  original  = this.documentGlossary[document.Key];
                    Document  newDoc    = overlayer.Overlay(original, document);
                    int       index     = this.documentList.BinarySearch(original);
                    this.documentList[index]            = newDoc;
                    this.documentGlossary[document.Key] = newDoc;
                }
                else
                {
                    this.documentList.Add(document);
                    this.documentGlossary.Add(document.Key, document);
                }
            }

            propertyReset();
        }