예제 #1
0
        public void Test_Topology_Binary_Merge()
        {
            var p1  = ExternalPractitionerTests.TestHelper.CreatePractitioner("A", "1");
            var cp1 = TestHelper.AddContactPoint(p1, "cp1", "cp1");
            var cp2 = TestHelper.AddContactPoint(p1, "cp2", "cp2");
            var cp3 = TestHelper.AddContactPoint(p1, "cp3", "cp3");
            var cp4 = TestHelper.AddContactPoint(p1, "cp4", "cp4");

            // Perform Merge cp1+cp2->cp12, cp3+cp4->cp34, cp12+cp34->ultimateDest
            var cp12         = TestHelper.SimpleMerge(cp1, cp2);
            var cp34         = TestHelper.SimpleMerge(cp3, cp4);
            var ultimateDest = TestHelper.SimpleMerge(cp12, cp34);

            // Verifying all contact points are ultimately merged into the right one
            Assert.AreEqual(cp1.MergedInto, cp12);
            Assert.AreEqual(cp2.MergedInto, cp12);
            Assert.AreEqual(cp3.MergedInto, cp34);
            Assert.AreEqual(cp4.MergedInto, cp34);
            Assert.AreEqual(cp12.MergedInto, ultimateDest);
            Assert.AreEqual(cp34.MergedInto, ultimateDest);
            Assert.IsNull(ultimateDest.MergedInto);

            // Verifying all contact points are ultimately merged into the right one
            Assert.AreEqual(cp1.GetUltimateMergeDestination(), ultimateDest);
            Assert.AreEqual(cp2.GetUltimateMergeDestination(), ultimateDest);
            Assert.AreEqual(cp3.GetUltimateMergeDestination(), ultimateDest);
            Assert.AreEqual(cp4.GetUltimateMergeDestination(), ultimateDest);
            Assert.AreEqual(cp12.GetUltimateMergeDestination(), ultimateDest);
            Assert.AreEqual(cp34.GetUltimateMergeDestination(), ultimateDest);
            Assert.AreEqual(ultimateDest.GetUltimateMergeDestination(), ultimateDest);
        }
예제 #2
0
        public void Test_Merged_ContactPoint_Collection_Properties()
        {
            var p1 = ExternalPractitionerTests.TestHelper.CreatePractitioner("A", "1");

            var cp1 = TestHelper.AddContactPoint(p1, "cp1", "cp1");
            var a1  = TestHelper.AddAddress(cp1, "Toronto", "ON");
            var t1  = TestHelper.AddTelephoneNumber(cp1, "416", "1111111");
            var e1  = TestHelper.AddEmailAddress(cp1, "*****@*****.**");

            var cp2 = TestHelper.AddContactPoint(p1, "cp2", "cp2");
            var a2  = TestHelper.AddAddress(cp2, "Mississauga", "ON");
            var t2  = TestHelper.AddTelephoneNumber(cp1, "905", "2222222");
            var e2  = TestHelper.AddEmailAddress(cp1, "*****@*****.**");

            // perform the merge, and get reference to all collections under result
            var result    = TestHelper.SimpleMerge(cp1, cp2);
            var result_a1 = CollectionUtils.SelectFirst(result.Addresses, a => a.IsSameAddress(a1));
            var result_a2 = CollectionUtils.SelectFirst(result.Addresses, a => a.IsSameAddress(a2));
            var result_t1 = CollectionUtils.SelectFirst(result.TelephoneNumbers, t => t.IsSameNumber(t1));
            var result_t2 = CollectionUtils.SelectFirst(result.TelephoneNumbers, t => t.IsSameNumber(t2));
            var result_e1 = CollectionUtils.SelectFirst(result.EmailAddresses, e => e.IsSameEmailAddress(e1));
            var result_e2 = CollectionUtils.SelectFirst(result.EmailAddresses, e => e.IsSameEmailAddress(e2));

            // Verifying all the collection exists
            Assert.AreEqual(result.Addresses.Count, 2);
            Assert.AreEqual(result.TelephoneNumbers.Count, 2);
            Assert.AreEqual(result.EmailAddresses.Count, 2);
            Assert.IsNotNull(result_a1);
            Assert.IsNotNull(result_a2);
            Assert.IsNotNull(result_t1);
            Assert.IsNotNull(result_t2);
            Assert.IsNotNull(result_e1);
            Assert.IsNotNull(result_e2);
        }
