public void ShouldApplyItemUpdatedEvent() { using (var serviceLocatorFixture = new ServiceLocatorFixture()) { // Setup SetupServiceLocatorFixture(serviceLocatorFixture); var events = new List <IDomainEvent>(); CommitEvent.RegisterAll(events.Add); // Exercise Guid patientGuid = CombGuid.NewCombGuid(); var assessmentDefinition = Substitute.For <AssessmentDefinition>(); var assessment = new AssessmentInstanceFactory().Create(assessmentDefinition, patientGuid, "TestName", false); assessment.UpdateItem(new ItemDefinition(new CodedConcept(new CodeSystem("1", "1", "Test"), "1", "Test"), ItemType.Question, null), 0); // Verify Assert.AreEqual(2, events.Count); var itemUpdatedEvent = events[1]; Assert.IsNotNull(itemUpdatedEvent); Assert.AreEqual(typeof(ItemUpdatedEvent), itemUpdatedEvent.GetType()); Assert.AreEqual((itemUpdatedEvent as ItemUpdatedEvent).Value, 0); Assert.AreEqual(2, assessment.Version); } }
public override long Commit(TransactionToApply batch, CommitEvent commitEvent, TransactionApplicationMode mode) { Debug.Assert(Transaction == null, "Designed to only allow one transaction"); Debug.Assert(batch.Next() == null, "Designed to only allow one transaction"); Transaction = batch.TransactionRepresentation(); return(++TxId); }
public void ShouldApplyAddedToWorkflowEvent() { using (var serviceLocatorFixture = new ServiceLocatorFixture()) { // Setup SetupServiceLocatorFixture(serviceLocatorFixture); var events = new List <IDomainEvent>(); CommitEvent.RegisterAll(events.Add); // Exercise var patientGuid = CombGuid.NewCombGuid(); var assessmentDefinition = Substitute.For <AssessmentDefinition>(); var assessment = new AssessmentInstanceFactory().Create(assessmentDefinition, patientGuid, "TestName", false); var workflowKey = CombGuid.NewCombGuid(); assessment.AddToWorkflow(workflowKey); // Verify Assert.AreEqual(2, events.Count); var addedToWorkflowEvent = events[1]; Assert.IsNotNull(addedToWorkflowEvent); Assert.AreEqual(typeof(AssessmentAddedToWorkflowEvent), addedToWorkflowEvent.GetType()); Assert.AreEqual((addedToWorkflowEvent as AssessmentAddedToWorkflowEvent).WorkflowKey, workflowKey); Assert.AreEqual(2, assessment.Version); } }
public void ShouldApplyCreatedEvent() { using (var serviceLocatorFixture = new ServiceLocatorFixture()) { // Setup SetupServiceLocatorFixture(serviceLocatorFixture); var events = new List <IDomainEvent>(); CommitEvent.RegisterAll(events.Add); // Exercise Guid patientGuid = CombGuid.NewCombGuid(); var assessmentDefinition = Substitute.For <AssessmentDefinition>(); var assessment = new AssessmentInstanceFactory().Create(assessmentDefinition, patientGuid, "TestName", false); // Verify Assert.AreEqual(1, events.Count); var createdEvent = events[0]; Assert.IsNotNull(createdEvent); Assert.AreEqual(typeof(AssessmentCreatedEvent), createdEvent.GetType()); Assert.AreEqual((createdEvent as AssessmentCreatedEvent).PatientKey, patientGuid); Assert.AreEqual((createdEvent as AssessmentCreatedEvent).AssessmentName, assessmentName); Assert.AreEqual(1, assessment.Version); } }
public override long Commit(TransactionToApply batch, CommitEvent commitEvent, TransactionApplicationMode mode) { int batchSize = Count(batch); BatchSizes.AddLast(batchSize); return(42); }
public void ShouldApplyScoredEvent() { using (var serviceLocatorFixture = new ServiceLocatorFixture()) { // Setup SetupServiceLocatorFixture(serviceLocatorFixture); var events = new List <IDomainEvent>(); CommitEvent.RegisterAll(events.Add); // Exercise var patientGuid = CombGuid.NewCombGuid(); var assessmentDefinition = Substitute.For <AssessmentDefinition>(); var assessment = new AssessmentInstanceFactory().Create(assessmentDefinition, patientGuid, "TestName", false); assessment.ScoreComplete(new CodedConcept(CodeSystems.Obhita, "dummayCode", ""), "result"); // Verify Assert.AreEqual(2, events.Count); var scoredEvent = events[1]; Assert.IsNotNull(scoredEvent); Assert.AreEqual(typeof(AssessmentScoredEvent), scoredEvent.GetType()); Assert.AreEqual((scoredEvent as AssessmentScoredEvent).Value, "result"); Assert.AreEqual((scoredEvent as AssessmentScoredEvent).ScoreCode.Code, "dummayCode"); Assert.IsNull((scoredEvent as AssessmentScoredEvent).Guidance); Assert.AreEqual(2, assessment.Version); } }
public void CalculateScoreShouldReturnTrueWhenHasDilyuseOfAnySubstance() { using (var serviceLocatorFixture = new ServiceLocatorFixture()) { // Setup SetupServiceLocatorFixture(serviceLocatorFixture); var events = new List <IDomainEvent>(); CommitEvent.RegisterAll(events.Add); // Exercise Guid defGuid = CombGuid.NewCombGuid(); Guid patientGuid = CombGuid.NewCombGuid(); var assessment = new AssessmentInstance(defGuid, patientGuid, "TestName"); assessment.UpdateItem("3269979", new Lookup(new CodedConcept(CodeSystems.Obhita, "", ""), Frequency.DailyOrAlmostDaily.Value)); var nidaAssessFurtherScoringEngine = new NidaAssessFurtherScoringEngine(); nidaAssessFurtherScoringEngine.CalculateScore(assessment); // Verify var scoredEvent = events.FirstOrDefault(e => e.GetType() == typeof(AssessmentScoredEvent)) as AssessmentScoredEvent; Assert.IsNotNull(scoredEvent); Assert.AreEqual(scoredEvent.Value, true); } }
public void ShouldApplyAddedToWorkflowEvent() { using (var serviceLocatorFixture = new ServiceLocatorFixture()) { // Setup SetupServiceLocatorFixture(serviceLocatorFixture); var events = new List <IDomainEvent>(); CommitEvent.RegisterAll(events.Add); // Exercise Guid defGuid = CombGuid.NewCombGuid(); Guid patientGuid = CombGuid.NewCombGuid(); var source = new AssessmentInstance(defGuid, patientGuid, assessmentName); Guid workflowKey = CombGuid.NewCombGuid(); source.AddToWorkflow(workflowKey); // Verify Assert.AreEqual(2, events.Count); var addedToWorkflowEvent = events[1]; Assert.IsNotNull(addedToWorkflowEvent); Assert.AreEqual(typeof(AssessmentAddedToWorkflowEvent), addedToWorkflowEvent.GetType()); Assert.AreEqual((addedToWorkflowEvent as AssessmentAddedToWorkflowEvent).WorkflowKey, workflowKey); Assert.AreEqual(2, source.Version); } }
public void ShouldApplyItemAddedEvent() { using (var serviceLocatorFixture = new ServiceLocatorFixture()) { // Setup SetupServiceLocatorFixture(serviceLocatorFixture); var events = new List <IDomainEvent>(); CommitEvent.RegisterAll(events.Add); // Exercise Guid defGuid = CombGuid.NewCombGuid(); Guid patientGuid = CombGuid.NewCombGuid(); var source = new AssessmentInstance(defGuid, patientGuid, assessmentName); source.UpdateItem("", 0); // Verify Assert.AreEqual(2, events.Count); var itemUpdatedEvent = events[1]; Assert.IsNotNull(itemUpdatedEvent); Assert.AreEqual(typeof(ItemUpdatedEvent), itemUpdatedEvent.GetType()); Assert.AreEqual((itemUpdatedEvent as ItemUpdatedEvent).Value, 0); Assert.AreEqual(2, source.Version); } }
public void CalculateScoreShouldReturnFalseWhenNoCriteriaMet() { using (var serviceLocatorFixture = new ServiceLocatorFixture()) { // Setup SetupServiceLocatorFixture(serviceLocatorFixture); var events = new List <IDomainEvent>(); CommitEvent.RegisterAll(events.Add); // Exercise Guid defGuid = CombGuid.NewCombGuid(); Guid patientGuid = CombGuid.NewCombGuid(); var assessment = new AssessmentInstance(defGuid, patientGuid, "TestName"); assessment.UpdateItem("", ""); var nidaAssessFurtherScoringEngine = new NidaAssessFurtherScoringEngine(); nidaAssessFurtherScoringEngine.CalculateScore(assessment); // Verify var scoredEvent = events.FirstOrDefault(e => e.GetType() == typeof(AssessmentScoredEvent)) as AssessmentScoredEvent; Assert.IsNotNull(scoredEvent); Assert.AreEqual(scoredEvent.Value, false); } }
public void CalculateScoreShouldReturnTrueWhenHasDilyuseOfAnySubstance() { using (var serviceLocatorFixture = new ServiceLocatorFixture()) { // Setup SetupServiceLocatorFixture(serviceLocatorFixture); var events = new List <IDomainEvent>(); CommitEvent.RegisterAll(events.Add); // Exercise Guid patientGuid = CombGuid.NewCombGuid(); var assessmentDefinition = Substitute.For <AssessmentDefinition>(); var assessment = new AssessmentInstanceFactory().Create(assessmentDefinition, patientGuid, "TestName"); assessment.UpdateItem(new ItemDefinition(new CodedConcept(new CodeSystem("1", "1", "Test"), "3269979", "Test"), ItemType.Question, null), DrugUseFrequency.DailyOrAlmostDaily); var nidaAssessFurtherScoringEngine = new NidaAssessFurtherScoringEngine(); nidaAssessFurtherScoringEngine.CalculateScore(assessment); // Verify var scoredEvent = events.FirstOrDefault(e => e.GetType() == typeof(AssessmentScoredEvent)) as AssessmentScoredEvent; Assert.IsNotNull(scoredEvent); Assert.AreEqual(scoredEvent.Value.ToString(), "True"); } }
public void CalculateScoreShouldRaiseScoredEvent() { using (var serviceLocatorFixture = new ServiceLocatorFixture()) { const int itemValue = 2; // Setup SetupServiceLocatorFixture(serviceLocatorFixture); var events = new List <IDomainEvent>(); CommitEvent.RegisterAll(events.Add); // Exercise Guid defGuid = CombGuid.NewCombGuid(); Guid patientGuid = CombGuid.NewCombGuid(); var assessment = new AssessmentInstance(defGuid, patientGuid, "TestName"); assessment.UpdateItem("", itemValue); var nidaSingleQuestionScreenerScoringEngine = new NidaSingleQuestionScreenerScoringEngine(); nidaSingleQuestionScreenerScoringEngine.CalculateScore(assessment); // Verify Assert.AreEqual(3, events.Count); var scoredEvent = events[2]; Assert.IsNotNull(scoredEvent); Assert.AreEqual(typeof(AssessmentScoredEvent), scoredEvent.GetType()); Assert.AreEqual((scoredEvent as AssessmentScoredEvent).Value, itemValue); Assert.AreEqual((scoredEvent as AssessmentScoredEvent).Guidance.Code, "guidance_1_and_up"); Assert.AreEqual(3, assessment.Version); } }
public void CalculateScoreShouldRaiseScoredEvent() { using (var serviceLocatorFixture = new ServiceLocatorFixture()) { // Setup SetupServiceLocatorFixture(serviceLocatorFixture); var events = new List <IDomainEvent>(); CommitEvent.RegisterAll(events.Add); // Exercise var patientGuid = CombGuid.NewCombGuid(); var assessmentDefinition = Substitute.For <AssessmentDefinition> (); var assessment = new AssessmentInstanceFactory().Create(assessmentDefinition, patientGuid, "TestName"); assessment.UpdateItem(new ItemDefinition(new CodedConcept(new CodeSystem("1", "1", "Test"), "1", "Test"), ItemType.Question, null), "true"); assessment.UpdateItem(new ItemDefinition(new CodedConcept(new CodeSystem("1", "1", "Test"), "2", "Test"), ItemType.Question, null), "false"); var drugAbuseScreeningTestScoringEngine = new DrugAbuseScreeningTestScoringEngine(); drugAbuseScreeningTestScoringEngine.CalculateScore(assessment); // Verify Assert.AreEqual(4, events.Count); var scoredEvent = events[3]; Assert.IsNotNull(scoredEvent); Assert.AreEqual(typeof(AssessmentScoredEvent), scoredEvent.GetType()); Assert.AreEqual((scoredEvent as AssessmentScoredEvent).Value, 1); Assert.AreEqual((scoredEvent as AssessmentScoredEvent).Guidance.Code, "guidance_0_to_2"); Assert.AreEqual(4, assessment.Version); } }
public void ShouldApplyCreatedEvent() { using (var serviceLocatorFixture = new ServiceLocatorFixture()) { // Setup SetupServiceLocatorFixture(serviceLocatorFixture); var events = new List <IDomainEvent>(); CommitEvent.RegisterAll(events.Add); // Exercise Guid defGuid = CombGuid.NewCombGuid(); Guid patientGuid = CombGuid.NewCombGuid(); var source = new AssessmentInstance(defGuid, patientGuid, assessmentName); // Verify Assert.AreEqual(1, events.Count); var createdEvent = events[0]; Assert.IsNotNull(createdEvent); Assert.AreEqual(typeof(AssessmentCreatedEvent), createdEvent.GetType()); Assert.AreEqual((createdEvent as AssessmentCreatedEvent).PatientKey, patientGuid); Assert.AreEqual((createdEvent as AssessmentCreatedEvent).AssessmentName, assessmentName); Assert.AreEqual(1, source.Version); } }
public void CalculateScoreShouldRaiseScoredEvent() { using (var serviceLocatorFixture = new ServiceLocatorFixture()) { // Setup SetupServiceLocatorFixture(serviceLocatorFixture); var events = new List <IDomainEvent>(); CommitEvent.RegisterAll(events.Add); // Exercise Guid defGuid = CombGuid.NewCombGuid(); Guid patientGuid = CombGuid.NewCombGuid(); var assessment = new AssessmentInstance(defGuid, patientGuid, "TestName"); assessment.UpdateItem("1", "true"); assessment.UpdateItem("2", "false"); var drugAbuseScreeningTestScoringEngine = new DrugAbuseScreeningTestScoringEngine(); drugAbuseScreeningTestScoringEngine.CalculateScore(assessment); // Verify Assert.AreEqual(4, events.Count); var scoredEvent = events[3]; Assert.IsNotNull(scoredEvent); Assert.AreEqual(typeof(AssessmentScoredEvent), scoredEvent.GetType()); Assert.AreEqual((scoredEvent as AssessmentScoredEvent).Value, 1); Assert.AreEqual((scoredEvent as AssessmentScoredEvent).Guidance.Code, "guidance_0_to_2"); Assert.AreEqual(4, assessment.Version); } }
public void ShouldApplyScoredEvent() { using (var serviceLocatorFixture = new ServiceLocatorFixture()) { // Setup SetupServiceLocatorFixture(serviceLocatorFixture); var events = new List <IDomainEvent>(); CommitEvent.RegisterAll(events.Add); // Exercise Guid defGuid = CombGuid.NewCombGuid(); Guid patientGuid = CombGuid.NewCombGuid(); var source = new AssessmentInstance(defGuid, patientGuid, assessmentName); source.ScoreComplete(new CodedConcept(CodeSystems.Obhita, "dummayCode", ""), "result"); // Verify Assert.AreEqual(2, events.Count); var scoredEvent = events[1]; Assert.IsNotNull(scoredEvent); Assert.AreEqual(typeof(AssessmentScoredEvent), scoredEvent.GetType()); Assert.AreEqual((scoredEvent as AssessmentScoredEvent).Value, "result"); Assert.AreEqual((scoredEvent as AssessmentScoredEvent).ScoreCode.Code, "dummayCode"); Assert.IsNull((scoredEvent as AssessmentScoredEvent).Guidance); Assert.AreEqual(2, source.Version); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public long commit(final org.neo4j.kernel.impl.api.TransactionToApply tx, final org.neo4j.kernel.impl.transaction.tracing.CommitEvent commitEvent, org.neo4j.storageengine.api.TransactionApplicationMode mode) throws org.neo4j.internal.kernel.api.exceptions.TransactionFailureException //JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected: public override long Commit(TransactionToApply tx, CommitEvent commitEvent, TransactionApplicationMode mode) { TransactionRepresentationReplicatedTransaction transaction = ReplicatedTransaction.from(tx.TransactionRepresentation()); Future <object> futureTxId; try { futureTxId = _replicator.replicate(transaction, true); } catch (ReplicationFailureException e) { throw new TransactionFailureException(ReplicationFailure, e); } try { return(( long )futureTxId.get()); } catch (ExecutionException e) { if (e.InnerException is TransactionFailureException) { throw ( TransactionFailureException )e.InnerException; } // TODO: Panic? throw new Exception(e); } catch (InterruptedException e) { // TODO Wait for the transaction to possibly finish within a user configurable time, before aborting. throw new TransactionFailureException("Interrupted while waiting for txId", e); } }
public void construct() { var eventType = "a"; var data = Encoding.UTF8.GetBytes("{}"); var e = new CommitEvent(eventType, data); Assert.Equal(eventType, e.EventType); Assert.Equal(data, e.Data); // Note this is reference equality, not value eq. }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public long commit(TransactionToApply batch, org.neo4j.kernel.impl.transaction.tracing.CommitEvent commitEvent, org.neo4j.storageengine.api.TransactionApplicationMode mode) throws org.neo4j.internal.kernel.api.exceptions.TransactionFailureException public override long Commit(TransactionToApply batch, CommitEvent commitEvent, TransactionApplicationMode mode) { long lastTxId = AppendToLog(batch, commitEvent); try { ApplyToStore(batch, commitEvent, mode); return(lastTxId); } finally { Close(batch); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private long appendToLog(TransactionToApply batch, org.neo4j.kernel.impl.transaction.tracing.CommitEvent commitEvent) throws org.neo4j.internal.kernel.api.exceptions.TransactionFailureException private long AppendToLog(TransactionToApply batch, CommitEvent commitEvent) { try { using (LogAppendEvent logAppendEvent = commitEvent.BeginLogAppend()) { return(_appender.append(batch, logAppendEvent)); } } catch (Exception cause) { throw new TransactionFailureException(TransactionLogError, cause, "Could not append transaction representation to log"); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: protected void applyToStore(TransactionToApply batch, org.neo4j.kernel.impl.transaction.tracing.CommitEvent commitEvent, org.neo4j.storageengine.api.TransactionApplicationMode mode) throws org.neo4j.internal.kernel.api.exceptions.TransactionFailureException protected internal virtual void ApplyToStore(TransactionToApply batch, CommitEvent commitEvent, TransactionApplicationMode mode) { try { using (StoreApplyEvent storeApplyEvent = commitEvent.BeginStoreApply()) { _storageEngine.apply(batch, mode); } } catch (Exception cause) { throw new TransactionFailureException(TransactionCommitFailed, cause, "Could not apply the transaction to the store after written to log"); } }
public void CallConstructor_WorkflowMessageCreatedEventRaised() { using (var serviceLocatorFixture = new ServiceLocatorFixture()) { // Setup SetupServiceLocatorFixture(serviceLocatorFixture); var events = new List <IDomainEvent> (); CommitEvent.RegisterAll(events.Add); var workflow = new WorkflowMessage(Guid.NewGuid(), Guid.NewGuid(), string.Empty, Guid.NewGuid(), string.Empty, new Score()); Assert.AreEqual(1, events.Count(), "Incorrect number of events."); Assert.AreEqual(typeof(WorkflowMessageCreatedEvent), events.First().GetType()); } }
public void CallAdministerAssessment_WorkflowMessageStatusChangedEventRaised() { using (var serviceLocatorFixture = new ServiceLocatorFixture()) { // Setup SetupServiceLocatorFixture(serviceLocatorFixture); var workflowMessage = new WorkflowMessage(Guid.NewGuid(), Guid.NewGuid(), string.Empty, Guid.NewGuid(), string.Empty, new Score()); var events = new List <IDomainEvent> (); CommitEvent.RegisterAll(events.Add); workflowMessage.AdministerAssessment(); Assert.AreEqual(1, events.Count(), "Incorrect number of events."); Assert.AreEqual(typeof(WorkflowMessageStatusChangedEvent), events.First().GetType()); Assert.AreEqual(WorkflowMessageStatus.InProgress, (events.First() as WorkflowMessageStatusChangedEvent).Status); } }
public void CallAdvance_CorrectEventsRaised() { using (var serviceLocatorFixture = new ServiceLocatorFixture()) { // Setup SetupServiceLocatorFixture(serviceLocatorFixture); var workflowMessage = new WorkflowMessage(Guid.NewGuid(), Guid.NewGuid(), string.Empty, Guid.NewGuid(), string.Empty, new Score()); workflowMessage.AdministerAssessment(); var events = new List <IDomainEvent> (); CommitEvent.RegisterAll(events.Add); var assessmentKey = Guid.NewGuid(); var assessmentCode = Guid.NewGuid().ToString(); var recommendedAssessmentKey = Guid.NewGuid(); var recommendedAssessmentCode = Guid.NewGuid().ToString(); var score = new Score(); workflowMessage.Advance(assessmentKey, assessmentCode, recommendedAssessmentKey, recommendedAssessmentCode, score); Assert.AreEqual(2, events.Count(), "Incorrect number of events."); Assert.IsTrue(events.Any(a => a.GetType() == typeof(WorkflowMessageStatusChangedEvent)), "Status Changed event not raised."); Assert.IsTrue(events.Any(a => a.GetType() == typeof(WorkflowMessageAdvancedEvent)), "Advanced Event not raised."); Assert.IsTrue( (events.First(a => a.GetType() == typeof(WorkflowMessageStatusChangedEvent)) as WorkflowMessageStatusChangedEvent).Status == WorkflowMessageStatus.WaitingForResponse, "Status event has wrong status."); var advanceEvent = events.First(a => a.GetType() == typeof(WorkflowMessageAdvancedEvent)) as WorkflowMessageAdvancedEvent; Assert.AreEqual(assessmentKey, advanceEvent.InitiatingAssessmentKey, "Advance event has wrong InitiatingAssessmentKey."); Assert.AreEqual(assessmentCode, advanceEvent.InitiatingAssessmentCode, "Advance event has wrong InitiatingAssessmentCode."); Assert.AreEqual(recommendedAssessmentKey, advanceEvent.RecommendedAssessmentDefinitionKey, "Advance event has wrong RecommendedAssessmentDefinitionKey."); Assert.AreEqual(recommendedAssessmentCode, advanceEvent.RecommendedAssessmentDefinitionCode, "Advance event has wrong RecommendedAssessmentDefinitionCode."); Assert.AreSame(score, advanceEvent.InitiatingAssessmentScore, "Advance event has wrong InitiatingAssessmentScore."); Assert.AreEqual(assessmentKey, workflowMessage.InitiatingAssessmentKey, "Worflow message has wrong InitiatingAssessmentKey."); Assert.AreEqual(assessmentCode, workflowMessage.InitiatingAssessmentCode, "Worflow message has wrong InitiatingAssessmentCode."); Assert.AreEqual(recommendedAssessmentKey, workflowMessage.RecommendedAssessmentDefinitionKey, "Worflow message has wrong RecommendedAssessmentDefinitionKey."); Assert.AreEqual(recommendedAssessmentCode, workflowMessage.RecommendedAssessmentDefinitionCode, "Worflow message has wrong RecommendedAssessmentDefinitionCode."); Assert.AreSame(score, workflowMessage.InitiatingAssessmentScore, "Worflow message has wrong InitiatingAssessmentScore."); } }
public void ShouldApplyCreatedEvent () { using ( var serviceLocatorFixture = new ServiceLocatorFixture () ) { // Setup SetupServiceLocatorFixture ( serviceLocatorFixture ); var events = new List<IDomainEvent> (); CommitEvent.RegisterAll ( events.Add ); // Exercise const string testCode = "testCode"; var source = new AssessmentDefinition ( new CodedConcept ( CodeSystems.Nci, testCode, "Test" ) ); // Verify Assert.AreEqual ( 1, events.Count ); var createdEvent = events[0]; Assert.IsNotNull ( createdEvent ); Assert.AreEqual ( typeof(AssessmentDefinitionCreatedEvent), createdEvent.GetType () ); Assert.AreEqual ( ( createdEvent as AssessmentDefinitionCreatedEvent ).CodedConcept.Code, testCode ); Assert.AreEqual ( 1, source.Version ); } }
public void ShouldApplyItemAddedEvent () { using ( var serviceLocatorFixture = new ServiceLocatorFixture () ) { // Setup SetupServiceLocatorFixture ( serviceLocatorFixture ); var events = new List<IDomainEvent> (); CommitEvent.RegisterAll ( events.Add ); // Exercise const string testCode = "testCode"; var source = new AssessmentDefinition ( new CodedConcept ( CodeSystems.Nci, testCode, "Test" ) ); source.AddItemDefinition ( new ItemDefinition ( new CodedConcept ( CodeSystems.Nci, testCode, "Test" ), ItemType.Question, new Lookup (new CodedConcept ( CodeSystems.Nci, testCode, "Test")) ) ); // Verify Assert.AreEqual ( 2, events.Count ); var itemDefinitionAddedEvent = events[1]; Assert.IsNotNull ( itemDefinitionAddedEvent ); Assert.AreEqual ( typeof(ItemDefinitionAddedEvent), itemDefinitionAddedEvent.GetType () ); Assert.AreEqual ( ( itemDefinitionAddedEvent as ItemDefinitionAddedEvent ).ItemDefinition.CodedConcept.Code, testCode ); Assert.AreEqual ( 2, source.Version ); } }
public void WorkflowStatesFlowCorrectly() { using (var serviceLocatorFixture = new ServiceLocatorFixture()) { // Setup SetupServiceLocatorFixture(serviceLocatorFixture); var events = new List <IDomainEvent> (); CommitEvent.RegisterAll(events.Add); var workflow = new WorkflowMessage(Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid().ToString(), Guid.NewGuid(), Guid.NewGuid().ToString(), new Score()); Assert.AreEqual(WorkflowMessageStatus.WaitingForResponse, workflow.Status); events.Clear(); workflow.Advance(Guid.NewGuid(), Guid.NewGuid().ToString(), Guid.NewGuid(), Guid.NewGuid().ToString(), new Score()); Assert.AreEqual(0, events.Count()); Assert.AreEqual(WorkflowMessageStatus.WaitingForResponse, workflow.Status); workflow.AdministerAssessment(); Assert.AreEqual(WorkflowMessageStatus.InProgress, workflow.Status); events.Clear(); workflow.Reject(); Assert.AreEqual(0, events.Count()); Assert.AreEqual(WorkflowMessageStatus.InProgress, workflow.Status); events.Clear(); workflow.AdministerAssessment(); Assert.AreEqual(0, events.Count()); Assert.AreEqual(WorkflowMessageStatus.InProgress, workflow.Status); workflow.Advance(Guid.NewGuid(), Guid.NewGuid().ToString(), Guid.NewGuid(), Guid.NewGuid().ToString(), new Score()); Assert.AreEqual(WorkflowMessageStatus.WaitingForResponse, workflow.Status); workflow.Reject(); Assert.AreEqual(WorkflowMessageStatus.Rejected, workflow.Status); events.Clear(); workflow.Reject(); Assert.AreEqual(0, events.Count()); Assert.AreEqual(WorkflowMessageStatus.Rejected, workflow.Status); events.Clear(); workflow.AdministerAssessment(); Assert.AreEqual(0, events.Count()); Assert.AreEqual(WorkflowMessageStatus.Rejected, workflow.Status); events.Clear(); workflow.Advance(Guid.NewGuid(), Guid.NewGuid().ToString(), Guid.NewGuid(), Guid.NewGuid().ToString(), new Score()); Assert.AreEqual(0, events.Count()); Assert.AreEqual(WorkflowMessageStatus.Rejected, workflow.Status); } }
private void SendEvent(string message) { CommitEvent?.Invoke(this, new CommitStatusEventArgs(message)); }
Task IAuditTrail.WaitForCommitAsync(long index, TimeSpan timeout, CancellationToken token) => index >= 0L ? CommitEvent.WaitForCommitAsync(this, commitEvent, index, timeout, token) : Task.FromException(new ArgumentOutOfRangeException(nameof(index)));
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public long commit(org.neo4j.kernel.impl.api.TransactionToApply batch, org.neo4j.kernel.impl.transaction.tracing.CommitEvent commitEvent, org.neo4j.storageengine.api.TransactionApplicationMode mode) throws org.neo4j.graphdb.TransactionFailureException public override long Commit(TransactionToApply batch, CommitEvent commitEvent, TransactionApplicationMode mode) { TransactionsToApply.Add(batch.TransactionRepresentation()); return(-1); }