public void Invoke() { var logger = new StandardOutLogger(); // Uses Console ElapsedTime elapsed = new ElapsedTime(); logger.WriteLine("Constructing test fixture...\n"); var fixture = new MoviePickerVariantsAllTests(); logger.WriteLine(elapsed.Elapsed.ToString()); logger.ForegroundColor = ConsoleColor.Green; logger.WriteLine("Setting up test fixture...\n"); MoviePickerVariantsAllTests.InitializeBeforeAllTests(null); //<<<<< Static class needs to match constructor above. // Override the debug logger inside of the tests. fixture.UnityContainer.RegisterInstance(typeof(ILogger), null, logger, new ContainerControlledLifetimeManager()); logger.WriteLine($"AFTER - InitializeBeforeAllTests {elapsed.Elapsed}"); fixture.MoviePickerVariantsAll_ChooseBest_Parker_20180805_Percentage(); //<<<<< Test method. logger.WriteLine($"AFTER TEST - {elapsed.ElapsedSinceLastElapsed}"); logger.WriteLine($"AFTER - CleanupAfterAllTests {elapsed.Elapsed}"); logger.WriteLine("Press any key to continue..."); Console.ReadKey(); }
protected ActorSystem([NotNull] string name, [NotNull] IBootstrapper bootstrapper) { if (bootstrapper == null) { throw new ArgumentNullException("bootstrapper"); } if (bootstrapper.UniqueNameCreator == null) { throw new ArgumentException("IBootstrapper.UniqueNameCreator was null", "bootstrapper"); } if (bootstrapper.LocalActorRefFactory == null) { throw new ArgumentException("IBootstrapper.LocalActorRefFactory was null", "bootstrapper"); } if (name == null) { throw new ArgumentNullException("name"); } if (name.Length == 0) { throw new ArgumentException("name"); } var nameLegal = new Regex("^[a-zA-Z0-9][a-zA-Z0-9-]*$"); if (!nameLegal.IsMatch(name)) { throw new ArgumentException( string.Format( "Invalid ActorSystem name [{0}], must contain only word characters (i.e. [a-zA-Z0-9] plus non-leading '-')", name), "name"); } _name = name; _rootPath = new RootActorPath("/"); _tempNodeHandler = new TempNodeHandler(_rootPath / "temp"); _settings = bootstrapper.Settings; _scheduler = bootstrapper.Scheduler; _uniqueNameCreator = bootstrapper.UniqueNameCreator; _localActorRefFactory = bootstrapper.LocalActorRefFactory; _deadLetters = bootstrapper.DeadLetterActorCreator(_rootPath / "_DeadLetter", this); _deadLettersMailbox = new DeadLetterMailbox(_deadLetters); _actionScheduler = bootstrapper.ActionScheduler; _defaultMailboxCreator = bootstrapper.DefaultMailboxCreator; _eventStream = new EventStream(this); var standardOutLogger = new StandardOutLogger(new ChildActorPath(_rootPath, "_StandardOutLogger", LocalActorRef.UndefinedInstanceId), this); _eventStream.StartStandardOutLogger(standardOutLogger, _settings.StandardOutLoggerSettings); _logSource = "ActorSystem:" + name; }
/// <summary> /// Initializes a new instance of the <see cref="Settings" /> class. /// </summary> /// <param name="system">The system.</param> /// <param name="config">The configuration.</param> /// <param name="setup">The setup class used to help bootstrap the <see cref="ActorSystem"/></param> /// <exception cref="ConfigurationException"> /// This exception is thrown if the 'akka.actor.provider' configuration item is not a valid type name or a valid actor ref provider. /// </exception> public Settings(ActorSystem system, Config config, ActorSystemSetup setup) { Setup = setup; _userConfig = config; _fallbackConfig = ConfigurationFactory.Default(); RebuildConfig(); System = system; var providerSelectionSetup = Setup.Get <BootstrapSetup>() .FlatSelect(_ => _.ActorRefProvider) .Select(_ => _.Fqn) .GetOrElse(Config.GetString("akka.actor.provider", null)); ProviderSelectionType = ProviderSelection.GetProvider(providerSelectionSetup); ConfigVersion = Config.GetString("akka.version", null); ProviderClass = ProviderSelectionType.Fqn; HasCluster = ProviderSelectionType.HasCluster; var providerType = Type.GetType(ProviderClass); if (providerType == null) { throw new ConfigurationException($"'akka.actor.provider' is not a valid type name : '{ProviderClass}'"); } if (!typeof(IActorRefProvider).IsAssignableFrom(providerType)) { throw new ConfigurationException($"'akka.actor.provider' is not a valid actor ref provider: '{ProviderClass}'"); } SupervisorStrategyClass = Config.GetString("akka.actor.guardian-supervisor-strategy", null); AskTimeout = Config.GetTimeSpan("akka.actor.ask-timeout", null, allowInfinite: true); CreationTimeout = Config.GetTimeSpan("akka.actor.creation-timeout", null); UnstartedPushTimeout = Config.GetTimeSpan("akka.actor.unstarted-push-timeout", null); SerializeAllMessages = Config.GetBoolean("akka.actor.serialize-messages", false); SerializeAllCreators = Config.GetBoolean("akka.actor.serialize-creators", false); LogLevel = Config.GetString("akka.loglevel", null); StdoutLogLevel = Config.GetString("akka.stdout-loglevel", null); var stdoutClassName = Config.GetString("akka.stdout-logger-class", null); if (string.IsNullOrWhiteSpace(stdoutClassName)) { StdoutLogger = new StandardOutLogger(); } else { var stdoutLoggerType = Type.GetType(stdoutClassName); if (stdoutLoggerType == null) { throw new ArgumentException($"Could not load type of {stdoutClassName} for standard out logger."); } if (!typeof(MinimalLogger).IsAssignableFrom(stdoutLoggerType)) { throw new ArgumentException("Standard out logger type must inherit from the MinimalLogger abstract class."); } try { StdoutLogger = (MinimalLogger)Activator.CreateInstance(stdoutLoggerType); } catch (MissingMethodException) { throw new MissingMethodException( "Standard out logger type must inherit from the MinimalLogger abstract class and have an empty constructor."); } } Loggers = Config.GetStringList("akka.loggers", new string[] { }); LoggersDispatcher = Config.GetString("akka.loggers-dispatcher", null); LoggerStartTimeout = Config.GetTimeSpan("akka.logger-startup-timeout", null); LoggerAsyncStart = Config.GetBoolean("akka.logger-async-start", false); //handled LogConfigOnStart = Config.GetBoolean("akka.log-config-on-start", false); LogDeadLetters = 0; switch (Config.GetString("akka.log-dead-letters", null)) { case "on": case "true": case "yes": LogDeadLetters = int.MaxValue; break; case "off": case "false": case "no": LogDeadLetters = 0; break; default: LogDeadLetters = Config.GetInt("akka.log-dead-letters", 0); break; } LogDeadLettersDuringShutdown = Config.GetBoolean("akka.log-dead-letters-during-shutdown", false); const string key = "akka.log-dead-letters-suspend-duration"; LogDeadLettersSuspendDuration = Config.GetString(key, null) == "infinite" ? Timeout.InfiniteTimeSpan : Config.GetTimeSpan(key); AddLoggingReceive = Config.GetBoolean("akka.actor.debug.receive", false); DebugAutoReceive = Config.GetBoolean("akka.actor.debug.autoreceive", false); DebugLifecycle = Config.GetBoolean("akka.actor.debug.lifecycle", false); FsmDebugEvent = Config.GetBoolean("akka.actor.debug.fsm", false); DebugEventStream = Config.GetBoolean("akka.actor.debug.event-stream", false); DebugUnhandledMessage = Config.GetBoolean("akka.actor.debug.unhandled", false); DebugRouterMisconfiguration = Config.GetBoolean("akka.actor.debug.router-misconfiguration", false); Home = Config.GetString("akka.home", ""); DefaultVirtualNodesFactor = Config.GetInt("akka.actor.deployment.default.virtual-nodes-factor", 0); SchedulerClass = Config.GetString("akka.scheduler.implementation", null); SchedulerShutdownTimeout = Config.GetTimeSpan("akka.scheduler.shutdown-timeout", null); CoordinatedShutdownTerminateActorSystem = Config.GetBoolean("akka.coordinated-shutdown.terminate-actor-system"); CoordinatedShutdownRunByActorSystemTerminate = Config.GetBoolean("akka.coordinated-shutdown.run-by-actor-system-terminate"); if (CoordinatedShutdownRunByActorSystemTerminate && !CoordinatedShutdownTerminateActorSystem) { throw new ConfigurationException( "akka.coordinated-shutdown.run-by-actor-system-terminate=on and " + "akka.coordinated-shutdown.terminate-actor-system=off is not a supported configuration combination."); } }