public async Task Throws_exception_if_IHttpContextProvider_not_registered() { var app = new ClientsideFixture <StartupWithContainerWithoutHttpContextAccessor>(); bool thrown = false; Exception ex = new Exception(); try { var msg = await app.RunRulesetAction("/ClientSide/SpecifiedRuleset"); } catch (InvalidOperationException e) { thrown = true; ex = e; } thrown.ShouldBeTrue(); ex.Message.ShouldEqual("Cannot use the RuleSetForClientSideMessagesAttribute unless the IHttpContextAccessor is registered with the service provider. Make sure the provider is registered by calling services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>(); in your Startup class's ConfigureServices method"); }
public ClientsideMessageTester(ClientsideFixture <StartupWithContainer> webApp) { _webApp = webApp; CultureScope.SetDefaultCulture(); }