public void Setup() { // Setup Defaults var restDefaults = RestConfiguration.JsonDefault(); restDefaults.WithBaseUrl("http://test.starnow.local/"); _configuration = restDefaults; // Setup Factory var factory = Factories.Default(); restDefaults.ClientFactory = factory; _factory = factory as TestApiFactory; }
public async Task TestNotificationFlow() { var token = GetAccessToken(); var f = new TestApiFactory(); var cl = f.CreateClient(); var observable = (ResetEventTestObserver)f.Services.GetService(typeof(ResetEventTestObserver)); cl.SetBearerToken(token); var response = await cl.PostAsync("/notification/Eshopworld.Web.Tests.NotificationChannelMiddlewareTests+TestNotificationSubType,Eshopworld.Web.Tests", new StringContent(JsonConvert.SerializeObject(new TestNotificationSubType()), Encoding.UTF8, "application/json")); response.IsSuccessStatusCode.Should().BeTrue(); observable.TestNotificationSubTypeResetEvent.WaitOne(TimeSpan.FromSeconds(1)).Should().BeTrue(); }
public ProductEndpointsTests(TestApiFactory <Startup> factory) { _factory = factory; }
public void Setup() { _configuration = RestConfigurationHelper.Default(); _factory = _configuration.ClientFactory as TestApiFactory; }
public Tests(TestApiFactory <TestStartup> appFactory) { AppFactory = appFactory; }
public static IClientBuilder Default() { var factory = new TestApiFactory(); // Products var appleProduct = new Product() { Name = "Apple", ExpiryDateTime = new DateTime(2017, 1, 23, 10, 23, 55, DateTimeKind.Utc), Price = 1.24, Sizes = new List <string>() { "Small", "Large" } }; var melonProduct = new Product() { Name = "Melon", ExpiryDateTime = new DateTime(2017, 1, 23, 10, 23, 55, DateTimeKind.Utc), Price = 10, Sizes = new List <string>() { "Large" } }; // Promos var melonPromo = new Promo() { Product = melonProduct, Discount = 33.45 }; var applePromo = new Promo() { Product = appleProduct, Discount = 11 }; factory.Responses.Add("/promo/melon", melonPromo); factory.Responses.Add("/promo/apple", applePromo); factory.Responses.Add("/promo", new List <Promo>() { applePromo, melonPromo }); factory.Responses.Add("/product/apple", appleProduct); factory.Responses.Add("/product", new List <Product> { melonProduct, appleProduct }); factory.Responses.Add("/product/empty", new List <Product> { }); factory.Responses.Add("/null", null); return(factory); }