예제 #3
0
        public void Test_Merge_ContactPoints_With_Different_Practitioners()
        {
            var p1  = ExternalPractitionerTests.TestHelper.CreatePractitioner("A", "1");
            var p2  = ExternalPractitionerTests.TestHelper.CreatePractitioner("B", "2");
            var cp1 = TestHelper.AddContactPoint(p1, "cp1", "cp1");
            var cp2 = TestHelper.AddContactPoint(p2, "cp2", "cp2");

            TestHelper.SimpleMerge(cp1, cp2);
        }
예제 #4
0
        public void Test_Circular_Merge()
        {
            var p1  = ExternalPractitionerTests.TestHelper.CreatePractitioner("A", "1");
            var cp1 = TestHelper.AddContactPoint(p1, "cp1", "cp1");
            var cp2 = TestHelper.AddContactPoint(p1, "cp2", "cp2");

            var cp12 = TestHelper.SimpleMerge(cp1, cp2);

            TestHelper.SimpleMerge(cp12, cp1);             // Merge back with cp1
        }
예제 #5
0
        public void Test_Merge_Same_ContactPoint()
        {
            var p1  = ExternalPractitionerTests.TestHelper.CreatePractitioner("A", "1");
            var cp1 = TestHelper.AddContactPoint(p1, "cp1", "cp1");

            Assert.IsFalse(cp1.IsMerged);
            Assert.IsFalse(cp1.Deactivated);

            TestHelper.SimpleMerge(cp1, cp1);
        }
예제 #6
0
        public void Test_Merged_ContactPoint_Basic_Properties()
        {
            var p1     = ExternalPractitionerTests.TestHelper.CreatePractitioner("A", "1");
            var cp1    = TestHelper.AddContactPoint(p1, "cp1", "cp1");
            var cp2    = TestHelper.AddContactPoint(p1, "cp2", "cp2");
            var result = TestHelper.SimpleMerge(cp1, cp2);

            Assert.AreEqual(result.Name, cp2.Name);
            Assert.AreEqual(result.Description, cp2.Description);
            Assert.AreEqual(result.PreferredResultCommunicationMode, cp2.PreferredResultCommunicationMode);
        }
예제 #7
0
        public void Test_Deactivate_NotMerged_ContactPoint()
        {
            var p1  = ExternalPractitionerTests.TestHelper.CreatePractitioner("A", "1");
            var cp1 = TestHelper.AddContactPoint(p1, "cp1", "cp1");

            Assert.IsFalse(cp1.IsMerged);
            Assert.IsFalse(cp1.Deactivated);

            cp1.MarkDeactivated(true);
            Assert.IsTrue(cp1.Deactivated);
        }
예제 #8
0
        public void Test_Merge_ContactPoints_Practitioner_Edited()
        {
            var p1  = ExternalPractitionerTests.TestHelper.CreatePractitioner("A", "1");
            var cp1 = TestHelper.AddContactPoint(p1, "cp1", "cp1");
            var cp2 = TestHelper.AddContactPoint(p1, "cp2", "cp2");

            Assert.IsNull(p1.LastEditedTime);

            TestHelper.SimpleMerge(cp1, cp2);

            Assert.IsNotNull(p1.LastEditedTime);
        }
예제 #9
0
        public void Test_Merge_Merged_ContactPoints_Right()
        {
            var p1  = ExternalPractitionerTests.TestHelper.CreatePractitioner("A", "1");
            var cp1 = TestHelper.AddContactPoint(p1, "cp1", "cp1");
            var cp2 = TestHelper.AddContactPoint(p1, "cp2", "cp2");
            var cp3 = TestHelper.AddContactPoint(p1, "cp3", "cp3");

            cp2.SetMergedInto(cp3);
            Assert.IsFalse(cp1.IsMerged);
            Assert.IsTrue(cp2.IsMerged);             // Right is aleady merged

            TestHelper.SimpleMerge(cp1, cp2);
        }
