コード例 #1
0
        public void TestModifyReferenceRelationAndThenModifyBackToOriginalStateInSameRevisionEventAndThenUndo()
        {
            // Consts
            const int    TestRevisionId  = 24;
            const string TestObjectGUID  = "urn:lsid:dyntaxa.se:Taxon:6010174";
            const int    TestReferenceId = 1030;

            // Step 1 - change original artfaktaReferenceRelation from TypeId = 1 to TypeId = 2
            WebTaxonRevisionEvent revisionEvent1 = DyntaxaManager.CreateCompleteRevisionEvent(GetRevisionContext(),
                                                                                              new WebTaxonRevisionEvent()
            {
                CreatedBy    = 2,
                CreatedDate  = DateTime.Now,
                TypeId       = 19,
                RevisionId   = TestRevisionId,
                AffectedTaxa = "Taxon' [6010174]",
                OldValue     = "Type='1",
                NewValue     = "Type='2"
            });
            WebDyntaxaRevisionReferenceRelation revisionReferenceRelationStep1 = DyntaxaManager.CreateDyntaxaRevisionReferenceRelation(
                GetRevisionContext(),
                WebDyntaxaReferenceRelationTestFactory.CreateModifyAction(
                    TestRevisionId,
                    revisionEvent1.Id,
                    TestObjectGUID,
                    TestReferenceId,
                    2,
                    1));

            // Step 2 - change from TypeId = 2 to TypeId = 1
            WebDyntaxaRevisionReferenceRelation revisionReferenceRelationStep2 = DyntaxaManager.CreateDyntaxaRevisionReferenceRelation(
                GetRevisionContext(),
                WebDyntaxaReferenceRelationTestFactory.CreateModifyAction(
                    TestRevisionId,
                    revisionEvent1.Id,
                    TestObjectGUID,
                    TestReferenceId,
                    1,
                    2));

            // Get reference relations for current revision and object GUID.
            List <WebDyntaxaRevisionReferenceRelation> referenceRelations =
                DyntaxaManager.GetDyntaxaRevisionReferenceRelation(
                    GetRevisionContext(),
                    TestRevisionId,
                    TestObjectGUID);

            Assert.AreEqual(1, referenceRelations.Count);
            Assert.AreEqual(1, referenceRelations[0].ReferenceType);


            // undo last revision event
            TaxonManager.DeleteTaxonRevisionEvent(GetRevisionContext(), revisionEvent1.Id);
            referenceRelations =
                DyntaxaManager.GetDyntaxaRevisionReferenceRelation(
                    GetRevisionContext(),
                    TestRevisionId,
                    TestObjectGUID);
            Assert.AreEqual(0, referenceRelations.Count);
        }
        public void GetDyntaxaRevisionReferenceRelation_WhenTwoReferenceRelationWithSameRelatedObjectGUIDExists_ThenTwoReferenceRelationIsReturned()
        {
            // Arrange
            const int    revisionId        = 24;
            const string relatedObjectGUID = "urn:lsid:dyntaxa.se:Taxon:6010174";
            const string rel1Action        = "Add";
            const string rel2Action        = "Delete";

            DyntaxaManager.CreateDyntaxaRevisionReferenceRelation(
                GetRevisionContext(),
                WebDyntaxaReferenceRelationTestFactory.Create(revisionId, relatedObjectGUID, rel1Action));
            DyntaxaManager.CreateDyntaxaRevisionReferenceRelation(
                GetRevisionContext(),
                WebDyntaxaReferenceRelationTestFactory.Create(revisionId, relatedObjectGUID, rel2Action));

            // Act
            var newReferenceRelations = DyntaxaManager.GetDyntaxaRevisionReferenceRelation(
                GetRevisionContext(), revisionId, relatedObjectGUID);

            // Assert
            Assert.IsNotNull(newReferenceRelations);
            Assert.AreEqual(2, newReferenceRelations.Count);
            Assert.AreEqual(rel1Action, newReferenceRelations[0].Action);
            Assert.AreEqual(rel2Action, newReferenceRelations[1].Action);
        }
