public static RemoveByteOrderMarkAndWhitespace ( string s ) : string | ||
s | string | |
리턴 | string |
public async Task QueueTriggerToBlobTest() { TestHelpers.ClearFunctionLogs("QueueTriggerToBlob"); string id = Guid.NewGuid().ToString(); string messageContent = string.Format("{{ \"id\": \"{0}\" }}", id); CloudQueueMessage message = new CloudQueueMessage(messageContent); await Fixture.TestQueue.AddMessageAsync(message); var resultBlob = Fixture.TestOutputContainer.GetBlockBlobReference(id); string result = await TestHelpers.WaitForBlobAndGetStringAsync(resultBlob); Assert.Equal(TestHelpers.RemoveByteOrderMarkAndWhitespace(messageContent), TestHelpers.RemoveByteOrderMarkAndWhitespace(result)); string userCategory = LogCategories.CreateFunctionUserCategory("QueueTriggerToBlob"); LogMessage traceEvent = await WaitForTraceAsync(p => p?.FormattedMessage != null && p.FormattedMessage.Contains(id) && string.Equals(p.Category, userCategory, StringComparison.Ordinal)); Assert.Equal(LogLevel.Information, traceEvent.Level); string trace = traceEvent.FormattedMessage; Assert.Contains("script processed queue message", trace); Assert.Contains(messageContent.Replace(" ", string.Empty), trace.Replace(" ", string.Empty)); }
public async Task HttpTrigger_CSharp_Poco_Post_Succeeds() { string uri = "api/httptrigger-csharp-poco?code=zlnu496ve212kk1p84ncrtdvmtpembduqp25ajjc"; HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, uri); string id = Guid.NewGuid().ToString(); JObject requestBody = new JObject { { "Id", id }, { "Value", "Testing" } }; request.Content = new StringContent(requestBody.ToString()); request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); HttpResponseMessage response = await this._fixture.HttpClient.SendAsync(request); Assert.Equal(HttpStatusCode.OK, response.StatusCode); // wait for function to execute and produce its result blob CloudBlobContainer outputContainer = _fixture.BlobClient.GetContainerReference("samples-output"); CloudBlockBlob outputBlob = outputContainer.GetBlockBlobReference(id); string result = await TestHelpers.WaitForBlobAndGetStringAsync(outputBlob); Assert.Equal("Testing", TestHelpers.RemoveByteOrderMarkAndWhitespace(result)); }
protected async Task ServiceBusQueueTriggerToBlobTestImpl() { var resultBlob = Fixture.TestOutputContainer.GetBlockBlobReference("completed"); await resultBlob.DeleteIfExistsAsync(); string id = Guid.NewGuid().ToString(); JObject message = new JObject { { "count", 0 }, { "id", id } }; using (Stream stream = new MemoryStream()) using (TextWriter writer = new StreamWriter(stream)) { writer.Write(message.ToString()); writer.Flush(); stream.Position = 0; await Fixture.ServiceBusQueueClient.SendAsync(new BrokeredMessage(stream) { ContentType = "text/plain" }); } // now wait for function to be invoked string result = await TestHelpers.WaitForBlobAndGetStringAsync(resultBlob); Assert.Equal(TestHelpers.RemoveByteOrderMarkAndWhitespace(id), TestHelpers.RemoveByteOrderMarkAndWhitespace(result)); }
public async Task HttpTrigger_CSharp_Poco_Get_Succeeds() { string id = Guid.NewGuid().ToString(); string uri = string.Format("api/httptrigger-csharp-poco?code=zlnu496ve212kk1p84ncrtdvmtpembduqp25ajjc&Id={0}&Value=Testing", id); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, uri); HttpResponseMessage response = await this._fixture.HttpClient.SendAsync(request); Assert.Equal(HttpStatusCode.OK, response.StatusCode); // wait for function to execute and produce its result blob CloudBlobContainer outputContainer = _fixture.BlobClient.GetContainerReference("samples-output"); CloudBlockBlob outputBlob = outputContainer.GetBlockBlobReference(id); string result = await TestHelpers.WaitForBlobAndGetStringAsync(outputBlob); Assert.Equal("Testing", TestHelpers.RemoveByteOrderMarkAndWhitespace(result)); }
public async Task HttpTrigger_CSharp_Poco_Post_Xml_Succeeds() { string uri = "api/httptrigger-csharp-poco?code=zlnu496ve212kk1p84ncrtdvmtpembduqp25ajjc"; HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, uri); string id = Guid.NewGuid().ToString(); request.Content = new StringContent(string.Format("<RequestData xmlns=\"http://functions\"><Id>{0}</Id><Value>Testing</Value></RequestData>", id)); request.Content.Headers.ContentType = new MediaTypeHeaderValue("text/xml"); HttpResponseMessage response = await this._fixture.HttpClient.SendAsync(request); Assert.Equal(HttpStatusCode.OK, response.StatusCode); // wait for function to execute and produce its result blob CloudBlobContainer outputContainer = _fixture.BlobClient.GetContainerReference("samples-output"); CloudBlockBlob outputBlob = outputContainer.GetBlockBlobReference(id); string result = await TestHelpers.WaitForBlobAndGetStringAsync(outputBlob); Assert.Equal("Testing", TestHelpers.RemoveByteOrderMarkAndWhitespace(result)); }
protected async Task ServiceBusQueueTriggerToBlobTestImpl() { // ServiceBus tests need the following environment var: // "AzureWebJobsServiceBus" -- the connection string for the ServiceBus account string testQueueName = "test-input"; string connectionString = AmbientConnectionStringProvider.Instance.GetConnectionString(ConnectionStringNames.ServiceBus); var namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString); await namespaceManager.DeleteQueueAsync(testQueueName); await namespaceManager.CreateQueueAsync(testQueueName); QueueClient queueClient = QueueClient.CreateFromConnectionString(connectionString, testQueueName); var resultBlob = Fixture.TestContainer.GetBlockBlobReference("completed"); await resultBlob.DeleteIfExistsAsync(); string id = Guid.NewGuid().ToString(); JObject message = new JObject { { "count", 0 }, { "id", id } }; using (Stream stream = new MemoryStream()) using (TextWriter writer = new StreamWriter(stream)) { writer.Write(message.ToString()); writer.Flush(); stream.Position = 0; await queueClient.SendAsync(new BrokeredMessage(stream) { ContentType = "text/plain" }); } queueClient.Close(); // now wait for function to be invoked string result = await TestHelpers.WaitForBlobAsync(resultBlob); Assert.Equal(TestHelpers.RemoveByteOrderMarkAndWhitespace(id), TestHelpers.RemoveByteOrderMarkAndWhitespace(result)); }
public async Task QueueTriggerToBlobTest() { string id = Guid.NewGuid().ToString(); string messageContent = string.Format("{{ \"id\": \"{0}\" }}", id); CloudQueueMessage message = new CloudQueueMessage(messageContent); await Fixture.TestQueue.AddMessageAsync(message); var resultBlob = Fixture.TestContainer.GetBlockBlobReference(id); string result = await TestHelpers.WaitForBlobAsync(resultBlob); Assert.Equal(TestHelpers.RemoveByteOrderMarkAndWhitespace(messageContent), TestHelpers.RemoveByteOrderMarkAndWhitespace(result)); TraceEvent traceEvent = await WaitForTraceAsync(p => p.Message.Contains(id)); Assert.Equal(TraceLevel.Verbose, traceEvent.Level); string trace = traceEvent.Message; Assert.True(trace.Contains("script processed queue message")); Assert.True(trace.Replace(" ", string.Empty).Contains(messageContent.Replace(" ", string.Empty))); }
protected async Task CosmosDBTriggerToBlobTestImpl() { // DocumentDB tests need the following environment vars: // "AzureWebJobsDocumentDBConnectionString" -- the connection string to the account // Waiting for the Processor to adquire leases await Task.Delay(10000); await Fixture.InitializeDocumentClient(); bool collectionsCreated = await Fixture.CreateDocumentCollections(); var resultBlob = Fixture.TestOutputContainer.GetBlockBlobReference("cosmosdbtriggere2e-completed"); await resultBlob.DeleteIfExistsAsync(); string id = Guid.NewGuid().ToString(); Document documentToTest = new Document() { Id = id }; await Fixture.DocumentClient.CreateDocumentAsync(UriFactory.CreateDocumentCollectionUri("ItemDb", "ItemCollection"), documentToTest); // wait for logs to flush await Task.Delay(FileTraceWriter.LogFlushIntervalMs); // now wait for function to be invoked string result = await TestHelpers.WaitForBlobAndGetStringAsync(resultBlob); if (collectionsCreated) { // cleanup collections await Fixture.DeleteDocumentCollections(); } Assert.Equal(TestHelpers.RemoveByteOrderMarkAndWhitespace(id), TestHelpers.RemoveByteOrderMarkAndWhitespace(result)); }
public async Task QueueTriggerToBlobTest() { TestHelpers.ClearFunctionLogs("QueueTriggerToBlob"); string id = Guid.NewGuid().ToString(); string messageContent = string.Format("{{ \"id\": \"{0}\" }}", id); CloudQueueMessage message = new CloudQueueMessage(messageContent); await Fixture.TestQueue.AddMessageAsync(message); var resultBlob = Fixture.TestOutputContainer.GetBlockBlobReference(id); string result = await TestHelpers.WaitForBlobAndGetStringAsync(resultBlob); Assert.Equal(TestHelpers.RemoveByteOrderMarkAndWhitespace(messageContent), TestHelpers.RemoveByteOrderMarkAndWhitespace(result)); TraceEvent traceEvent = await WaitForTraceAsync(p => p.Message.Contains(id)); Assert.Equal(System.Diagnostics.TraceLevel.Info, traceEvent.Level); string trace = traceEvent.Message; Assert.Contains("script processed queue message", trace); Assert.Contains(messageContent.Replace(" ", string.Empty), trace.Replace(" ", string.Empty)); }