private TestKitBase(ITestKitAssertions assertions, ActorSystem system, Config config, string actorSystemName, string testActorName)
        {
            if(assertions == null) throw new ArgumentNullException("assertions");

            _assertions = assertions;
            
            InitializeTest(system, config, actorSystemName, testActorName);
        }
Exemple #2
0
 protected MultiNodeClusterSpec(
     RoleName myself,
     ActorSystemSetup setup,
     ImmutableList <RoleName> roles,
     Func <RoleName, ImmutableList <string> > deployments)
     : base(myself, setup, roles, deployments)
 {
     _assertions       = new XunitAssertions();
     _roleNameComparer = new RoleNameComparer(this);
 }
Exemple #3
0
        private TestKitBase(ITestKitAssertions assertions, ActorSystem system, Config config, string actorSystemName, string testActorName)
        {
            if (assertions == null)
            {
                throw new ArgumentNullException(nameof(assertions), "The supplied assertions must not be null.");
            }

            _assertions = assertions;

            InitializeTest(system, config, actorSystemName, testActorName);
        }
        private TestKitBase(ITestKitAssertions assertions, ActorSystem system, Config config, string actorSystemName, string testActorName)
        {
            if (assertions == null)
            {
                throw new ArgumentNullException("assertions");
            }

            _assertions = assertions;

            InitializeTest(system, config, actorSystemName, testActorName);
        }
Exemple #5
0
        private TestKitBase(ITestKitAssertions assertions, ActorSystem system, Config config, string actorSystemName, string testActorName)
        {
            if (assertions == null)
            {
                throw new ArgumentNullException("assertions");
            }
            if (system == null)
            {
                var configWithDefaultFallback = config.SafeWithFallback(_defaultConfig);
                system = ActorSystem.Create(actorSystemName ?? "test", configWithDefaultFallback);
            }

            _assertions = assertions;
            _system     = system;
            system.RegisterExtension(new TestKitExtension());
            system.RegisterExtension(new TestKitAssertionsExtension(assertions));
            _testKitSettings    = TestKitExtension.For(_system);
            _queue              = new BlockingQueue <MessageEnvelope>();
            _log                = Logging.GetLogger(system, GetType());
            _eventFilterFactory = new EventFilterFactory(this);

            //register the CallingThreadDispatcherConfigurator
            _system.Dispatchers.RegisterConfigurator(CallingThreadDispatcher.Id,
                                                     new CallingThreadDispatcherConfigurator(_system.Settings.Config, _system.Dispatchers.Prerequisites));

            if (string.IsNullOrEmpty(testActorName))
            {
                testActorName = "testActor" + _testActorId.IncrementAndGet();
            }

            var testActor = CreateTestActor(system, testActorName);

            //Wait for the testactor to start
            AwaitCondition(() =>
            {
                var repRef = testActor as IRepointableRef;
                return(repRef == null || repRef.IsStarted);
            }, TimeSpan.FromSeconds(5), TimeSpan.FromMilliseconds(10));

            if (!(this is INoImplicitSender))
            {
                InternalCurrentActorCellKeeper.Current = (ActorCell)((ActorRefWithCell)testActor).Underlying;
            }
            else if (!(this is TestProbe))
            //HACK: we need to clear the current context when running a No Implicit Sender test as sender from an async test may leak
            //but we should not clear the current context when creating a testprobe from a test
            {
                InternalCurrentActorCellKeeper.Current = null;
            }
            SynchronizationContext.SetSynchronizationContext(
                new ActorCellKeepingSynchronizationContext(InternalCurrentActorCellKeeper.Current));
            _testActor = testActor;
        }
