public void Given_a_MatchAny_handler_has_been_added_When_adding_handler_Then_it_fails() { var builder = new MatchBuilder(new DummyCompiler <object>()); builder.MatchAny(_ => { }); //As we have added a handler that matches everything, adding another handler is pointless, so //the builder should throw an exception. Assert.Throws <InvalidOperationException>(() => ((Action)(() => builder.Match <object>(_ => { })))()); }
public void Given_builder_has_built_When_adding_handler_Then_it_fails() { var builder = new MatchBuilder(new DummyCompiler <object>()); builder.Match <object>(_ => { }); builder.Build(); //As we have built, no more handlers should be accepted Assert.Throws <InvalidOperationException>(() => ((Action)(() => builder.Match <string>(_ => { })))()); Assert.Throws <InvalidOperationException>(() => ((Action)(() => builder.MatchAny(_ => { })))()); }