Beispiel #1
0
        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));
            }
                );
        }
Beispiel #2
0
 /// <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));
 }
Beispiel #6
0
 private void TearDownCore()
 {
     ScenarioHelper.Clear();
 }
Beispiel #7
0
 public void WhenIOpenTheApplication()
 {
     ScenarioHelper.CreateRootObject();
     StructureHelper.SetRootObject(ScenarioHelper.RootObject);
     ScreenExtensions.TryActivate(ScenarioHelper.RootObject);
 }
Beispiel #8
0
 protected override void SetupOverride()
 {
     LogoFX.Client.Testing.Shared.TestHelper.Setup();
     ServiceRegistrationHelper.RegisterIntegrationObjects();
     ScenarioHelper.Add(new BuilderRegistrationService(), typeof(IBuilderRegistrationService));
 }
Beispiel #9
0
 // ReSharper disable once RedundantOverridenMember
 protected override void RegisterFakes()
 {
     base.RegisterFakes();
     RegistrationHelper.RegisterBuilder(ScenarioHelper.Registrator, ScenarioHelper.GetOrCreate(WarehouseProviderBuilder.CreateBuilder));
 }