Exemple #6
0
        private TestKitBase(ITestKitAssertions assertions, ActorSystem system, Config config, string actorSystemName, string testActorName)
        {
            if(assertions == null) throw new ArgumentNullException("assertions");
            if(system == null)
            {
                var configWithDefaultFallback = config.SafeWithFallback(_defaultConfig);
                system = ActorSystem.Create(actorSystemName ?? "test", configWithDefaultFallback);
            }

            _assertions = assertions;
            _system = system;
            system.RegisterExtension(new TestKitExtension());
            system.RegisterExtension(new TestKitAssertionsExtension(assertions));
            _testKitSettings = TestKitExtension.For(_system);
            _queue = new BlockingQueue<MessageEnvelope>();
            _log = Logging.GetLogger(system, GetType());
            _eventFilterFactory = new EventFilterFactory(this);
            
            //register the CallingThreadDispatcherConfigurator
            _system.Dispatchers.RegisterConfigurator(CallingThreadDispatcher.Id,
                new CallingThreadDispatcherConfigurator(_system.Settings.Config, _system.Dispatchers.Prerequisites));

            if (string.IsNullOrEmpty(testActorName))
                testActorName = "testActor" + _testActorId.IncrementAndGet();

            var testActor = CreateTestActor(system, testActorName);
            //Wait for the testactor to start
            AwaitCondition(() =>
            {
                var repRef = testActor as IRepointableRef;
                return repRef == null || repRef.IsStarted;
            }, TimeSpan.FromSeconds(5), TimeSpan.FromMilliseconds(10));

            if(!(this is INoImplicitSender))
            {
                InternalCurrentActorCellKeeper.Current = (ActorCell)((ActorRefWithCell)testActor).Underlying;
            }
            else if(!(this is TestProbe)) 
                //HACK: we need to clear the current context when running a No Implicit Sender test as sender from an async test may leak
                //but we should not clear the current context when creating a testprobe from a test
            {
                InternalCurrentActorCellKeeper.Current = null;
            }
            SynchronizationContext.SetSynchronizationContext(
                new ActorCellKeepingSynchronizationContext(InternalCurrentActorCellKeeper.Current));
            _testActor = testActor;

        }
 protected RemoteDeploymentDeathWatchSpec(RemoteDeploymentDeathWatchSpecConfig specConfig)
     : base(specConfig)
 {
     _specConfig = specConfig;
     _assertions = new XunitAssertions();
 }
Exemple #8
0
 /// <summary>
 /// Create a new instance of the <see cref="TestKitBase"/> class.
 /// If no <paramref name="system"/> is passed in, a new system
 /// with <see cref="DefaultConfig"/> will be created.
 /// </summary>
 /// <param name="assertions">The framework-specific assertion tools.</param>
 /// <param name="system">Optional: The actor system.</param>
 /// <param name="testActorName">Optional: The name of the TestActor.</param>
 /// <exception cref="ArgumentNullException">
 /// This exception is thrown when the given <paramref name="assertions"/> is undefined.
 /// </exception>
 protected TestKitBase(ITestKitAssertions assertions, ActorSystem system = null, string testActorName = null)
     : this(assertions, system, _defaultConfig, null, testActorName)
 {
 }
Exemple #9
0
 /// <summary>
 /// Create a new instance of the <see cref="TestKitBase"/> class.
 /// A new system with the specified configuration will be created.
 /// </summary>
 /// <param name="assertions">The set of assertions used by the TestKit.</param>
 /// <param name="setup">The <see cref="ActorSystemSetup"/> to use for the configuring the system.</param>
 /// <param name="actorSystemName">Optional: the name of the ActorSystem.</param>
 /// <param name="testActorName">Optional: the name of the TestActor.</param>
 /// <exception cref="ArgumentNullException">
 /// This exception is thrown when the given <paramref name="assertions"/> is undefined.
 /// </exception>
 protected TestKitBase(ITestKitAssertions assertions, ActorSystemSetup setup, string actorSystemName = null, string testActorName = null)
     : this(assertions, null, setup, actorSystemName, testActorName)
 {
 }
Exemple #10
0
 /// <summary>
 /// Create a new instance of the <see cref="TestKitBase"/> class.
 /// A new system with the specified configuration will be created.
 /// </summary>
 /// <param name="assertions">TBD</param>
 /// <param name="config">The configuration to use for the system.</param>
 /// <param name="actorSystemName">TBD</param>
 /// <param name="testActorName">Optional: The name of the TestActor.</param>
 /// <exception cref="ArgumentNullException">
 /// This exception is thrown when the given <paramref name="assertions"/> is undefined.
 /// </exception>
 protected TestKitBase(ITestKitAssertions assertions, Config config, string actorSystemName = null, string testActorName = null)
     : this(assertions, null, config ?? ConfigurationFactory.Empty, actorSystemName, testActorName)
 {
 }
