Пример #1
0
        static Scenario BuildScenario()
        {
            var server = new FakePushServer();

            var step1 = Step.CreateRequest("publish", async req =>
            {
                var clientId = req.CorrelationId;
                var message  = $"Hi Server from client: {clientId}";

                server.Publish(clientId, message);
                return(Response.Ok());
            });

            var listenerChannel = Step.CreateListenerChannel();

            server.Notify += (s, pushNotification) =>
            {
                listenerChannel.Notify(correlationId: pushNotification.ClientId,
                                       response: Response.Ok(pushNotification.Message));
            };

            var step2 = Step.CreateListener("listen", listenerChannel);

            return(new ScenarioBuilder(scenarioName: "PushScenario")
                   .AddTestFlow("test push ", steps: new[] { step1, step2 }, concurrentCopies: 1)
                   .Build(duration: TimeSpan.FromSeconds(3)));
        }
Пример #2
0
        static Scenario BuildScenario()
        {
            var server         = new FakePushServer();
            var updatesChannel = GlobalUpdatesChannel.Instance;

            var step1 = Step.CreatePull("publish", async req =>
            {
                var clientId = req.CorrelationId;
                var message  = $"Hi Server from client: {clientId}";

                server.Publish(clientId, message);
                return(Response.Ok());
            });

            var step2 = Step.CreatePush("update from server");

            server.Notify += (s, pushNotification) =>
            {
                updatesChannel.ReceivedUpdate(
                    correlationId: pushNotification.ClientId,
                    pushStepName: step2.Name,
                    update: Response.Ok(pushNotification.Message)
                    );
            };

            return(ScenarioBuilder.CreateScenario("PushScenario", step1, step2)
                   .WithConcurrentCopies(1)
                   .WithDuration(TimeSpan.FromSeconds(3)));
        }