using System; using NUnit.Framework; using ServiceStack.WebHost.Endpoints.Tests.Support.Host; namespace ServiceStack.WebHost.Endpoints.Tests { public class ServiceHostTestBase { public static TestAppHost CreateAppHost() { var appHost = new TestAppHost(); appHost.Init(); return appHost; } public void ShouldThrow(Action action) where T : Exception { ShouldThrow(action, "Should Throw"); } public void ShouldThrow(Action action, string errorMessageIfNotThrows) where T : Exception { try { action(); } catch (T) { return; } Assert.Fail(errorMessageIfNotThrows); } public void ShouldNotThrow(Action action) where T : Exception { ShouldNotThrow(action, "Should not Throw"); } public void ShouldNotThrow(Action action, string errorMessageIfThrows) where T : Exception { try { action(); } catch (T) { Assert.Fail(errorMessageIfThrows); } } } }