public async Task HttpResponseExceptionWithExplicitStatusCode(string throwAt) { HttpRequestMessage request = new HttpRequestMessage(); request.RequestUri = new Uri( ScenarioHelper.BaseAddress + "/ExceptionTests/ReturnString" ); request.Method = HttpMethod.Post; request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); request.Content = new StringContent( "\"" + throwAt + "\"", Encoding.UTF8, "application/json" ); await ScenarioHelper.RunTestAsync( "ExceptionTests", "/{action}", request, async response => { Assert.NotNull(response.Content); Assert.NotNull(response.Content.Headers.ContentType); Assert.Equal( "application/json", response.Content.Headers.ContentType.MediaType ); if (throwAt == "DoNotThrow") { Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.Equal( "Hello World!", await response.Content.ReadAsAsync <string>( new List <MediaTypeFormatter>() { new JsonMediaTypeFormatter() } ) ); } else { Assert.Equal(HttpStatusCode.NotFound, response.StatusCode); Assert.Equal( String.Format("Error at {0}", throwAt), await response.Content.ReadAsAsync <string>( new List <MediaTypeFormatter>() { new JsonMediaTypeFormatter() } ) ); } }, config => { config.Services.Replace( typeof(IContentNegotiator), new CustomContentNegotiator(throwAt) ); config.MessageHandlers.Add(new CustomMessageHandler(throwAt)); config.Filters.Add(new CustomActionFilterAttribute(throwAt)); config.Filters.Add(new CustomAuthorizationFilterAttribute(throwAt)); config.Filters.Add(new CustomAuthenticationFilter(throwAt)); config.Filters.Add(new CustomExceptionFilterAttribute(throwAt)); config.Formatters.Clear(); config.Formatters.Add(new CustomJsonMediaTypeFormatter(throwAt)); } ); }
/// <summary> /// Resolves steps provider by type. /// </summary> /// <typeparam name="TStepsProvider">The type of steps provider.</typeparam> /// <returns>The steps provider.</returns> protected TStepsProvider GetStepsProvider <TStepsProvider>() where TStepsProvider : class, IStepsProvider { return(ScenarioHelper.Get <TStepsProvider>()); }
protected void TearDownCore() { ScenarioHelper.Clear(); }
private void StartScenario(string type) { _scenario = new ScenarioHelper(_sus, type); _scenario.Start(); }
public static void RegisterIntegrationObjects() { ScenarioHelper.Add(new StartApplicationService(), typeof(IStartApplicationService)); ScenarioHelper.Add(new LoginScreenObject(), typeof(ILoginScreenObject)); ScenarioHelper.Add(new MainScreenObject(), typeof(IMainScreenObject)); }
private void TearDownCore() { ScenarioHelper.Clear(); }
public void WhenIOpenTheApplication() { ScenarioHelper.CreateRootObject(); StructureHelper.SetRootObject(ScenarioHelper.RootObject); ScreenExtensions.TryActivate(ScenarioHelper.RootObject); }
protected override void SetupOverride() { LogoFX.Client.Testing.Shared.TestHelper.Setup(); ServiceRegistrationHelper.RegisterIntegrationObjects(); ScenarioHelper.Add(new BuilderRegistrationService(), typeof(IBuilderRegistrationService)); }
// ReSharper disable once RedundantOverridenMember protected override void RegisterFakes() { base.RegisterFakes(); RegistrationHelper.RegisterBuilder(ScenarioHelper.Registrator, ScenarioHelper.GetOrCreate(WarehouseProviderBuilder.CreateBuilder)); }