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); }
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 CreateDyntaxaRevisionReferenceRelation_WithValidData_ThenDyntaxaRevisionReferenceRelationIsCreated() { // Arrange const string relatedObjectGUID = "urn:lsid:dyntaxa.se:Taxon:6010174"; const string action = "Add"; const int revisionId = 1; WebDyntaxaRevisionReferenceRelation dyntaxaReferenceRelation, newDyntaxaReferenceRelation; dyntaxaReferenceRelation = WebDyntaxaReferenceRelationTestFactory.Create( revisionId, relatedObjectGUID, action); // Act // Create test Dyntaxa revision reference relation. dyntaxaReferenceRelation.ReferenceId = 3342; newDyntaxaReferenceRelation = DyntaxaManager.CreateDyntaxaRevisionReferenceRelation( GetRevisionContext(), dyntaxaReferenceRelation); // Assert Assert.IsNotNull(newDyntaxaReferenceRelation); Assert.AreNotEqual(dyntaxaReferenceRelation.Id, newDyntaxaReferenceRelation.Id); Assert.AreEqual(dyntaxaReferenceRelation.RelatedObjectGUID, newDyntaxaReferenceRelation.RelatedObjectGUID); Assert.AreEqual(3342, newDyntaxaReferenceRelation.ReferenceId); Assert.AreEqual(GetContext().GetUser().Id, newDyntaxaReferenceRelation.CreatedBy); }
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> /// Creates a dyntaxa revision reference relation.. /// </summary> /// <param name="clientInformation">Client information.</param> /// <param name="dyntaxaRevisionReferenceRelation">The dyntaxa revision reference relation.</param> /// <returns></returns> public WebDyntaxaRevisionReferenceRelation CreateDyntaxaRevisionReferenceRelation( WebClientInformation clientInformation, WebDyntaxaRevisionReferenceRelation dyntaxaRevisionReferenceRelation) { using (WebServiceContext context = new WebServiceContext(clientInformation)) { try { return(DyntaxaManager.CreateDyntaxaRevisionReferenceRelation(context, dyntaxaRevisionReferenceRelation)); } catch (Exception exception) { WebServiceData.LogManager.LogError(context, exception); throw; } } }
public void GetAllDyntaxaRevisionReferenceRelations_WhenReferenceRelationExists_ThenReferenceRelationIsReturned() { //Arrange List <WebDyntaxaRevisionReferenceRelation> referenceRelations; const int revisionId = 24; 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 referenceRelations = DyntaxaManager.GetAllDyntaxaRevisionReferenceRelations( GetRevisionContext(), revisionId); // Assert Assert.AreEqual(1, referenceRelations.Count); }
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); }
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()); }
public void GetDyntaxaRevisionReferenceRelationById_WhenDyntaxaRevisionReferenceRelationCreated_ThenCreatedRevisionReferenceRelationIsReturned() { // Arrange const int revisionId = 24; const string relatedObjectGUID = "urn:lsid:dyntaxa.se:Taxon:6010174"; const string action = "Add"; const int referenceId = 252; WebDyntaxaRevisionReferenceRelation dyntaxaReferenceRelation = WebDyntaxaReferenceRelationTestFactory.Create( revisionId, relatedObjectGUID, action); dyntaxaReferenceRelation.ReferenceId = referenceId; var newReferenceRelations = DyntaxaManager.CreateDyntaxaRevisionReferenceRelation( GetRevisionContext(), dyntaxaReferenceRelation); // Act WebDyntaxaRevisionReferenceRelation getReferenceRelations = DyntaxaManager.GetDyntaxaRevisionReferenceRelationById( GetRevisionContext(), newReferenceRelations.Id); // Assert Assert.IsNotNull(getReferenceRelations); Assert.AreEqual(relatedObjectGUID, getReferenceRelations.RelatedObjectGUID); Assert.AreEqual(action, getReferenceRelations.Action); Assert.AreEqual(referenceId, getReferenceRelations.ReferenceId); }
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); }
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); }