예제 #10
0
        public void Test_Merge_Deactivated_ContactPoints_Right()
        {
            var p1  = ExternalPractitionerTests.TestHelper.CreatePractitioner("A", "1");
            var cp1 = TestHelper.AddContactPoint(p1, "cp1", "cp1");
            var cp2 = TestHelper.AddContactPoint(p1, "cp2", "cp2");

            cp2.MarkDeactivated(true);
            Assert.IsFalse(cp1.IsMerged);
            Assert.IsFalse(cp1.Deactivated);
            Assert.IsFalse(cp2.IsMerged);
            Assert.IsTrue(cp2.Deactivated);             // Right is deactivated

            TestHelper.SimpleMerge(cp1, cp2);
        }
예제 #11
0
        public void Test_Merged_ContactPoint_Deactivated()
        {
            var p1  = ExternalPractitionerTests.TestHelper.CreatePractitioner("A", "1");
            var cp1 = TestHelper.AddContactPoint(p1, "cp1", "cp1");
            var cp2 = TestHelper.AddContactPoint(p1, "cp2", "cp2");

            Assert.IsFalse(cp1.Deactivated);
            Assert.IsFalse(cp1.Deactivated);

            var result = TestHelper.SimpleMerge(cp1, cp2);

            Assert.IsTrue(cp1.Deactivated);
            Assert.IsTrue(cp2.Deactivated);
            Assert.IsFalse(result.Deactivated);             // result is not deactivated
        }
예제 #12
0
        public void Test_Merge_Default_ContactPoints()
        {
            var p1  = ExternalPractitionerTests.TestHelper.CreatePractitioner("A", "1");
            var cp1 = TestHelper.AddContactPoint(p1, "cp1", "cp1");
            var cp2 = TestHelper.AddContactPoint(p1, "cp2", "cp2");
            var cp3 = TestHelper.AddContactPoint(p1, "cp3", "cp3");

            Assert.IsTrue(cp1.IsDefaultContactPoint);
            Assert.IsFalse(cp2.IsDefaultContactPoint);
            Assert.IsFalse(cp3.IsDefaultContactPoint);

            // Merge cp1, which is a default cp
            var result = TestHelper.SimpleMerge(cp1, cp2);

            Assert.IsFalse(cp1.IsDefaultContactPoint);
            Assert.IsFalse(cp2.IsDefaultContactPoint);
            Assert.IsFalse(cp3.IsDefaultContactPoint);
            Assert.IsTrue(result.IsDefaultContactPoint);             // result is a default
        }
예제 #13
0
        public void Test_Merge_NonDefault_Contact_Points()
        {
            var p1  = ExternalPractitionerTests.TestHelper.CreatePractitioner("A", "1");
            var cp1 = TestHelper.AddContactPoint(p1, "cp1", "cp1");
            var cp2 = TestHelper.AddContactPoint(p1, "cp2", "cp2");
            var cp3 = TestHelper.AddContactPoint(p1, "cp3", "cp3");

            Assert.IsTrue(cp1.IsDefaultContactPoint);
            Assert.IsFalse(cp2.IsDefaultContactPoint);
            Assert.IsFalse(cp3.IsDefaultContactPoint);

            // Merge non-default cp
            var result = TestHelper.SimpleMerge(cp2, cp3);

            Assert.IsTrue(cp1.IsDefaultContactPoint);             // cp1 remain a default
            Assert.IsFalse(cp2.IsDefaultContactPoint);
            Assert.IsFalse(cp3.IsDefaultContactPoint);
            Assert.IsFalse(result.IsDefaultContactPoint);
        }
예제 #14
0
        public void Test_Activate_Merged_ContactPoint()
        {
            var p1  = ExternalPractitionerTests.TestHelper.CreatePractitioner("A", "1");
            var cp1 = TestHelper.AddContactPoint(p1, "cp1", "cp1");
            var cp2 = TestHelper.AddContactPoint(p1, "cp2", "cp2");

            Assert.IsFalse(cp1.IsMerged);
            Assert.IsFalse(cp1.Deactivated);
            Assert.IsFalse(cp2.IsMerged);
            Assert.IsFalse(cp2.Deactivated);

            TestHelper.SimpleMerge(cp1, cp2);

            Assert.IsTrue(cp1.IsMerged);
            Assert.IsTrue(cp1.Deactivated);
            Assert.IsTrue(cp2.IsMerged);
            Assert.IsTrue(cp2.Deactivated);

            // Activated merged/deactivated cp
            cp1.MarkDeactivated(false);
            cp2.MarkDeactivated(false);
        }