protected EndToEndTestFixture(string rootPath, string testId)
        {
            _testId = testId;
            string connectionString            = AmbientConnectionStringProvider.Instance.GetConnectionString(ConnectionStringNames.Storage);
            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);

            QueueClient = storageAccount.CreateCloudQueueClient();
            BlobClient  = storageAccount.CreateCloudBlobClient();
            TableClient = storageAccount.CreateCloudTableClient();

            CreateTestStorageEntities();
            TraceWriter = new TestTraceWriter(TraceLevel.Verbose);

            ScriptHostConfiguration config = new ScriptHostConfiguration()
            {
                RootScriptPath     = rootPath,
                TraceWriter        = TraceWriter,
                FileLoggingEnabled = true
            };

            ApiHubTestHelper.SetDefaultConnectionFactory();

            Host = ScriptHost.Create(config);
            Host.Start();
        }
        public async Task ApiHubTableEntityIn()
        {
            TestHelpers.ClearFunctionLogs("ApiHubTableEntityIn");

            // Ensure the test entity exists.
            await ApiHubTestHelper.EnsureEntityAsync(ApiHubTestHelper.EntityId4);

            // Test table entity out binding.
            JObject input = new JObject
            {
                { "table", "SampleTable" },
                { "id", ApiHubTestHelper.EntityId4 }
            };
            await Fixture.Host.CallAsync("ApiHubTableEntityIn",
                                         new Dictionary <string, object>()
            {
                { "input", input.ToString() }
            });

            var logs = await TestHelpers.GetFunctionLogsAsync("ApiHubTableEntityIn");

            string expectedLog = string.Format("TestResult: {0}", ApiHubTestHelper.EntityId4);

            Assert.True(logs.Any(p => p.Contains(expectedLog)));
        }
        protected EndToEndTestFixture(string rootPath, string testId)
        {
            _settingsManager = ScriptSettingsManager.Instance;
            FixtureId        = testId;
            string connectionString            = AmbientConnectionStringProvider.Instance.GetConnectionString(ConnectionStringNames.Storage);
            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);

            QueueClient = storageAccount.CreateCloudQueueClient();
            BlobClient  = storageAccount.CreateCloudBlobClient();
            TableClient = storageAccount.CreateCloudTableClient();

            CreateTestStorageEntities();
            TraceWriter = new TestTraceWriter(TraceLevel.Verbose);

            ApiHubTestHelper.SetDefaultConnectionFactory();

            ScriptHostConfiguration config = new ScriptHostConfiguration()
            {
                RootScriptPath  = rootPath,
                TraceWriter     = TraceWriter,
                FileLoggingMode = FileLoggingMode.Always
            };

            RequestConfiguration = new HttpConfiguration();
            RequestConfiguration.Formatters.Add(new PlaintextMediaTypeFormatter());

            ScriptHostEnvironmentMock = new Mock <IScriptHostEnvironment>();

            // Reset the timer logs first, since one of the tests will
            // be checking them
            TestHelpers.ClearFunctionLogs("TimerTrigger");
            Host = ScriptHost.Create(ScriptHostEnvironmentMock.Object, config, _settingsManager);
            Host.Start();
        }
        protected EndToEndTestFixture(string rootPath, string testId)
        {
            FixtureId = testId;
            string connectionString            = AmbientConnectionStringProvider.Instance.GetConnectionString(ConnectionStringNames.Storage);
            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);

            QueueClient = storageAccount.CreateCloudQueueClient();
            BlobClient  = storageAccount.CreateCloudBlobClient();
            TableClient = storageAccount.CreateCloudTableClient();

            CreateTestStorageEntities();
            TraceWriter = new TestTraceWriter(TraceLevel.Verbose);

            ApiHubTestHelper.SetDefaultConnectionFactory();

            ScriptHostConfiguration config = new ScriptHostConfiguration()
            {
                RootScriptPath  = rootPath,
                TraceWriter     = TraceWriter,
                FileLoggingMode = FileLoggingMode.Always
            };

            // Clear the timer logs first, since one of the tests will
            // be checking them
            TestHelpers.ClearFunctionLogs("TimerTrigger");
            Host = ScriptHost.Create(config);
            Host.Start();
        }
