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