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)); }
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)); }