public async Task SubscribeEmptyBodyTest() { request = new DefaultHttpRequest(new DefaultHttpContext()) { Body = new MemoryStream(Encoding.ASCII.GetBytes("")) }; var response = await SubscriptionTriggerSubscribe.Run(request, client, log); Assert.IsInstanceOfType(response, typeof(BadRequestObjectResult)); Assert.IsTrue((((BadRequestObjectResult)response).Value as string).Contains("Empty")); }
public async Task SubscribeTest() { request = new DefaultHttpRequest(new DefaultHttpContext()) { Body = new MemoryStream(Encoding.ASCII.GetBytes(JsonConvert.SerializeObject(sub))) }; var response = await SubscriptionTriggerSubscribe.Run(request, client, log); Assert.IsInstanceOfType(response, typeof(OkResult)); }
public void Initialize() { log = NullLoggerFactory.Instance.CreateLogger("Dummy"); sub = new PushSubscriptionInformation(); sub.EndPoint = "https://dummy_endpoint"; sub.ExpirationTime = null; sub.Keys = new Keys(); sub.Keys.Authentication = "dummy_authentication"; sub.Keys.p256dh = "dummy_p256dh"; Environment.SetEnvironmentVariable("DatabaseId", TestContext.Properties["DatabaseId"].ToString(), EnvironmentVariableTarget.Process); Environment.SetEnvironmentVariable("CollectionId", TestContext.Properties["CollectionId"].ToString(), EnvironmentVariableTarget.Process); Environment.SetEnvironmentVariable("AzureWebJobsStorage", TestContext.Properties["AzureWebJobsStorage"].ToString(), EnvironmentVariableTarget.Process); client = new DocumentClient(new Uri(TestContext.Properties["AccountEndpoint"].ToString()), TestContext.Properties["AccountKey"].ToString()); notificationQueueService = new NotificationQueueService(); subscriptionService = new SubscriptionService(notificationQueueService); subscriptionTriggerSubscribe = new SubscriptionTriggerSubscribe(subscriptionService); }