コード例 #3
0
        public void TestAddTwoReferenceRelationsWithSameReferenceButDifferentType()
        {
            // Consts
            const int    TestRevisionId      = 24;
            const string TestObjectGUID      = "urn:lsid:dyntaxa.se:Taxon:6010174";
            const int    TestReferenceId3200 = 3200;

            // Arrange
            WebTaxonRevisionEvent revisionEvent1;

            // Act
            // Add new reference 3200 with type 1
            revisionEvent1 = DyntaxaManager.CreateCompleteRevisionEvent(GetRevisionContext(),
                                                                        new WebTaxonRevisionEvent()
            {
                CreatedBy    = 2,
                CreatedDate  = DateTime.Now,
                TypeId       = 19,
                RevisionId   = TestRevisionId,
                AffectedTaxa = "Taxon [6010174]",
                OldValue     = "NULL",
                NewValue     = "Reference3200, Type=1"
            });
            WebDyntaxaRevisionReferenceRelation revisionReferenceRelationStep1 = DyntaxaManager.CreateDyntaxaRevisionReferenceRelation(
                GetRevisionContext(),
                WebDyntaxaReferenceRelationTestFactory.CreateAddAction(
                    TestRevisionId,
                    revisionEvent1.Id,
                    TestObjectGUID,
                    TestReferenceId3200,
                    1));

            // Add new reference 3200 with type 2
            WebDyntaxaRevisionReferenceRelation revisionReferenceRelationStep2 = DyntaxaManager.CreateDyntaxaRevisionReferenceRelation(
                GetRevisionContext(),
                WebDyntaxaReferenceRelationTestFactory.CreateAddAction(
                    TestRevisionId,
                    revisionEvent1.Id,
                    TestObjectGUID,
                    TestReferenceId3200,
                    2));

            // Get reference relations for current revision and object GUID.
            List <WebDyntaxaRevisionReferenceRelation> referenceRelations =
                DyntaxaManager.GetDyntaxaRevisionReferenceRelation(
                    GetRevisionContext(),
                    TestRevisionId,
                    TestObjectGUID);

            Assert.AreEqual(2, referenceRelations.Count);
            Assert.AreEqual(TestReferenceId3200, referenceRelations[0].ReferenceId);
            Assert.AreEqual(1, referenceRelations[0].ReferenceType);
            Assert.AreEqual(TestReferenceId3200, referenceRelations[1].ReferenceId);
            Assert.AreEqual(2, referenceRelations[1].ReferenceType);
        }
 /// <summary>
 /// Get dyntaxa revision reference relation item(s).
 /// </summary>
 /// <param name="clientInformation">Client information.</param>
 /// <param name="revisionId">The revision identifier.</param>
 /// <param name="relatedObjectGUID">The related object unique identifier.</param>
 /// <returns>
 /// A List of WebDyntaxaRevisionReferenceRelation if any revision steps have been
 /// made for specified (revisionId,relatedObjectGUID); otherwise null.
 /// </returns>
 public List <WebDyntaxaRevisionReferenceRelation> GetDyntaxaRevisionReferenceRelation(
     WebClientInformation clientInformation,
     int revisionId,
     string relatedObjectGUID)
 {
     using (WebServiceContext context = new WebServiceContext(clientInformation))
     {
         try
         {
             return(DyntaxaManager.GetDyntaxaRevisionReferenceRelation(context, revisionId, relatedObjectGUID));
         }
         catch (Exception exception)
         {
             WebServiceData.LogManager.LogError(context, exception);
             throw;
         }
     }
 }
        public void GetDyntaxaRevisionReferenceRelation_WhenWrongRevisionId_ThenEmptyListIsReturned()
        {
            // Arrange
            const int    revisionId               = 24;
            const int    wrongRevisionId          = 25;
            const string relatedObjectGUID        = "urn:lsid:dyntaxa.se:Taxon:6010174";
            const string action                   = "Add";
            var          dyntaxaReferenceRelation = WebDyntaxaReferenceRelationTestFactory.Create(
                revisionId, relatedObjectGUID, action);

            DyntaxaManager.CreateDyntaxaRevisionReferenceRelation(GetRevisionContext(), dyntaxaReferenceRelation);

            // Act
            var newReferenceRelations = DyntaxaManager.GetDyntaxaRevisionReferenceRelation(
                GetRevisionContext(), wrongRevisionId, relatedObjectGUID);

            // Assert
            Assert.IsNotNull(newReferenceRelations);
            Assert.AreEqual(0, newReferenceRelations.Count);
        }
