Beispiel #1
0
        public void CaseDefault_AlreadyExists_ThrowsException()
        {
            CaseBuilder cb = Channel.CaseRead <int>(Channel.CreateUnbounded <int>(), i => { }).CaseDefault(() => { });

            Assert.Throws <InvalidOperationException>(() => cb.CaseDefault(() => { }));
            Assert.Throws <InvalidOperationException>(() => cb.CaseDefault(() => Task.CompletedTask));
        }
Beispiel #2
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));
        }
Beispiel #3
0
        public void CaseDefault_Async_InvalidAction_ThrowsException()
        {
            CaseBuilder builder1 = Channel.CaseRead <int>(Channel.CreateUnbounded <int>(), i => Task.CompletedTask);

            Assert.Throws <ArgumentNullException>(() => builder1.CaseDefault((Func <Task>)null));
        }
Beispiel #4
0
        public void CaseDefault_Sync_InvalidAction_ThrowsException()
        {
            CaseBuilder builder1 = Channel.CaseRead <int>(Channel.CreateUnbounded <int>(), i => { });

            Assert.Throws <ArgumentNullException>(() => builder1.CaseDefault((Action)null));
        }