Exemplo n.º 1
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);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
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);
        }