コード例 #6
0
        public void TestModifyReferenceRelationOneTime()
        {
            // Consts
            const int    TestRevisionId  = 24;
            const string TestObjectGUID  = "urn:lsid:dyntaxa.se:Taxon:6010174";
            const int    TestReferenceId = 1030;


            // Step 1 - change original artfaktaReferenceRelation from TypeId = 1 to TypeId = 2
            WebDyntaxaRevisionReferenceRelation revisionReferenceRelation = DyntaxaManager.CreateDyntaxaRevisionReferenceRelation(
                GetRevisionContext(),
                WebDyntaxaReferenceRelationTestFactory.CreateModifyAction(
                    TestRevisionId,
                    5000,
                    TestObjectGUID,
                    TestReferenceId,
                    2,
                    1));

            // Get reference relations for current revision and object GUID.
            List <WebDyntaxaRevisionReferenceRelation> referenceRelations =
                DyntaxaManager.GetDyntaxaRevisionReferenceRelation(
                    GetRevisionContext(),
                    TestRevisionId,
                    TestObjectGUID);

            Assert.AreEqual(1, referenceRelations.Count);
            Assert.AreEqual(2, referenceRelations[0].ReferenceType);

            // Test with character ' in GUID.
            referenceRelations =
                DyntaxaManager.GetDyntaxaRevisionReferenceRelation(
                    GetRevisionContext(),
                    TestRevisionId,
                    "urn:lsid:dyntaxa.se:Taxon:'6010174");
            Assert.IsTrue(referenceRelations.IsEmpty());
        }