Ejemplo n.º 5
0
        public async Task ApiHubTableClientBindingTest()
        {
            var textArgValue = ApiHubTestHelper.NewRandomString();

            // Ensure the test entity exists.
            await ApiHubTestHelper.EnsureEntityAsync(ApiHubTestHelper.EntityId1);

            // Test table client binding.
            await Fixture.Host.CallAsync("ApiHubTableClient",
                                         new Dictionary <string, object>()
            {
                { ApiHubTestHelper.TextArg, textArgValue }
            });

            await ApiHubTestHelper.AssertTextUpdatedAsync(
                textArgValue, ApiHubTestHelper.EntityId1);
        }
        protected EndToEndTestFixture(string rootPath, string testId)
        {
            _settingsManager = ScriptSettingsManager.Instance;
            FixtureId        = testId;
            string connectionString            = AmbientConnectionStringProvider.Instance.GetConnectionString(ConnectionStringNames.Storage);
            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);

            QueueClient = storageAccount.CreateCloudQueueClient();
            BlobClient  = storageAccount.CreateCloudBlobClient();
            TableClient = storageAccount.CreateCloudTableClient();

            CreateTestStorageEntities();
            TraceWriter = new TestTraceWriter(TraceLevel.Verbose);

            ApiHubTestHelper.SetDefaultConnectionFactory();

            ScriptHostConfiguration config = new ScriptHostConfiguration()
            {
                RootScriptPath  = rootPath,
                TraceWriter     = TraceWriter,
                FileLoggingMode = FileLoggingMode.Always
            };

            RequestConfiguration = new HttpConfiguration();
            RequestConfiguration.Formatters.Add(new PlaintextMediaTypeFormatter());

            EventManager = new ScriptEventManager();
            ScriptHostEnvironmentMock = new Mock <IScriptHostEnvironment>();

            // Reset the timer logs first, since one of the tests will
            // be checking them
            TestHelpers.ClearFunctionLogs("TimerTrigger");
            TestHelpers.ClearFunctionLogs("ListenerStartupException");

            InitializeConfig(config);
            Func <string, FunctionDescriptor> funcLookup = (name) => this.Host.GetFunctionOrNull(name);
            var fastLogger = new FunctionInstanceLogger(funcLookup, new MetricsLogger());

            config.HostConfig.AddService <IAsyncCollector <FunctionInstanceLogEntry> >(fastLogger);

            Host = ScriptHost.Create(ScriptHostEnvironmentMock.Object, EventManager, config, _settingsManager);
            Host.Start();
        }
        public async Task ApiHubTableEntityOut()
        {
            var textArgValue = ApiHubTestHelper.NewRandomString();

            // Delete the test entity if it exists.
            await ApiHubTestHelper.DeleteEntityAsync(ApiHubTestHelper.EntityId5);

            // Test table entity out binding.
            JObject input = new JObject
            {
                { "table", "SampleTable" },
                { "value", textArgValue }
            };
            await Fixture.Host.CallAsync("ApiHubTableEntityOut",
                                         new Dictionary <string, object>()
            {
                { "input", input.ToString() }
            });

            await ApiHubTestHelper.AssertTextUpdatedAsync(
                textArgValue, ApiHubTestHelper.EntityId5);
        }
Ejemplo n.º 8
0
        public async Task ApiHubTableEntityBindingTest()
        {
            var textArgValue = ApiHubTestHelper.NewRandomString();

            // Ensure the test entity exists.
            await ApiHubTestHelper.EnsureEntityAsync(ApiHubTestHelper.EntityId3);

            // Test table entity binding.
            TestInput input = new TestInput
            {
                Id    = ApiHubTestHelper.EntityId3,
                Value = textArgValue
            };
            await Fixture.Host.CallAsync("ApiHubTableEntity",
                                         new Dictionary <string, object>()
            {
                { "input", JsonConvert.SerializeObject(input) }
            });

            await ApiHubTestHelper.AssertTextUpdatedAsync(
                textArgValue, ApiHubTestHelper.EntityId3);
        }