public void GetDyntaxaRevisionSpeciesFact_WhenDyntaxaRevisionSpeciesFactCreatedWithSpeciesFactExistsData_ThenCreatedRevisionSpeciesFactIsReturned() { WebDyntaxaRevisionSpeciesFact dyntaxaRevisionSpeciesFact, newDyntaxaRevisionSpeciesFact, getDyntaxaRevisionSpeciesFact; // Create test Dyntaxa revision species fact. dyntaxaRevisionSpeciesFact = WebDyntaxaSpeciesFactTestFactory.Create((Int32)TaxonId.Bear); const int STATUS_ID = 400; dyntaxaRevisionSpeciesFact.StatusId = STATUS_ID; dyntaxaRevisionSpeciesFact.SpeciesFactExists = true; dyntaxaRevisionSpeciesFact.OriginalStatusId = 380; dyntaxaRevisionSpeciesFact.OriginalQualityId = 150; dyntaxaRevisionSpeciesFact.OriginalReferenceId = 250; dyntaxaRevisionSpeciesFact.OriginalDescription = "test"; newDyntaxaRevisionSpeciesFact = DyntaxaManager.CreateDyntaxaRevisionSpeciesFact(GetRevisionContext(), dyntaxaRevisionSpeciesFact); getDyntaxaRevisionSpeciesFact = DyntaxaManager.GetDyntaxaRevisionSpeciesFact(GetRevisionContext(), dyntaxaRevisionSpeciesFact.FactorId, dyntaxaRevisionSpeciesFact.TaxonId, dyntaxaRevisionSpeciesFact.RevisionId); Assert.IsNotNull(getDyntaxaRevisionSpeciesFact); Assert.AreEqual(STATUS_ID, getDyntaxaRevisionSpeciesFact.StatusId); Assert.IsTrue(dyntaxaRevisionSpeciesFact.SpeciesFactExists); Assert.AreEqual(380, dyntaxaRevisionSpeciesFact.OriginalStatusId); Assert.AreEqual(150, dyntaxaRevisionSpeciesFact.OriginalQualityId); Assert.AreEqual(250, dyntaxaRevisionSpeciesFact.OriginalReferenceId); Assert.AreEqual("test", dyntaxaRevisionSpeciesFact.OriginalDescription); }
public void CreateDyntaxaRevisionSpeciesFact_WithSpeciesFactStatusNullData_ThenDyntaxaRevisionSpeciesFactIsCreated() { WebDyntaxaRevisionSpeciesFact dyntaxaRevisionSpeciesFact, newDyntaxaRevisionSpeciesFact; // Create test Dyntaxa revision species fact. dyntaxaRevisionSpeciesFact = WebDyntaxaSpeciesFactTestFactory.Create((Int32)TaxonId.Bear); const int STATUS_ID = 400; dyntaxaRevisionSpeciesFact.StatusId = STATUS_ID; dyntaxaRevisionSpeciesFact.StatusId = null; dyntaxaRevisionSpeciesFact.QualityId = null; dyntaxaRevisionSpeciesFact.ReferenceId = null; dyntaxaRevisionSpeciesFact.SpeciesFactExists = true; dyntaxaRevisionSpeciesFact.OriginalStatusId = STATUS_ID; dyntaxaRevisionSpeciesFact.OriginalQualityId = 10; dyntaxaRevisionSpeciesFact.OriginalReferenceId = 23; dyntaxaRevisionSpeciesFact.OriginalDescription = "test"; newDyntaxaRevisionSpeciesFact = DyntaxaManager.CreateDyntaxaRevisionSpeciesFact(GetRevisionContext(), dyntaxaRevisionSpeciesFact); Assert.IsNotNull(newDyntaxaRevisionSpeciesFact); Assert.IsTrue(dyntaxaRevisionSpeciesFact.SpeciesFactExists); Assert.IsNull(dyntaxaRevisionSpeciesFact.StatusId); Assert.AreNotEqual(dyntaxaRevisionSpeciesFact.Id, newDyntaxaRevisionSpeciesFact.Id); Assert.AreEqual(dyntaxaRevisionSpeciesFact.Description, newDyntaxaRevisionSpeciesFact.Description); Assert.AreEqual(STATUS_ID, newDyntaxaRevisionSpeciesFact.OriginalStatusId); Assert.AreEqual(GetContext().GetUser().Id, newDyntaxaRevisionSpeciesFact.CreatedBy); }
public void CreateDyntaxaRevisionSpeciesFact_WithValidData_ThenDyntaxaRevisionSpeciesFactIsCreated() { WebDyntaxaRevisionSpeciesFact dyntaxaRevisionSpeciesFact, newDyntaxaRevisionSpeciesFact; // Create test Dyntaxa revision species fact. dyntaxaRevisionSpeciesFact = WebDyntaxaSpeciesFactTestFactory.Create((Int32)TaxonId.Bear); const int STATUS_ID = 400; dyntaxaRevisionSpeciesFact.StatusId = STATUS_ID; newDyntaxaRevisionSpeciesFact = DyntaxaManager.CreateDyntaxaRevisionSpeciesFact(GetRevisionContext(), dyntaxaRevisionSpeciesFact); Assert.IsNotNull(newDyntaxaRevisionSpeciesFact); Assert.IsFalse(dyntaxaRevisionSpeciesFact.SpeciesFactExists); Assert.IsNull(dyntaxaRevisionSpeciesFact.OriginalStatusId); Assert.AreNotEqual(dyntaxaRevisionSpeciesFact.Id, newDyntaxaRevisionSpeciesFact.Id); Assert.AreEqual(dyntaxaRevisionSpeciesFact.Description, newDyntaxaRevisionSpeciesFact.Description); Assert.AreEqual(STATUS_ID, newDyntaxaRevisionSpeciesFact.StatusId); Assert.AreEqual(GetContext().GetUser().Id, newDyntaxaRevisionSpeciesFact.CreatedBy); dyntaxaRevisionSpeciesFact = WebDyntaxaSpeciesFactTestFactory.Create((Int32)TaxonId.Wolf); dyntaxaRevisionSpeciesFact.Description = "Foo'Bar"; dyntaxaRevisionSpeciesFact.StatusId = STATUS_ID; newDyntaxaRevisionSpeciesFact = DyntaxaManager.CreateDyntaxaRevisionSpeciesFact(GetRevisionContext(), dyntaxaRevisionSpeciesFact); Assert.IsNotNull(newDyntaxaRevisionSpeciesFact); Assert.IsFalse(dyntaxaRevisionSpeciesFact.SpeciesFactExists); Assert.IsNull(dyntaxaRevisionSpeciesFact.OriginalStatusId); Assert.AreNotEqual(dyntaxaRevisionSpeciesFact.Id, newDyntaxaRevisionSpeciesFact.Id); Assert.AreEqual("Foo'Bar", newDyntaxaRevisionSpeciesFact.Description); Assert.AreEqual(STATUS_ID, newDyntaxaRevisionSpeciesFact.StatusId); Assert.AreEqual(GetContext().GetUser().Id, newDyntaxaRevisionSpeciesFact.CreatedBy); dyntaxaRevisionSpeciesFact = WebDyntaxaSpeciesFactTestFactory.Create((Int32)TaxonId.Wolverine); dyntaxaRevisionSpeciesFact.OriginalDescription = "Foo'Bar"; dyntaxaRevisionSpeciesFact.StatusId = STATUS_ID; newDyntaxaRevisionSpeciesFact = DyntaxaManager.CreateDyntaxaRevisionSpeciesFact(GetRevisionContext(), dyntaxaRevisionSpeciesFact); Assert.IsNotNull(newDyntaxaRevisionSpeciesFact); Assert.IsFalse(dyntaxaRevisionSpeciesFact.SpeciesFactExists); Assert.IsNull(dyntaxaRevisionSpeciesFact.OriginalStatusId); Assert.AreNotEqual(dyntaxaRevisionSpeciesFact.Id, newDyntaxaRevisionSpeciesFact.Id); Assert.AreEqual(dyntaxaRevisionSpeciesFact.Description, newDyntaxaRevisionSpeciesFact.Description); Assert.AreEqual(STATUS_ID, newDyntaxaRevisionSpeciesFact.StatusId); Assert.AreEqual(GetContext().GetUser().Id, newDyntaxaRevisionSpeciesFact.CreatedBy); Assert.AreEqual("Foo'Bar", newDyntaxaRevisionSpeciesFact.OriginalDescription); }
public void SetRevisionSpeciesFactPublished() { const int STATUS_ID = 400; // Create test Dyntaxa revision species fact. var dyntaxaRevisionSpeciesFact = WebDyntaxaSpeciesFactTestFactory.Create((Int32)TaxonId.Bear); dyntaxaRevisionSpeciesFact.FactorId = (Int32)FactorId.SwedishHistory; dyntaxaRevisionSpeciesFact.RevisionId = 24; dyntaxaRevisionSpeciesFact.IsPublished = false; dyntaxaRevisionSpeciesFact.StatusId = STATUS_ID; DyntaxaManager.CreateDyntaxaRevisionSpeciesFact(GetRevisionContext(), dyntaxaRevisionSpeciesFact); var result = DyntaxaManager.SetRevisionSpeciesFactPublished(GetRevisionContext(), 24); Assert.AreEqual(true, result); }
public void GetDyntaxaRevisionSpeciesFact_WhenWrongFactorId_ThenNullIsReturned() { WebDyntaxaRevisionSpeciesFact dyntaxaRevisionSpeciesFact, newDyntaxaRevisionSpeciesFact, getDyntaxaRevisionSpeciesFact; const int STATUS_ID = 400; // Create test Dyntaxa revision species fact. dyntaxaRevisionSpeciesFact = WebDyntaxaSpeciesFactTestFactory.Create((Int32)TaxonId.Bear); dyntaxaRevisionSpeciesFact.FactorId = (Int32)FactorId.SwedishHistory; dyntaxaRevisionSpeciesFact.RevisionId = 24; dyntaxaRevisionSpeciesFact.IsPublished = false; dyntaxaRevisionSpeciesFact.StatusId = STATUS_ID; newDyntaxaRevisionSpeciesFact = DyntaxaManager.CreateDyntaxaRevisionSpeciesFact(GetRevisionContext(), dyntaxaRevisionSpeciesFact); getDyntaxaRevisionSpeciesFact = DyntaxaManager.GetDyntaxaRevisionSpeciesFact( GetRevisionContext(), (Int32)FactorId.SwedishOccurrence, (Int32)TaxonId.Bear, 24); Assert.IsNull(getDyntaxaRevisionSpeciesFact); }
public void GetAllDyntaxaRevisionSpeciesFacts_WhenSpeciesFactExists_ThenSpeciesFactIsReturned() { WebDyntaxaRevisionSpeciesFact dyntaxaRevisionSpeciesFact, getDyntaxaRevisionSpeciesFact; List <WebDyntaxaRevisionSpeciesFact> dyntaxaRevisionSpeciesFacts; const int STATUS_ID = 400; // Create test Dyntaxa revision species fact. dyntaxaRevisionSpeciesFact = WebDyntaxaSpeciesFactTestFactory.Create((Int32)TaxonId.Bear); dyntaxaRevisionSpeciesFact.FactorId = (Int32)FactorId.SwedishHistory; dyntaxaRevisionSpeciesFact.RevisionId = 24; dyntaxaRevisionSpeciesFact.IsPublished = false; dyntaxaRevisionSpeciesFact.StatusId = STATUS_ID; DyntaxaManager.CreateDyntaxaRevisionSpeciesFact(GetRevisionContext(), dyntaxaRevisionSpeciesFact); dyntaxaRevisionSpeciesFacts = DyntaxaManager.GetAllDyntaxaRevisionSpeciesFacts( GetRevisionContext(), 24); Assert.AreEqual(1, dyntaxaRevisionSpeciesFacts.Count); }
public void GetDyntaxaRevisionSpeciesFact_WhenRevisionSpeciesFactIsCreatedAndLaterChanged_ThenLastChangedRevisionSpeciesFactIsReturned() { WebDyntaxaRevisionSpeciesFact dyntaxaRevisionSpeciesFact1, getDyntaxaRevisionSpeciesFact1, dyntaxaRevisionSpeciesFact2, getDyntaxaRevisionSpeciesFact2, currentDyntaxaRevisionSpeciesFact; WebTaxonRevisionEvent revisionEvent1, revisionEvent2; Int32 revisionId = 1; //------------------------------------------------------------------- // Create first dyntaxa revision species fact and revision event. dyntaxaRevisionSpeciesFact1 = WebDyntaxaSpeciesFactTestFactory.Create((Int32)TaxonId.Bear); dyntaxaRevisionSpeciesFact1.FactorId = (Int32)FactorId.SwedishHistory; dyntaxaRevisionSpeciesFact1.RevisionId = revisionId; dyntaxaRevisionSpeciesFact1.IsPublished = false; dyntaxaRevisionSpeciesFact1.StatusId = 400; revisionEvent1 = new WebTaxonRevisionEvent() { CreatedBy = 2, CreatedDate = DateTime.Now, TypeId = 1, RevisionId = revisionId, AffectedTaxa = "Bear", OldValue = "StatusId=Unknown", NewValue = "StatusId=400" }; revisionEvent1 = DyntaxaManager.CreateCompleteRevisionEvent(GetRevisionContext(), revisionEvent1); dyntaxaRevisionSpeciesFact1.RevisionEventId = revisionEvent1.Id; dyntaxaRevisionSpeciesFact1 = DyntaxaManager.CreateDyntaxaRevisionSpeciesFact(GetRevisionContext(), dyntaxaRevisionSpeciesFact1); currentDyntaxaRevisionSpeciesFact = DyntaxaManager.GetDyntaxaRevisionSpeciesFact( GetRevisionContext(), (Int32)FactorId.SwedishHistory, (Int32)TaxonId.Bear, revisionId); //Assert first Insert Assert.AreEqual(revisionEvent1.Id, dyntaxaRevisionSpeciesFact1.RevisionEventId); Assert.IsFalse(currentDyntaxaRevisionSpeciesFact.IsChangedInRevisionEventIdSpecified); Assert.AreEqual(400, currentDyntaxaRevisionSpeciesFact.StatusId); Assert.AreEqual(dyntaxaRevisionSpeciesFact1.StatusId, currentDyntaxaRevisionSpeciesFact.StatusId); //--------------------------------------------------------------------- // Create second dyntaxa revision species fact and revision event. dyntaxaRevisionSpeciesFact2 = WebDyntaxaSpeciesFactTestFactory.Create((Int32)TaxonId.Bear); dyntaxaRevisionSpeciesFact2.FactorId = (Int32)FactorId.SwedishHistory; dyntaxaRevisionSpeciesFact2.RevisionId = revisionId; dyntaxaRevisionSpeciesFact2.IsPublished = false; dyntaxaRevisionSpeciesFact2.StatusId = 450; // changed from 400 to 450. revisionEvent2 = new WebTaxonRevisionEvent() { CreatedBy = 3, //Changed CreatedDate = DateTime.Now, TypeId = 1, RevisionId = revisionId, AffectedTaxa = "Bear", OldValue = "StatusId=400", //Changed NewValue = "StatusId=450" //Changed }; revisionEvent2 = DyntaxaManager.CreateCompleteRevisionEvent(GetRevisionContext(), revisionEvent2); dyntaxaRevisionSpeciesFact2.RevisionEventId = revisionEvent2.Id; dyntaxaRevisionSpeciesFact2 = DyntaxaManager.CreateDyntaxaRevisionSpeciesFact(GetRevisionContext(), dyntaxaRevisionSpeciesFact2); currentDyntaxaRevisionSpeciesFact = DyntaxaManager.GetDyntaxaRevisionSpeciesFact( GetRevisionContext(), (Int32)FactorId.SwedishHistory, (Int32)TaxonId.Bear, revisionId); getDyntaxaRevisionSpeciesFact1 = DyntaxaManager.GetDyntaxaRevisionSpeciesFactById(GetRevisionContext(), dyntaxaRevisionSpeciesFact1.Id); getDyntaxaRevisionSpeciesFact2 = DyntaxaManager.GetDyntaxaRevisionSpeciesFactById(GetRevisionContext(), dyntaxaRevisionSpeciesFact2.Id); // Check values. Assert.AreEqual(450, currentDyntaxaRevisionSpeciesFact.StatusId); Assert.AreEqual(getDyntaxaRevisionSpeciesFact2.StatusId, currentDyntaxaRevisionSpeciesFact.StatusId); Assert.AreEqual(400, getDyntaxaRevisionSpeciesFact1.StatusId); Assert.AreNotEqual(getDyntaxaRevisionSpeciesFact1.StatusId, currentDyntaxaRevisionSpeciesFact.StatusId); Assert.AreEqual(revisionEvent1.Id, getDyntaxaRevisionSpeciesFact1.RevisionEventId); Assert.AreEqual(revisionEvent2.Id, getDyntaxaRevisionSpeciesFact1.ChangedInRevisionEventId); Assert.AreEqual(revisionEvent2.Id, currentDyntaxaRevisionSpeciesFact.RevisionEventId); Assert.IsFalse(currentDyntaxaRevisionSpeciesFact.IsChangedInRevisionEventIdSpecified); }