コード例 #1
0
        public void DatabaseGenerator_UnchangedMiddleReference()
        {
            var aold = SimpleCi.CreateApplication("a", "old");
            var b1   = ReferencingCi.CreateApplication("b", aold);
            var c1   = ReferenceToReferencingCi.CreateApplication("c", b1);
            var anew = SimpleCi.CreateApplication("a", "new");
            var b2   = ReferencingCi.CreateApplication("b", anew);
            var c2   = ReferenceToReferencingCi.CreateApplication("c", b2);

            var oldApplications = new List <ConceptApplication> {
                aold, c1
            };                                                               // A and C have database generator implementations, but B doesn't.
            var newApplications = new List <NewConceptApplication> {
                c2, anew
            };

            List <ConceptApplication>    toBeRemoved;
            List <NewConceptApplication> toBeInserted;

            TestDatabaseGenerator(oldApplications, newApplications, out toBeRemoved, out toBeInserted);

            Assert.AreEqual(2, toBeRemoved.Count);
            Assert.IsTrue(toBeRemoved.IndexOf(c1) < toBeRemoved.IndexOf(aold));
            Assert.AreEqual(2, toBeInserted.Count);
            Assert.IsTrue(toBeInserted.IndexOf(anew) < toBeInserted.IndexOf(c2));
        }
コード例 #2
0
        public void DatabaseGenerator_MustRecreateDependentConceptInCorrectOrder()
        {
            var simpleV1         = SimpleCi.CreateApplication("v1");
            var simpleV2         = SimpleCi.CreateApplication("v2");
            var dependent        = ReferencingCi.CreateApplication("", simpleV1);
            var secondReference1 = ReferenceToReferencingCi.CreateApplication("1", dependent);
            var secondReference2 = ReferenceToReferencingCi.CreateApplication("2", dependent);

            var oldApplications = new List <ConceptApplication> {
                simpleV1, dependent, secondReference1
            };
            var newApplications = new List <NewConceptApplication> {
                simpleV2, dependent, secondReference2
            };

            List <ConceptApplication>    toBeRemoved;
            List <NewConceptApplication> toBeInserted;

            TestDatabaseGenerator(oldApplications, newApplications, out toBeRemoved, out toBeInserted);

            Assert.AreEqual(3, toBeRemoved.Count);
            Assert.IsTrue(toBeRemoved.IndexOf(dependent) < toBeRemoved.IndexOf(simpleV1));
            Assert.IsTrue(toBeRemoved.IndexOf(secondReference1) < toBeRemoved.IndexOf(dependent));
            Assert.AreEqual(3, toBeInserted.Count);
            Assert.IsTrue(toBeInserted.IndexOf(dependent) > toBeInserted.IndexOf(simpleV2));
            Assert.IsTrue(toBeInserted.IndexOf(secondReference2) > toBeInserted.IndexOf(dependent));
        }
コード例 #3
0
        public void DatabaseGenerator_RecreatedDependentConceptReferencesNewVersion()
        {
            var simpleV1             = SimpleCi.CreateApplication("name", "v1", "data1");
            var simpleV2             = SimpleCi.CreateApplication("name", "v2", "data2");
            var dependentV1Unchanged = ReferencingCi.CreateApplication("", simpleV1);
            var dependentV2Unchanged = ReferencingCi.CreateApplication("", simpleV2);

            Assert.IsTrue(dependentV1Unchanged.GetConceptApplicationKey().Equals(dependentV2Unchanged.GetConceptApplicationKey()), "Test initialization: Dependent concept has not changed, the referenced concept has changed (different concept key).");

            var oldApplications = new List <ConceptApplication> {
                simpleV1, dependentV1Unchanged
            };
            var newApplications = new List <NewConceptApplication> {
                simpleV2, dependentV2Unchanged
            };

            List <ConceptApplication>    toBeRemoved;
            List <NewConceptApplication> toBeInserted;

            TestDatabaseGenerator(oldApplications, newApplications, out toBeRemoved, out toBeInserted);

            var removedReferencing  = (ReferencingCi)toBeRemoved.Select(ca => ((NewConceptApplication)ca).ConceptInfo).First(ci => ci is ReferencingCi);
            var insertedReferencing = (ReferencingCi)toBeInserted.Select(ca => ca.ConceptInfo).First(ci => ci is ReferencingCi);

            Assert.AreEqual("data1", removedReferencing.Reference.Data, "Removed reference should point to old version of changed concept.");
            Assert.AreEqual("data2", insertedReferencing.Reference.Data, "Inserted reference should point to new version of changed concept.");
        }
