public EchoActor(TestKitBase testkit, bool echoBackToSenderAsWell=true) { ReceiveAny(msg => { var sender = Sender; var testActor = testkit.TestActor; if(echoBackToSenderAsWell && testActor != sender) sender.Forward(msg); testActor.Tell(msg,Sender); }); }
public ScriptRunner( Func <Flow <TIn, TIn, NotUsed>, Flow <TIn, TOut, TMat> > op, ActorMaterializerSettings settings, Script <TIn, TOut> script, int maximumOverrun, int maximumRequests, int maximumBuffer, TestKitBase system) : base(op, settings, ToPublisher, system) { _currentScript = script; _maximumRequests = maximumRequests; _maximumBuffer = maximumBuffer; _remainingDemand = _currentScript.ExpectedOutputs.Length + ThreadLocalRandom.Current.Next(1, maximumOverrun); DebugLog($"Starting with remaining demand={_remainingDemand}"); }
public void Add( IDependencyResolverAdder dependencyResolverAdder, ITestProbeChildActorCreator testProbeChildActorCreator, ITestProbeCreator testProbeCreator, IResolvedTestProbeStore resolvedTestProbeStore, IWaiter childWaiter, TestKitBase testKit, ImmutableDictionary <Type, ImmutableDictionary <Type, Func <object, object> > > handlers) => dependencyResolverAdder.Add(testKit, actorType => { ImmutableDictionary <Type, Func <object, object> > actorHandlers = handlers.GetValueOrDefault(actorType, null); ITestProbeChildActor probeActor = testProbeChildActorCreator.Create(testProbeCreator, testKit, actorHandlers); resolvedTestProbeStore.ResolveProbe(probeActor.ActorPath, actorType, probeActor.TestProbe, probeActor.PropsSupervisorStrategy); childWaiter.ResolveEvent(); return(probeActor.Actor); });
public TestSetup(TestKitBase kit, bool pullMode) { _kit = kit; _pullMode = pullMode; _handler = kit.CreateTestProbe(); _handlerRef = _handler.Ref; _bindCommander = kit.CreateTestProbe(); _parent = kit.CreateTestProbe(); _selectorRouter = kit.CreateTestProbe(); _endpoint = TestUtils.TemporaryServerAddress(); _registerCallReceiver = kit.CreateTestProbe(); _interestCallReceiver = kit.CreateTestProbe(); _parentRef = new TestActorRef <ListenerParent>(kit.Sys, Props.Create(() => new ListenerParent(this, pullMode))); }
public TestBase() : base(AkkaConfig.Config) { // Create shims _shimContext = ShimsContext.Create(); TestKitBaseShim = new ShimTestKitBase(new ShimTestKit()); // Create objects passed into sut methods TestKitBase = TestKitBaseShim.Instance; // Set up shims TestKitBaseShim.CreateTestProbeString = name => { CallCount++; NamePassedIntoShim = name; TestProbeReturnedFromShim = CreateTestProbe(); return(TestProbeReturnedFromShim); }; }
public ChainSetup( Func <Flow <TIn, TIn, NotUsed>, Flow <TIn, TOut, TMat> > stream, ActorMaterializerSettings settings, ActorMaterializer materializer, Func <Source <TOut, NotUsed>, ActorMaterializer, IPublisher <TOut> > toPublisher, TestKitBase system) { Settings = settings; System = system; Upstream = system.CreateManualPublisherProbe <TIn>(); Downstream = system.CreateSubscriberProbe <TOut>(); var s = Source.FromPublisher(Upstream).Via(stream(Flow.Identity <TIn>().Select(x => x).Named("buh"))); Publisher = toPublisher(s, materializer); UpstreamSubscription = Upstream.ExpectSubscription(); Publisher.Subscribe(Downstream); DownstreamSubscription = Downstream.ExpectSubscription(); }
public TestProbeChildActor(ITestProbeCreator testProbeCreator, TestKitBase testKit, IReadOnlyDictionary <Type, Func <object, object> > handlers = null) { ActorPath = Context.Self.Path; TestProbe = testProbeCreator.Create(testKit); PropsSupervisorStrategy = Context.Props.SupervisorStrategy; ReceiveAny(o => TestProbe.Forward(o)); if (handlers != null) { TestProbe.SetAutoPilot(new DelegateAutoPilot((sender, message) => { Type messageType = message.GetType(); if (handlers.TryGetValue(messageType, out Func <object, object> handler)) { object reply = handler(message); Context.Sender.Tell(reply); } return(AutoPilot.KeepRunning); })); } }
public ServerConnection(TestKitBase testkit, IActorRef connectionActor) { _connectionActor = connectionActor; _connectionProbe = testkit.CreateTestProbe(); }
public ProbeSource(TestKitBase testKit, Attributes attributes, SourceShape <T> shape) : base(shape) { _testKit = testKit; _attributes = attributes; }
internal ManualProbe(TestKitBase system, bool autoOnSubscribe = true) { _probe = system.CreateTestProbe(); AutoOnSubscribe = autoOnSubscribe; }
/// <summary> /// Probe that implements <see cref="IPublisher{T}"/> interface. /// </summary> public static ManualProbe <T> CreateManualPublisherProbe <T>(this TestKitBase testKit, bool autoOnSubscribe = true) => new ManualProbe <T>(testKit, autoOnSubscribe);
/// <summary> /// TBD /// </summary> /// <param name="testkit">TBD</param> /// <param name="echoBackToSenderAsWell">TBD</param> public StashingActor(TestKitBase testkit, bool echoBackToSenderAsWell = true) { _testkit = testkit; _echoBackToSenderAsWell = echoBackToSenderAsWell; StashAll(); }
public static void RiverOf <T>(Action <ISubscriber <T>, Flow <int, string, NotUsed>, IEnumerable <int> > flowConstructor, TestKitBase kit) { var subscriber = TestSubscriber.CreateManualProbe <T>(kit); var elements = Enumerable.Range(1, 10).ToList(); flowConstructor(subscriber, OtherFlow, elements); var subscription = subscriber.ExpectSubscription(); subscription.Request(elements.Count); elements.ForEach(el => subscriber.ExpectNext().Should().Be(el.ToString())); subscription.Request(1); subscriber.ExpectComplete(); }
public TestStage(IActorRef probe, SideChannel sideChanngel, TestKitBase testKit) { _probe = probe; _sideChanngel = sideChanngel; _testKit = testKit; }
public TestSetup(TestKitBase kit) : this(kit, TestUtils.TemporaryServerAddress()) { }
/// <summary> /// A Sink that materialized to a <see cref="TestSubscriber.Probe{T}"/>. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="testKit"></param> /// <returns></returns> public static Sink <T, TestSubscriber.Probe <T> > SinkProbe <T>(this TestKitBase testKit) { return(new Sink <T, TestSubscriber.Probe <T> >(new StreamTestKit.ProbeSink <T>(testKit, Attributes.None, new SinkShape <T>(new Inlet <T>("ProbeSink.in"))))); }
internal ManualProbe(TestKitBase testKit) { _testKit = testKit; _probe = testKit.CreateTestProbe(); }
public AggregateFixture( TestKitBase testKit) { _testKit = testKit; }
/// <summary> /// Returns a <see cref="Props"/> object that can be used to create an <see cref="EchoActor"/>. /// The <see cref="EchoActor"/> echoes whatever is sent to it, to the /// TestKit's <see cref="TestKitBase.TestActor"/>. /// By default it also echoes back to the sender, unless the sender is the <see cref="TestKitBase.TestActor"/> /// (in this case the <see cref="TestKitBase.TestActor"/> will only receive one message) or unless /// <paramref name="echoBackToSenderAsWell"/> has been set to <c>false</c>. /// </summary> /// <param name="testkit">TBD</param> /// <param name="echoBackToSenderAsWell">TBD</param> /// <returns>TBD</returns> public static Props Props(TestKitBase testkit, bool echoBackToSenderAsWell = true) { return(Akka.Actor.Props.Create(() => new StashingActor(testkit, echoBackToSenderAsWell))); }
/// <summary> /// A Source that materializes to a <see cref="TestPublisher.Probe{T}"/>. /// </summary> public static Source <T, TestPublisher.Probe <T> > SourceProbe <T>(this TestKitBase testKit) { return(new Source <T, TestPublisher.Probe <T> >(new StreamTestKit.ProbeSource <T>(testKit, Attributes.None, new SourceShape <T>(new Outlet <T>("ProbeSource.out"))))); }
internal Probe(TestKitBase system, long initialPendingRequests) : base(system) { _initialPendingRequests = Pending = initialPendingRequests; _subscription = new Lazy <StreamTestKit.PublisherProbeSubscription <T> >(ExpectSubscription); }
public StateObj(TestKitBase testKit) { S = ""; Finished = testKit.CreateTestBarrier(2); }
public static Probe <T> CreatePublisherProbe <T>(this TestKitBase testKit, long initialPendingRequests = 0L) => new Probe <T>(testKit, initialPendingRequests);
/// <summary> /// TBD /// </summary> /// <param name="testkit">TBD</param> /// <param name="system">TBD</param> /// <param name="filters">TBD</param> public InternalEventFilterApplier(TestKitBase testkit, ActorSystem system, IReadOnlyList <EventFilterBase> filters) { _filters = filters; _testkit = testkit; _actorSystem = system; }
public UnacceptedConnectionTest(TestKitBase kit, bool pullMode = false) : base(kit) { _pullMode = pullMode; }
public StreamPuppet(IPublisher <int> p, TestKitBase kit) { _probe = TestSubscriber.CreateManualProbe <int>(kit); p.Subscribe(_probe); _subscription = _probe.ExpectSubscription(); }
/// <summary> /// Returns a <see cref="Props"/> object that can be used to create an <see cref="EchoActor"/>. /// The <see cref="EchoActor"/> echoes whatever is sent to it, to the /// TestKit's <see cref="TestKitBase.TestActor">TestActor</see>. /// By default it also echoes back to the sender, unless the sender is the TestActor /// (in this case the TestActor will only receive one message) or unless /// <paramref name="echoBackToSenderAsWell"/> has been set to <c>false</c>. /// </summary> public static Props Props(TestKitBase testkit, bool echoBackToSenderAsWell = true) { return Actor.Props.Create(()=>new EchoActor(testkit, echoBackToSenderAsWell)); }
internal Probe(TestKitBase testKit) : base(testKit) { _subscription = new Lazy <ISubscription>(ExpectSubscription); }
public ProbeSink(TestKitBase testKit, Attributes attributes, SinkShape <T> shape) : base(shape) { _testKit = testKit; _attributes = attributes; }
public static ManualProbe <T> CreateManualSubscriberProbe <T>(this TestKitBase testKit) { return(new ManualProbe <T>(testKit)); }
public TcpReadProbe(TestKitBase testkit) { SubscriberProbe = testkit.CreateManualSubscriberProbe <ByteString>(); TcpReadSubscription = new Lazy <ISubscription>(() => SubscriberProbe.ExpectSubscription()); }
public static Probe <T> CreateSubscriberProbe <T>(this TestKitBase testKit) { return(new Probe <T>(testKit)); }