コード例 #7
0
        public void TestDeleteReferenceAndThenAddItAgainAndThenUndo()
        {
            // Consts
            const int    TestRevisionId      = 24;
            const string TestObjectGUID      = "urn:lsid:dyntaxa.se:Taxon:6010174";
            const int    TestReferenceId3200 = 3200;

            WebTaxonRevisionEvent revisionEvent1;
            WebTaxonRevisionEvent revisionEvent2;

            // Act

            // Step 1 - Delete reference 3200, Type=2
            revisionEvent1 = DyntaxaManager.CreateCompleteRevisionEvent(GetRevisionContext(),
                                                                        new WebTaxonRevisionEvent()
            {
                CreatedBy    = 2,
                CreatedDate  = DateTime.Now,
                TypeId       = 19,
                RevisionId   = TestRevisionId,
                AffectedTaxa = "Taxon [6010174]",
                OldValue     = "Ref3200,Typ1",
                NewValue     = "Deleted"
            });
            WebDyntaxaRevisionReferenceRelation revisionReferenceRelationStep1 = DyntaxaManager.CreateDyntaxaRevisionReferenceRelation(
                GetRevisionContext(),
                WebDyntaxaReferenceRelationTestFactory.CreateDeleteAction(
                    TestRevisionId,
                    revisionEvent1.Id,
                    TestObjectGUID,
                    TestReferenceId3200,
                    2,
                    2));

            // Get reference relations for current revision and object GUID.
            List <WebDyntaxaRevisionReferenceRelation> referenceRelations =
                DyntaxaManager.GetDyntaxaRevisionReferenceRelation(
                    GetRevisionContext(),
                    TestRevisionId,
                    TestObjectGUID);

            Assert.AreEqual(1, referenceRelations.Count);
            Assert.AreEqual(TestReferenceId3200, referenceRelations[0].ReferenceId);
            Assert.AreEqual("Delete", referenceRelations[0].Action);


            // Step 2 - Add reference 3200, Type=1
            revisionEvent2 = DyntaxaManager.CreateCompleteRevisionEvent(GetRevisionContext(),
                                                                        new WebTaxonRevisionEvent()
            {
                CreatedBy    = 2,
                CreatedDate  = DateTime.Now,
                TypeId       = 19,
                RevisionId   = TestRevisionId,
                AffectedTaxa = "Taxon [6010174]",
                OldValue     = "Deleted",
                NewValue     = "Ref3200"
            });
            WebDyntaxaRevisionReferenceRelation revisionReferenceRelationStep2 = DyntaxaManager.CreateDyntaxaRevisionReferenceRelation(
                GetRevisionContext(),
                WebDyntaxaReferenceRelationTestFactory.CreateAddAction(
                    TestRevisionId,
                    revisionEvent2.Id,
                    TestObjectGUID,
                    TestReferenceId3200,
                    2));

            // Get reference relations for current revision and object GUID.
            referenceRelations =
                DyntaxaManager.GetDyntaxaRevisionReferenceRelation(
                    GetRevisionContext(),
                    TestRevisionId,
                    TestObjectGUID);
            Assert.AreEqual(1, referenceRelations.Count);
            Assert.AreEqual(TestReferenceId3200, referenceRelations[0].ReferenceId);
            Assert.AreEqual("Add", referenceRelations[0].Action);
        }