コード例 #4
0
        public void DatabaseGenerator_MustRecreateDependentConceptWhereBaseIsCreatedAndDeletedWithSameKey()
        {
            var simpleC1             = SimpleCi.CreateApplication("same", new SimpleConceptImplementation());
            var simpleC2             = SimpleCi.CreateApplication("same", new DependentConceptImplementation());
            var dependentC1Unchanged = ReferencingCi.CreateApplication("", simpleC1);
            var dependentC2Unchanged = ReferencingCi.CreateApplication("", simpleC2);

            Assert.IsTrue(dependentC1Unchanged.GetConceptApplicationKey().Equals(dependentC2Unchanged.GetConceptApplicationKey()), "Test initialization: Dependent concept has not changed, the referenced concept has changed (different implementation, same concept key).");

            var oldApplications = new List <ConceptApplication> {
                simpleC1, dependentC1Unchanged
            };
            var newApplications = new List <NewConceptApplication> {
                simpleC2, dependentC2Unchanged
            };

            List <ConceptApplication>    toBeRemoved;
            List <NewConceptApplication> toBeInserted;

            TestDatabaseGenerator(oldApplications, newApplications, out toBeRemoved, out toBeInserted);

            Assert.AreEqual(2, toBeRemoved.Count);
            Assert.IsTrue(toBeRemoved.Contains(simpleC1));
            Assert.IsTrue(toBeRemoved.Contains(dependentC1Unchanged));
            Assert.AreEqual(2, toBeInserted.Count);
            Assert.IsTrue(toBeInserted.Contains(simpleC2));
            Assert.IsTrue(toBeInserted.Contains(dependentC2Unchanged));

            var removedReferencing  = toBeRemoved.Select(ca => ((NewConceptApplication)ca).ConceptInfo).OfType <ReferencingCi>().Single();
            var insertedReferencing = toBeInserted.Select(ca => ca.ConceptInfo).OfType <ReferencingCi>().Single();

            Assert.AreNotSame(simpleC1.ConceptInfo, simpleC2.ConceptInfo);
            Assert.AreSame(simpleC1.ConceptInfo, removedReferencing.Reference, "Removed reference should point to old version of changed concept.");
            Assert.AreSame(simpleC2.ConceptInfo, insertedReferencing.Reference, "Inserted reference should point to new version of changed concept.");
        }
コード例 #5
0
        public void DatabaseGenerator_MustRecreateDependentConcept()
        {
            var simpleV1  = SimpleCi.CreateApplication("v1");
            var simpleV2  = SimpleCi.CreateApplication("v2");
            var dependent = ReferencingCi.CreateApplication("", simpleV1);

            var oldApplications = new List <ConceptApplication> {
                simpleV1, dependent
            };
            var newApplications = new List <NewConceptApplication> {
                simpleV2, dependent
            };

            List <ConceptApplication>    toBeRemoved;
            List <NewConceptApplication> toBeInserted;

            TestDatabaseGenerator(oldApplications, newApplications, out toBeRemoved, out toBeInserted);

            Assert.AreEqual(2, toBeRemoved.Count);
            Assert.IsTrue(toBeRemoved.Contains(simpleV1));
            Assert.IsTrue(toBeRemoved.Contains(dependent));
            Assert.AreEqual(2, toBeInserted.Count);
            Assert.IsTrue(toBeInserted.Contains(simpleV2));
            Assert.IsTrue(toBeInserted.Contains(dependent));
        }