private static IServiceProvider CreateServices() { Mock <IServiceProvider> servicesMock = new Mock <IServiceProvider>(MockBehavior.Strict); StorageClientFactory clientFactory = new StorageClientFactory(); servicesMock.Setup(p => p.GetService(typeof(StorageClientFactory))).Returns(clientFactory); return(servicesMock.Object); }
private static IStorageAccount CreateAccount() { Mock <IServiceProvider> services = new Mock <IServiceProvider>(MockBehavior.Strict); StorageClientFactory clientFactory = new StorageClientFactory(); services.Setup(p => p.GetService(typeof(StorageClientFactory))).Returns(clientFactory); return(new StorageAccount(CloudStorageAccount.DevelopmentStorageAccount, services.Object)); }
private static IStorageAccount CreateProductUnderTest(CloudStorageAccount account) { Mock <IServiceProvider> servicesMock = new Mock <IServiceProvider>(MockBehavior.Strict); StorageClientFactory clientFactory = new StorageClientFactory(); servicesMock.Setup(p => p.GetService(typeof(StorageClientFactory))).Returns(clientFactory); return(new StorageAccount(account, servicesMock.Object)); }
public Fixture(WebApplicationFactory <Startup> factory) { _factory = factory; StorageClientFactory.Create().Returns(Task.FromResult(StorageClient)); _defaultMocks = c => { c.AddSingleton(StorageClientFactory); c.AddSingleton(BatchFinalizer); }; }
public void ConstructorDefaults() { JobHostConfiguration config = new JobHostConfiguration(); Assert.NotNull(config.Singleton); Assert.NotNull(config.LoggerFactory); Assert.False(config.Blobs.CentralizedPoisonQueue); StorageClientFactory clientFactory = config.GetService <StorageClientFactory>(); Assert.NotNull(clientFactory); }
public async Task PlatformBaseServiceAsync(IHttpClientFactory clientFactory) { DatabaseClientFactory dbFactory = new DatabaseClientFactory(clientFactory); string dbConnectionString = await dbFactory.GetConnectionStringForClient(); this.dbClient = await dbFactory.GetClient(dbConnectionString); StorageClientFactory storageFactory = new StorageClientFactory(clientFactory); string storageConnectionString = await storageFactory.GetConnectionStringForClient(); this.storageClient = await storageFactory.GetClient(storageConnectionString); this.Setup().Wait(); }
private static IStorageAccountProvider GetStorageAccountProvider(CloudStorageAccount account) { Mock <IServiceProvider> services = new Mock <IServiceProvider>(MockBehavior.Strict); StorageClientFactory clientFactory = new StorageClientFactory(); services.Setup(p => p.GetService(typeof(StorageClientFactory))).Returns(clientFactory); IStorageAccount storageAccount = account != null ? new StorageAccount(account, services.Object) : null; IStorageAccountProvider storageAccountProvider = new SimpleStorageAccountProvider(services.Object) { StorageAccount = account }; return(storageAccountProvider); }
public void ConstructorDefaults() { JobHostConfiguration config = new JobHostConfiguration(); Assert.NotNull(config.Singleton); Assert.NotNull(config.Tracing); Assert.Equal(TraceLevel.Info, config.Tracing.ConsoleLevel); Assert.Equal(0, config.Tracing.Tracers.Count); StorageClientFactory clientFactory = config.GetService <StorageClientFactory>(); Assert.NotNull(clientFactory); }
public void StorageClientFactory_GetterSetter() { JobHostConfiguration configuration = new JobHostConfiguration(); StorageClientFactory clientFactory = configuration.StorageClientFactory; Assert.NotNull(clientFactory); Assert.Same(clientFactory, configuration.GetService <StorageClientFactory>()); CustomStorageClientFactory customFactory = new CustomStorageClientFactory(); configuration.StorageClientFactory = customFactory; Assert.Same(customFactory, configuration.StorageClientFactory); Assert.Same(customFactory, configuration.GetService <StorageClientFactory>()); }
public void ConstructorDefaults() { JobHostConfiguration config = new JobHostConfiguration(); Assert.NotNull(config.Singleton); Assert.NotNull(config.Tracing); Assert.Equal(System.Diagnostics.TraceLevel.Info, config.Tracing.ConsoleLevel); Assert.Equal(0, config.Tracing.Tracers.Count); Assert.False(config.Blobs.CentralizedPoisonQueue); StorageClientFactory clientFactory = config.GetService <StorageClientFactory>(); Assert.NotNull(clientFactory); }
private static TestJobHostConfiguration CreateConfiguration() { Mock <IServiceProvider> services = new Mock <IServiceProvider>(MockBehavior.Strict); StorageClientFactory clientFactory = new StorageClientFactory(); services.Setup(p => p.GetService(typeof(StorageClientFactory))).Returns(clientFactory); IStorageAccountProvider storageAccountProvider = new SimpleStorageAccountProvider(services.Object) { // Use null connection strings since unit tests shouldn't make wire requests. StorageAccount = null, DashboardAccount = null }; return(CreateConfiguration(storageAccountProvider)); }
public static FunctionIndexer Create(CloudStorageAccount account = null, INameResolver nameResolver = null, IExtensionRegistry extensionRegistry = null, TraceWriter traceWriter = null) { Mock <IServiceProvider> services = new Mock <IServiceProvider>(MockBehavior.Strict); StorageClientFactory clientFactory = new StorageClientFactory(); services.Setup(p => p.GetService(typeof(StorageClientFactory))).Returns(clientFactory); IStorageAccount storageAccount = account != null ? new StorageAccount(account, services.Object) : null; IStorageAccountProvider storageAccountProvider = new SimpleStorageAccountProvider(services.Object) { StorageAccount = account }; IExtensionTypeLocator extensionTypeLocator = new NullExtensionTypeLocator(); ContextAccessor <IMessageEnqueuedWatcher> messageEnqueuedWatcherAccessor = new ContextAccessor <IMessageEnqueuedWatcher>(); ContextAccessor <IBlobWrittenWatcher> blobWrittenWatcherAccessor = new ContextAccessor <IBlobWrittenWatcher>(); ISharedContextProvider sharedContextProvider = new SharedContextProvider(); TraceWriter logger = traceWriter ?? new TestTraceWriter(TraceLevel.Verbose); SingletonManager singletonManager = new SingletonManager(); IWebJobsExceptionHandler exceptionHandler = new WebJobsExceptionHandler(); var blobsConfiguration = new JobHostBlobsConfiguration(); ITriggerBindingProvider triggerBindingProvider = DefaultTriggerBindingProvider.Create(nameResolver, storageAccountProvider, extensionTypeLocator, new FixedHostIdProvider("test"), new SimpleQueueConfiguration(maxDequeueCount: 5), blobsConfiguration, exceptionHandler, messageEnqueuedWatcherAccessor, blobWrittenWatcherAccessor, sharedContextProvider, new DefaultExtensionRegistry(), singletonManager, logger); IBindingProvider bindingProvider = DefaultBindingProvider.Create(nameResolver, null, storageAccountProvider, extensionTypeLocator, messageEnqueuedWatcherAccessor, blobWrittenWatcherAccessor, new DefaultExtensionRegistry()); IFunctionOutputLoggerProvider outputLoggerProvider = new NullFunctionOutputLoggerProvider(); IFunctionOutputLogger outputLogger = outputLoggerProvider.GetAsync(CancellationToken.None).Result; IFunctionExecutor executor = new FunctionExecutor(new NullFunctionInstanceLogger(), outputLogger, exceptionHandler, logger); if (extensionRegistry == null) { extensionRegistry = new DefaultExtensionRegistry(); } return(new FunctionIndexer(triggerBindingProvider, bindingProvider, DefaultJobActivator.Instance, executor, extensionRegistry, new SingletonManager(), logger)); }
public static FunctionIndexer Create(CloudStorageAccount account = null, INameResolver nameResolver = null, IExtensionRegistry extensionRegistry = null) { Mock<IServiceProvider> services = new Mock<IServiceProvider>(MockBehavior.Strict); StorageClientFactory clientFactory = new StorageClientFactory(); services.Setup(p => p.GetService(typeof(StorageClientFactory))).Returns(clientFactory); IStorageAccount storageAccount = account != null ? new StorageAccount(account, services.Object) : null; IStorageAccountProvider storageAccountProvider = new SimpleStorageAccountProvider(services.Object) { StorageAccount = account }; IExtensionTypeLocator extensionTypeLocator = new NullExtensionTypeLocator(); ContextAccessor<IMessageEnqueuedWatcher> messageEnqueuedWatcherAccessor = new ContextAccessor<IMessageEnqueuedWatcher>(); ContextAccessor<IBlobWrittenWatcher> blobWrittenWatcherAccessor = new ContextAccessor<IBlobWrittenWatcher>(); ISharedContextProvider sharedContextProvider = new SharedContextProvider(); TestTraceWriter logger = new TestTraceWriter(TraceLevel.Verbose); SingletonManager singletonManager = new SingletonManager(); ITriggerBindingProvider triggerBindingProvider = DefaultTriggerBindingProvider.Create(nameResolver, storageAccountProvider, extensionTypeLocator, new FixedHostIdProvider("test"), new SimpleQueueConfiguration(maxDequeueCount: 5), BackgroundExceptionDispatcher.Instance, messageEnqueuedWatcherAccessor, blobWrittenWatcherAccessor, sharedContextProvider, new DefaultExtensionRegistry(), singletonManager, logger); IBindingProvider bindingProvider = DefaultBindingProvider.Create(nameResolver, storageAccountProvider, extensionTypeLocator, messageEnqueuedWatcherAccessor, blobWrittenWatcherAccessor, new DefaultExtensionRegistry()); TraceWriter trace = new TestTraceWriter(TraceLevel.Verbose); IFunctionOutputLoggerProvider outputLoggerProvider = new NullFunctionOutputLoggerProvider(); IFunctionOutputLogger outputLogger = outputLoggerProvider.GetAsync(CancellationToken.None).Result; IFunctionExecutor executor = new FunctionExecutor(new NullFunctionInstanceLogger(), outputLogger, BackgroundExceptionDispatcher.Instance, trace, null); if (extensionRegistry == null) { extensionRegistry = new DefaultExtensionRegistry(); } return new FunctionIndexer(triggerBindingProvider, bindingProvider, DefaultJobActivator.Instance, executor, extensionRegistry, new SingletonManager(), trace); }
public TestFixture() { Mock <IServiceProvider> services = new Mock <IServiceProvider>(MockBehavior.Strict); StorageClientFactory clientFactory = new StorageClientFactory(); services.Setup(p => p.GetService(typeof(StorageClientFactory))).Returns(clientFactory); DefaultStorageAccountProvider accountProvider = new DefaultStorageAccountProvider(services.Object); var task = accountProvider.GetStorageAccountAsync(CancellationToken.None); IStorageQueueClient client = task.Result.CreateQueueClient(); QueueClient = client.SdkObject; string queueName = string.Format("{0}-{1}", TestQueuePrefix, Guid.NewGuid()); Queue = client.GetQueueReference(queueName).SdkObject; Queue.CreateIfNotExistsAsync(null, null, CancellationToken.None).Wait(); string poisonQueueName = string.Format("{0}-poison", queueName); PoisonQueue = client.GetQueueReference(poisonQueueName).SdkObject; PoisonQueue.CreateIfNotExistsAsync(null, null, CancellationToken.None).Wait(); }
/// <summary> /// Saves tracking data to a file or in the azure storage container /// </summary> public async Task Flush() { var storageClient = StorageClientFactory.Create(ControllerConfiguration.StorageClientType); await storageClient.WriteText( JsonConvert.SerializeObject(new { configuration = new SimpleBenchmarkConfiguration { TestCaseType = TestCaseConfiguration.TestCaseType, TransportType = TestCaseConfiguration.TransportType, MessageCount = BenchmarkConfiguration.MessageCount, FillerSize = BenchmarkConfiguration.FillerSize, ClientCount = BenchmarkConfiguration.ClientCount, Timeout = BenchmarkConfiguration.Timeout, AzureServiceBusOperationTimeout = TransportConfiguration.AzureServiceBusOperationTimeout, UseExpress = TransportConfiguration.UseExpress, }, events = _events, }), $"{BenchmarkConfiguration.Name}.json" ); }
private static IStorageAccount CreateProductUnderTest(CloudStorageAccount account) { StorageClientFactory clientFactory = new StorageClientFactory(); return(new StorageAccount(account, clientFactory)); }
private static IStorageAccount CreateAccount() { Mock<IServiceProvider> services = new Mock<IServiceProvider>(MockBehavior.Strict); StorageClientFactory clientFactory = new StorageClientFactory(); services.Setup(p => p.GetService(typeof(StorageClientFactory))).Returns(clientFactory); return new StorageAccount(CloudStorageAccount.DevelopmentStorageAccount, services.Object); }
public void Should_CreateFileStorageClient_When_StorageClientType_File() { var storageClient = StorageClientFactory.Create(StorageClientType.File); Assert.IsType <FileStorageClient>(storageClient); }
public PlatformBaseController(IHttpClientFactory factory) { this.dbClientFactory = new DatabaseClientFactory(factory); this.storageClientFactory = new StorageClientFactory(factory); this.PlatformBaseControllerAsync().Wait(); }
private static TestJobHostConfiguration CreateConfiguration() { Mock<IServiceProvider> services = new Mock<IServiceProvider>(MockBehavior.Strict); StorageClientFactory clientFactory = new StorageClientFactory(); services.Setup(p => p.GetService(typeof(StorageClientFactory))).Returns(clientFactory); IStorageAccountProvider storageAccountProvider = new SimpleStorageAccountProvider(services.Object) { // Use null connection strings since unit tests shouldn't make wire requests. StorageAccount = null, DashboardAccount = null }; return CreateConfiguration(storageAccountProvider); }
public FileMetadataRepository(StorageClientFactory clientFactory) { _table = clientFactory.GetTableClient() .GetTableReference("DataTable"); }
private static IServiceProvider CreateServices() { Mock<IServiceProvider> servicesMock = new Mock<IServiceProvider>(MockBehavior.Strict); StorageClientFactory clientFactory = new StorageClientFactory(); servicesMock.Setup(p => p.GetService(typeof(StorageClientFactory))).Returns(clientFactory); return servicesMock.Object; }
public TestJobHostConfiguration() { StorageClientFactory = new StorageClientFactory(); }
public FileBlobRepository(StorageClientFactory clientFactory) { _container = clientFactory.GetBlobClient() .GetContainerReference("files"); }
public ApplicationRepository(StorageClientFactory clientFactory) { _table = clientFactory.GetTableClient() .GetTableReference("DataTable"); }