public void When_Register_called_with_registered_MockService_Then_throws_with_useful_message() { var mockService = new MockService(); Action register = () => MockServiceRepository.Register(mockService); register .ShouldThrow <InvalidOperationException>("Because that MockService is already registered") .WithMessage("ServiceId in use", "Because that helps debug the issue"); }
public MockService(bool ignoreUnusedHandlers = false) { _portNumber = PortRepository.GetFreePortNumber(); _handlers = new List <Tuple <Expression <Func <IOwinContext, bool> >, Func <IOwinContext, Task> > >(); _unusedHandlers = new List <Expression <Func <IOwinContext, bool> > >(); _ignoreUnusedHandlers = ignoreUnusedHandlers; MockServiceRepository.Register(_portNumber, this); _host = WebApp.Start <MockStartup>(GetBaseAddress()); }