コード例 #8
0
        public void TestAddTwoReferenceRelationsToOneObjectGUIDAndThenModifyTypeOfOneOfTheReferences()
        {
            // Consts
            const int    TestRevisionId      = 24;
            const string TestObjectGUID      = "urn:lsid:dyntaxa.se:Taxon:6010174";
            const int    TestReferenceId3200 = 3200;
            const int    TestReferenceId1500 = 1500;

            // Arrange
            WebTaxonRevisionEvent revisionEvent1;
            WebTaxonRevisionEvent revisionEvent2;

            // Act
            // Add new reference 3200 with type 2
            revisionEvent1 = DyntaxaManager.CreateCompleteRevisionEvent(GetRevisionContext(),
                                                                        new WebTaxonRevisionEvent()
            {
                CreatedBy    = 2,
                CreatedDate  = DateTime.Now,
                TypeId       = 19,
                RevisionId   = TestRevisionId,
                AffectedTaxa = "Taxon [6010174]",
                OldValue     = "NULL",
                NewValue     = "Reference3200"
            });
            WebDyntaxaRevisionReferenceRelation revisionReferenceRelationStep1 = DyntaxaManager.CreateDyntaxaRevisionReferenceRelation(
                GetRevisionContext(),
                WebDyntaxaReferenceRelationTestFactory.CreateAddAction(
                    TestRevisionId,
                    revisionEvent1.Id,
                    TestObjectGUID,
                    TestReferenceId3200,
                    2));

            // Add new reference 1500 with type 1
            WebDyntaxaRevisionReferenceRelation revisionReferenceRelationStep2 = DyntaxaManager.CreateDyntaxaRevisionReferenceRelation(
                GetRevisionContext(),
                WebDyntaxaReferenceRelationTestFactory.CreateAddAction(
                    TestRevisionId,
                    revisionEvent1.Id,
                    TestObjectGUID,
                    TestReferenceId1500,
                    1));

            // Get reference relations for current revision and object GUID.
            List <WebDyntaxaRevisionReferenceRelation> referenceRelations =
                DyntaxaManager.GetDyntaxaRevisionReferenceRelation(
                    GetRevisionContext(),
                    TestRevisionId,
                    TestObjectGUID);

            Assert.AreEqual(2, referenceRelations.Count);
            Assert.AreEqual(TestReferenceId3200, referenceRelations[0].ReferenceId);
            Assert.AreEqual(2, referenceRelations[0].ReferenceType);
            Assert.AreEqual(TestReferenceId1500, referenceRelations[1].ReferenceId);



            // Change type of Reference 3200 to type 1
            revisionEvent2 = DyntaxaManager.CreateCompleteRevisionEvent(GetRevisionContext(),
                                                                        new WebTaxonRevisionEvent()
            {
                CreatedBy    = 2,
                CreatedDate  = DateTime.Now,
                TypeId       = 19,
                RevisionId   = TestRevisionId,
                AffectedTaxa = "Taxon [6010174]",
                OldValue     = "Type=2",
                NewValue     = "Type=1"
            });
            // Add eller Modify?
            //WebDyntaxaRevisionReferenceRelation revisionReferenceRelationStep3 = DyntaxaManager.CreateDyntaxaRevisionReferenceRelation(
            //    GetRevisionContext(),
            //    WebDyntaxaReferenceRelationTestFactory.CreateAddAction(
            //        TestRevisionId,
            //        revisionEvent2.Id,
            //        TestObjectGUID,
            //        TestReferenceId3200,
            //        1));
            WebDyntaxaRevisionReferenceRelation revisionReferenceRelationStep3 = DyntaxaManager.CreateDyntaxaRevisionReferenceRelation(
                GetRevisionContext(),
                WebDyntaxaReferenceRelationTestFactory.CreateModifyAction(
                    TestRevisionId,
                    revisionEvent2.Id,
                    TestObjectGUID,
                    TestReferenceId3200,
                    1,
                    2)); // 2 eller null?

            // Get reference relations for current revision and object GUID.
            referenceRelations =
                DyntaxaManager.GetDyntaxaRevisionReferenceRelation(
                    GetRevisionContext(),
                    TestRevisionId,
                    TestObjectGUID);

            Assert.AreEqual(2, referenceRelations.Count);
            Assert.AreEqual(TestReferenceId1500, referenceRelations[0].ReferenceId);
            Assert.AreEqual(TestReferenceId3200, referenceRelations[1].ReferenceId);
            Assert.AreEqual(1, referenceRelations[1].ReferenceType);



            // undo last revision event
            TaxonManager.DeleteTaxonRevisionEvent(GetRevisionContext(), revisionEvent2.Id);
            referenceRelations =
                DyntaxaManager.GetDyntaxaRevisionReferenceRelation(
                    GetRevisionContext(),
                    TestRevisionId,
                    TestObjectGUID);
            Assert.AreEqual(2, referenceRelations[0].ReferenceType);

            // Get reference relations for current revision and object GUID.
            referenceRelations =
                DyntaxaManager.GetDyntaxaRevisionReferenceRelation(
                    GetRevisionContext(),
                    TestRevisionId,
                    TestObjectGUID);

            Assert.AreEqual(2, referenceRelations.Count);
            Assert.AreEqual(TestReferenceId3200, referenceRelations[0].ReferenceId);
            Assert.AreEqual(2, referenceRelations[0].ReferenceType);
            Assert.AreEqual(TestReferenceId1500, referenceRelations[1].ReferenceId);

            // undo last revision event once more
            TaxonManager.DeleteTaxonRevisionEvent(GetRevisionContext(), revisionEvent1.Id);
            referenceRelations =
                DyntaxaManager.GetDyntaxaRevisionReferenceRelation(
                    GetRevisionContext(),
                    TestRevisionId,
                    TestObjectGUID);
            Assert.AreEqual(0, referenceRelations.Count);
        }