示例#1
0
        public void CaseReadWrite_Async_CallMultipleTimes_IdempotentResult()
        {
            Channel.CaseBuilder builder1 = Channel.CaseRead(Channel.Create <int>(), i => Task.CompletedTask);
            Assert.Same(builder1, builder1.CaseRead(Channel.Create <int>(), i => Task.CompletedTask));
            Assert.Same(builder1, builder1.CaseWrite(Channel.Create <string>(), "", () => Task.CompletedTask));
            Assert.Same(builder1, builder1.CaseDefault(() => Task.CompletedTask));

            Channel.CaseBuilder builder2 = Channel.CaseWrite(Channel.Create <int>(), 0, () => Task.CompletedTask);
            Assert.Same(builder2, builder2.CaseRead(Channel.Create <int>(), i => Task.CompletedTask));
            Assert.Same(builder2, builder2.CaseWrite(Channel.Create <string>(), "", () => Task.CompletedTask));
            Assert.Same(builder2, builder2.CaseDefault(() => Task.CompletedTask));
        }
示例#2
0
 public void CaseDefault_AlreadyExists_ThrowsException()
 {
     Channel.CaseBuilder cb = Channel.CaseRead(Channel.Create <int>(), i => { }).CaseDefault(() => { });
     Assert.Throws <InvalidOperationException>(() => cb.CaseDefault(() => { }));
     Assert.Throws <InvalidOperationException>(() => cb.CaseDefault(() => Task.CompletedTask));
 }
示例#3
0
 public void CaseDefault_Async_InvalidAction_ThrowsException()
 {
     Channel.CaseBuilder builder1 = Channel.CaseRead(Channel.Create <int>(), i => Task.CompletedTask);
     Assert.Throws <ArgumentNullException>(() => builder1.CaseDefault((Func <Task>)null));
 }
示例#4
0
 public void CaseDefault_Sync_InvalidAction_ThrowsException()
 {
     Channel.CaseBuilder builder1 = Channel.CaseRead(Channel.Create <int>(), i => { });
     Assert.Throws <ArgumentNullException>(() => builder1.CaseDefault((Action)null));
 }