Exemple #1
0
        public async Task TestClose()
        {
            var endpoint = new TestEndpoint("id");
            IEndpointExecutor executor = await Factory.CreateAsync(endpoint, null);

            Task running = executor.Invoke(Default, 0, 3600);

            await executor.CloseAsync();

            await running;

            Assert.True(running.IsCompleted);

            // ensure this doesn't throw
            await executor.CloseAsync();
        }
        public async Task <IEndpointExecutor> CreateAsync(Endpoint endpoint, ICheckpointer checkpointer, EndpointExecutorConfig endpointExecutorConfig)
        {
            IEndpointExecutor exec = await this.underlying.CreateAsync(endpoint, checkpointer, endpointExecutorConfig);

            await exec.CloseAsync();

            return(exec);
        }
        public async Task <IEndpointExecutor> CreateAsync(Endpoint endpoint)
        {
            IEndpointExecutor exec = await this.underlying.CreateAsync(endpoint);

            await exec.CloseAsync();

            return(exec);
        }
Exemple #4
0
        public async Task <IEndpointExecutor> CreateAsync(Endpoint endpoint, IList <uint> priorities, ICheckpointer checkpointer)
        {
            IEndpointExecutor exec = await this.underlying.CreateAsync(endpoint, priorities, checkpointer);

            await exec.CloseAsync();

            return(exec);
        }
Exemple #5
0
        public async Task TestClose()
        {
            var endpoint = new TestEndpoint("id");
            IEndpointExecutor executor = await Factory.CreateAsync(endpoint);

            Task running = executor.Invoke(Default);

            await executor.CloseAsync();

            await running;

            Assert.True(running.IsCompleted);

            // ensure this doesn't throw
            await executor.CloseAsync();

            await Assert.ThrowsAsync <InvalidOperationException>(() => executor.Invoke(Default));

            await Assert.ThrowsAsync <InvalidOperationException>(() => executor.SetEndpoint(endpoint));
        }
Exemple #6
0
        public async Task TestCancellation()
        {
            var endpoint = new StalledEndpoint("id");
            IEndpointExecutor executor = await Factory.CreateAsync(endpoint, null);

            Task running = executor.Invoke(Default, 0, 3600);

            await executor.CloseAsync();

            await running;

            Assert.True(running.IsCompleted);
        }
Exemple #7
0
        public async Task TestSetEndpoint()
        {
            var endpoint1 = new TestEndpoint("id1");
            var endpoint2 = new TestEndpoint("id1");
            var endpoint3 = new TestEndpoint("id3");
            IEndpointExecutor executor = await Factory.CreateAsync(endpoint1);

            Assert.Equal(new List <IMessage>(), endpoint1.Processed);
            Assert.Equal(new List <IMessage>(), endpoint2.Processed);
            Assert.Equal(new List <IMessage>(), endpoint3.Processed);
            await Assert.ThrowsAsync <ArgumentException>(() => executor.SetEndpoint(endpoint3));

            await executor.Invoke(Message1);

            await executor.Invoke(Message1);

            Assert.Equal(new List <IMessage> {
                Message1, Message1
            }, endpoint1.Processed);
            Assert.Equal(new List <IMessage>(), endpoint2.Processed);
            Assert.Equal(new List <IMessage>(), endpoint3.Processed);

            await executor.SetEndpoint(endpoint2);

            Assert.Equal(new List <IMessage> {
                Message1, Message1
            }, endpoint1.Processed);
            Assert.Equal(new List <IMessage>(), endpoint2.Processed);
            Assert.Equal(new List <IMessage>(), endpoint3.Processed);

            await executor.Invoke(Message2);

            await executor.Invoke(Message3);

            Assert.Equal(new List <IMessage> {
                Message1, Message1
            }, endpoint1.Processed);
            Assert.Equal(new List <IMessage> {
                Message2, Message3
            }, endpoint2.Processed);
            Assert.Equal(new List <IMessage>(), endpoint3.Processed);

            await executor.CloseAsync();
        }
Exemple #8
0
        public async Task TestSetEndpoint()
        {
            var endpoint1 = new TestEndpoint("id");
            var endpoint2 = new NullEndpoint("id");
            var endpoint3 = new TestEndpoint("id1");
            IEndpointExecutor executor = await Factory.CreateAsync(endpoint1, null);

            Assert.Equal(endpoint1, executor.Endpoint);
            await Assert.ThrowsAsync <ArgumentNullException>(() => executor.SetEndpoint(null, null));

            await Assert.ThrowsAsync <ArgumentException>(() => executor.SetEndpoint(endpoint3, null));

            await executor.SetEndpoint(endpoint2, null);

            Assert.Equal(endpoint2, executor.Endpoint);

            await executor.CloseAsync();

            await Assert.ThrowsAsync <InvalidOperationException>(() => executor.SetEndpoint(endpoint1, null));
        }