Exemplo n.º 1
0
        public void CaseRead_Async_InvalidArguments_ThrowsArgumentException()
        {
            CaseBuilder cb = Channel.CaseRead <int>(Channel.CreateUnbounded <int>(), i => { });

            Assert.Throws <ArgumentNullException>("channel", () => cb.CaseRead <int>(null, (Func <int, Task>)null));
            Assert.Throws <ArgumentNullException>("channel", () => cb.CaseRead <int>(null, i => Task.CompletedTask));
            Assert.Throws <ArgumentNullException>("func", () => cb.CaseRead <int>(Channel.CreateUnbounded <int>(), (Func <int, Task>)null));
        }
Exemplo n.º 2
0
        public void CaseRead_Sync_InvalidArguments_ThrowsArgumentException()
        {
            CaseBuilder cb = Channel.CaseRead <int>(Channel.CreateUnbounded <int>(), i => { });

            Assert.Throws <ArgumentNullException>("channel", () => cb.CaseRead <int>(null, (Action <int>)null));
            Assert.Throws <ArgumentNullException>("channel", () => cb.CaseRead <int>(null, i => { }));
            Assert.Throws <ArgumentNullException>("action", () => cb.CaseRead <int>(Channel.CreateUnbounded <int>(), (Action <int>)null));
        }
Exemplo n.º 3
0
        public void CaseReadWrite_Async_CallMultipleTimes_IdempotentResult()
        {
            CaseBuilder builder1 = Channel.CaseRead <int>(Channel.CreateUnbounded <int>(), i => Task.CompletedTask);

            Assert.Same(builder1, builder1.CaseRead <int>(Channel.CreateUnbounded <int>(), i => Task.CompletedTask));
            Assert.Same(builder1, builder1.CaseWrite(Channel.CreateUnbounded <string>(), "", () => Task.CompletedTask));
            Assert.Same(builder1, builder1.CaseDefault(() => Task.CompletedTask));

            CaseBuilder builder2 = Channel.CaseWrite(Channel.CreateUnbounded <int>(), 0, () => Task.CompletedTask);

            Assert.Same(builder2, builder2.CaseRead <int>(Channel.CreateUnbounded <int>(), i => Task.CompletedTask));
            Assert.Same(builder2, builder2.CaseWrite(Channel.CreateUnbounded <string>(), "", () => Task.CompletedTask));
            Assert.Same(builder2, builder2.CaseDefault(() => Task.CompletedTask));
        }