Exemple #11
0
 /// <summary>
 /// Create a new instance of the <see cref="TestKitBase"/> class.
 /// A new system with the specified configuration will be created.
 /// </summary>
 /// <param name="assertions">The set of assertions used by the TestKit.</param>
 /// <param name="config">The configuration to use for the system.</param>
 /// <param name="actorSystemName">Optional: the name of the ActorSystem.</param>
 /// <param name="testActorName">Optional: the name of the TestActor.</param>
 /// <exception cref="ArgumentNullException">
 /// This exception is thrown when the given <paramref name="assertions"/> is undefined.
 /// </exception>
 protected TestKitBase(ITestKitAssertions assertions, Config config, string actorSystemName = null, string testActorName = null)
     : this(assertions, null, ActorSystemSetup.Empty.WithSetup(BootstrapSetup.Create().WithConfig(config)), actorSystemName, testActorName)
 {
 }
Exemple #12
0
 protected MultiNodeClusterSpec(MultiNodeConfig config, Type type)
     : base(config, type)
 {
     _assertions       = new XunitAssertions();
     _roleNameComparer = new RoleNameComparer(this);
 }
 /// <summary>
 /// Create a new instance of the <see cref="TestKitBase"/> class.
 /// If no <paramref name="system"/> is passed in, a new system 
 /// with <see cref="DefaultConfig"/> will be created.
 /// </summary>
 /// <param name="assertions"></param>
 /// <param name="system">Optional: The actor system.</param>
 /// <param name="testActorName">Optional: The name of the TestActor.</param>
 protected TestKitBase(ITestKitAssertions assertions, ActorSystem system = null, string testActorName=null)
     : this(assertions, system, _defaultConfig, null, testActorName)
 {
 }
 /// <summary>
 /// Create a new instance of the <see cref="TestKitBase"/> class.
 /// A new system with the specified configuration will be created.
 /// </summary>
 /// <param name="config">The configuration to use for the system.</param>
 /// <param name="testActorName">Optional: The name of the TestActor.</param>
 /// <param name="assertions"></param>
 /// <param name="actorSystemName"></param>
 protected TestKitBase(ITestKitAssertions assertions, Config config, string actorSystemName = null, string testActorName = null)
     : this(assertions, null, config ?? ConfigurationFactory.Empty, actorSystemName, testActorName)
 {
 }
 public TestKitAssertionsProvider(ITestKitAssertions assertions)
 {
     _assertions = assertions;
 }
Exemple #16
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="system">TBD</param>
 /// <param name="assertions">TBD</param>
 /// <param name="testProbeName">TBD</param>
 public TestProbe(ActorSystem system, ITestKitAssertions assertions, string testProbeName = null)
     : base(assertions, system, testProbeName)
 {
 }
 public TestKitAssertionsProvider(ITestKitAssertions assertions)
 {
     _assertions = assertions;
 }
 protected RemoteDeploymentDeathWatchSpec(RemoteDeploymentDeathWatchSpecConfig specConfig)
     : base(specConfig)
 {
     _specConfig = specConfig;
     _assertions = new XunitAssertions();
 }
Exemple #19
0
 /// <summary>
 /// Create a new instance of the <see cref="TestKitBase"/> class.
 /// If no <paramref name="system"/> is passed in, a new system
 /// with <see cref="DefaultConfig"/> will be created.
 /// </summary>
 /// <param name="assertions">The framework-specific assertion tools.</param>
 /// <param name="system">Optional: The actor system.</param>
 /// <param name="testActorName">Optional: The name of the TestActor.</param>
 /// <exception cref="ArgumentNullException">
 /// This exception is thrown when the given <paramref name="assertions"/> is undefined.
 /// </exception>
 protected TestKitBase(ITestKitAssertions assertions, ActorSystem system = null, string testActorName = null)
     : this(assertions, system, ActorSystemSetup.Empty.WithSetup(BootstrapSetup.Create().WithConfig(_defaultConfig)), null, testActorName)
 {
 }
Exemple #20
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="assertions">TBD</param>
 public TestKitAssertionsExtension(ITestKitAssertions assertions)
 {
     _assertions = assertions;
 }
 public EventListener(string locationId, IActorRef eventLog, ActorSystem system, ITestKitAssertions assertions, string aggregateId = null)
     : base(system, assertions, "EventListener-" + locationId)
 {
     LocationId  = locationId;
     EventLog    = eventLog;
     AggregateId = aggregateId;
     View        = system.ActorOf(Props.Create(() => new EventListenerView(this)));
 }