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)); }
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)); }
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)); }
public void CaseDefault_Sync_InvalidAction_ThrowsException() { Channel.CaseBuilder builder1 = Channel.CaseRead(Channel.Create <int>(), i => { }); Assert.Throws <ArgumentNullException>(() => builder1.CaseDefault((Action)null)); }