public void TestWorldTerminateToStopAllActors()
        {
            var results = new TestResults();
            var beforeStartCountAccess = results.BeforeStartCountAccessCompletes(12);

            var stoppables = SetUpActors(World, results);

            for (int idx = 0; idx < stoppables.Length; ++idx)
            {
                stoppables[idx].CreateChildren();
            }

            beforeStartCountAccess.ReadFrom <int>("value");
            var terminatingStopAccess = results.TerminatingStopCountAccessCompletes(12);

            results.TerminatingAccessCompletes(0).WriteUsing("value", true);
            World.Terminate();

            var terminatingStopCount = terminatingStopAccess.ReadFrom <int>("value");

            Assert.Equal(12, terminatingStopCount);
        }
        public void TestThatTimeOutOccursForSideEffects()
        {
            var greetingsTestResults = TestResults.AfterCompleting(1);
            var uc             = World.ActorFor <IUsesCompletes>(typeof(UsesCompletesCausesTimeoutActor), greetingsTestResults);
            var helloCompletes = uc.GetHello()
                                 .AndThenConsume(TimeSpan.FromMilliseconds(1), new Hello(HelloNot), hello => greetingsTestResults.SetGreeting(hello.Greeting))
                                 .Otherwise <Hello>(failedHello =>
            {
                greetingsTestResults.SetGreeting(failedHello.Greeting, true);
                return(failedHello);
            });

            Assert.NotEqual(Hello, greetingsTestResults.GetGreeting(true));
            Assert.Equal(HelloNot, helloCompletes.Outcome.Greeting);

            var valueTestResults = TestResults.AfterCompleting(1);

            var oneCompletes = uc.GetOne()
                               .AndThenConsume(TimeSpan.FromMilliseconds(1), 0, value => valueTestResults.SetValue(value))
                               .Otherwise <int>(value =>
            {
                valueTestResults.SetValue(value, true);
                return(0);
            });

            var thread = new Thread(() =>
            {
                Thread.Sleep(1500);
                oneCompletes.With(1);
            });

            thread.Start();

            Assert.NotEqual(1, valueTestResults.GetValue(true));
            Assert.Equal(0, valueTestResults.GetValue(true));
            Assert.Equal(0, oneCompletes.Outcome);
        }
Beispiel #3
0
 public InvoiceSubmissionRouter(TestResults testResults) :
     base(new RouterSpecification <IInvoiceSubmitter>(
              0,
              Definition.Has <ERPSpecificInvoiceSubmitter>(Definition.Parameters(ERPSystemCode.None, testResults))))
 {
 }
Beispiel #4
0
 public ERPSpecificInvoiceSubmitter(ERPSystemCode erp, TestResults testResults)
 {
     this.erp         = erp;
     this.testResults = testResults;
 }
Beispiel #5
0
 public SimpleActor(TestResults testResults)
 {
     _testResults = testResults;
 }
 public UsesCompletesCausesTimeoutActor(TestResults results) => _results = results;
 public UsesCompletesActor(TestResults results) => _results = results;
Beispiel #8
0
 public LifecycleActor(TestResults testResults) => _testResults = testResults;
Beispiel #9
0
 public MathCommandWorker(TestResults testResults)
 {
     _testResults = testResults;
 }
Beispiel #10
0
 public MathCommandRouter(int poolSize, TestResults testResults) :
     base(new RouterSpecification <IThreeArgConsumerProtocol>(
              poolSize,
              Definition.Has <MathCommandWorker>(Definition.Parameters(testResults))))
 {
 }
 public ChildCreatingStoppableActor(TestResults results) => _results = results;