Beispiel #1
0
        public async Task FileNameIsLogged()
        {
            // Prepare the inputs
            var data = new StorageObjectData {
                Name = "new-file.txt"
            };
            var cloudEvent = new CloudEvent
            {
                Type   = StorageObjectData.FinalizedCloudEventType,
                Source = new Uri("//storage.googleapis.com", UriKind.RelativeOrAbsolute),
                Id     = "1234",
                Data   = data
            };
            var logger = new MemoryLogger <HelloGcs.Function>();

            // Execute the function
            var function = new HelloGcs.Function(logger);
            await function.HandleAsync(cloudEvent, data, CancellationToken.None);

            // Check the log results - just the entry starting with "File:".
            var logEntry = Assert.Single(logger.ListLogEntries(), entry => entry.Message.StartsWith("File:"));

            Assert.Equal("File: new-file.txt", logEntry.Message);
            Assert.Equal(LogLevel.Information, logEntry.Level);
        }
        public async Task FileNameIsLogged()
        {
            // Prepare the inputs
            var cloudEvent = new CloudEvent(StorageObjectData.FinalizedCloudEventType, new Uri("//storage.googleapis.com"));
            var data       = new StorageObjectData {
                Name = "new-file.txt"
            };

            CloudEventConverters.PopulateCloudEvent(cloudEvent, data);
            var logger = new MemoryLogger <HelloGcs.Function>();

            // Execute the function
            var function = new HelloGcs.Function(logger);
            await function.HandleAsync(cloudEvent, data, CancellationToken.None);

            // Check the log results
            var logEntry = Assert.Single(logger.ListLogEntries());

            Assert.Equal("File new-file.txt uploaded", logEntry.Message);
            Assert.Equal(LogLevel.Information, logEntry.Level);
        }