示例#1
0
        public async Task TestCustomActorRuntimeLogFormatter()
        {
            Configuration config  = Configuration.Create().WithVerbosityEnabled();
            var           tcs     = TaskCompletionSource.Create <bool>();
            IActorRuntime runtime = CreateTestRuntime(config, tcs);

            runtime.RegisterMonitor <S>();
            runtime.SetLogger(null);

            var logger = new CustomActorRuntimeLog();

            runtime.RegisterLog(logger);

            runtime.CreateActor(typeof(M));

            await WaitAsync(tcs.Task, 5000);

            await Task.Delay(200);

            string expected = @"CreateActor
CreateStateMachine
StateTransition
StateTransition
StateTransition
";

            string actual = RemoveNonDeterministicValuesFromReport(logger.ToString());

            Assert.Equal(expected, actual);
        }
        public void TestCustomActorRuntimeLogFormatter()
        {
            this.Test(async runtime =>
            {
                var tcs = new TaskCompletionSource <bool>();
                runtime.RegisterMonitor <TestMonitor>();
                runtime.Monitor <TestMonitor>(new SetupEvent(tcs));
                runtime.RegisterMonitor <S>();
                runtime.Logger = null;

                var logger = new CustomActorRuntimeLog();
                runtime.RegisterLog(logger);

                runtime.CreateActor(typeof(M));

                await this.WaitAsync(tcs.Task, 5000);
                await Task.Delay(200);

                string expected = @"CreateActor
CreateStateMachine
StateTransition
StateTransition
StateTransition";
                string actual   = logger.ToString().RemoveNonDeterministicValues();
                expected        = expected.NormalizeNewLines();
                Assert.Equal(expected, actual);
            }, this.GetConfiguration());
        }
示例#3
0
        public void TestCustomActorRuntimeLogFormatter()
        {
            var logger = new CustomActorRuntimeLog();
            Action <IActorRuntime> test = r =>
            {
                r.RegisterLog(logger);
                r.CreateActor(typeof(M));
            };

            TestingEngine engine = TestingEngine.Create(GetConfiguration().WithDFSStrategy(), test);

            try
            {
                engine.Run();

                var numErrors = engine.TestReport.NumOfFoundBugs;
                Assert.True(numErrors == 1, GetBugReport(engine));
                Assert.True(engine.ReadableTrace != null, "Readable trace is null.");
                Assert.True(engine.ReadableTrace.Length > 0, "Readable trace is empty.");

                string expected = @"CreateStateMachine
StateTransition
CreateStateMachine
StateTransition
";

                string actual = RemoveNonDeterministicValuesFromReport(logger.ToString());
                Assert.Equal(expected, actual);
            }
            catch (Exception ex)
            {
                Assert.False(true, ex.Message + "\n" + ex.StackTrace);
            }
        }
        public void TestCustomActorRuntimeLogFormatter()
        {
            Configuration config = Configuration.Create().WithVerbosityEnabled();

            this.Test(new Func <IActorRuntime, Task>(async(runtime) =>
            {
                var tcs = TaskCompletionSource.Create <bool>();
                runtime.RegisterMonitor <TestMonitor>();
                runtime.Monitor <TestMonitor>(new SetupEvent(tcs));
                runtime.RegisterMonitor <S>();
                runtime.SetLogger(null);

                var logger = new CustomActorRuntimeLog();
                runtime.RegisterLog(logger);

                runtime.CreateActor(typeof(M));

                await this.WaitAsync(tcs.Task, 5000);
                await Task.Delay(200);

                string expected = @"CreateActor
CreateStateMachine
StateTransition
StateTransition
StateTransition";
                string actual   = logger.ToString().RemoveNonDeterministicValues();
                expected        = expected.NormalizeNewLines();
                Assert.Equal(expected, actual);
            }), config);
        }
示例#5
0
        public async Task TestCustomActorRuntimeLogFormatter()
        {
            Configuration config = Configuration.Create().WithVerbosityEnabled();

            config.IsMonitoringEnabledInInProduction = true;

            IActorRuntime runtime = RuntimeFactory.Create(config);

            runtime.RegisterMonitor <S>();
            runtime.SetLogger(null);
            var logger = new CustomActorRuntimeLog();

            runtime.RegisterLog(logger);

            var tcs = new TaskCompletionSource <bool>();

            runtime.CreateActor(typeof(M), new SetupEvent(tcs));

            await WaitAsync(tcs.Task);

            await Task.Delay(200);

            string expected = @"CreateActor
StateTransition
CreateActor
StateTransition
StateTransition
StateTransition
";

            string actual = RemoveNonDeterministicValuesFromReport(logger.ToString());

            Assert.Equal(expected, actual);
        }