Пример #1
0
        public async Task ItShouldProcessBackgroundCommands()
        {
            var commands = new[] { new CloudTableBackgroundCommandEventRepositoryIntegrationTestsCommand(), new CloudTableBackgroundCommandEventRepositoryIntegrationTestsCommand() };

            using (var host = new HostBuilder()
                              .ConfigureAppConfiguration((ctx, config) =>
            {
                config
                .AddJsonFile("appsettings.json", true)
                .AddEnvironmentVariables();
            })
                              .ConfigureServices(services =>
            {
                services
                .AddBackgroundCommandHandlersFromAssemblyContaining <CloudTableBackgroundCommandEventRepositoryIntegrationTests>()
                .AddHostingServiceConcurrentQueueBackgroundProcessing()
                .AddBackgroundCommandEventsRepositoryDecorators()
                .AddCountdownEventBackgroundProcessorDecorator(commands.Count())
                .AddCloudTableEventRepository(CloudTableProvider.FromConnectionStringName("StorageTable", "bgtasksintegrationtests"));
            })
                              .Start())
            {
                var dispatcher = host.Services.GetRequiredService <IBackgroundDispatcher>();

                foreach (var command in commands)
                {
                    await dispatcher.DispatchAsync(command);
                }

                var awaiter = host.Services.GetRequiredService <CountdownEventBackgroundProcessorAwaiter>();
                awaiter.Wait(TimeSpan.FromSeconds(30));

                var repository = host.Services.GetRequiredService <IBackgroundCommandEventRepository>();
                var allEvents  = await repository.GetAllEventsForCommandId(commands[0].Id);

                allEvents.Should().NotBeEmpty();
                allEvents.Should().HaveCount(3);
                allEvents.Should().OnlyContain(x => x.Command.Id.Equals(commands[0].Id, StringComparison.Ordinal));

                var latestEvent = await repository.GetLatestEventForCommandId(commands[0].Id);

                latestEvent.Command.Id.Should().Be(commands[0].Id);
                latestEvent.Status.Should().Be(BackgroundCommandEventStatus.Processed);
            }
        }
Пример #2
0
 public GoogleDataStoreRepository(string connectionString)
 {
     _table = CloudTableProvider.GetTable(connectionString, "PlanerUekGoogleDataStore");
 }
Пример #3
0
 public void Setup()
 {
     _storageAccountProvider = new ConfigurationCloudStorageAccountProvider("fooidity:Storage");
     _tableProvider          = new CloudTableProvider(_storageAccountProvider, "test");
 }
 public StudentGroupsRepository(string connectionString)
 {
     _table = CloudTableProvider.GetTable(connectionString, "PlanerUekStudentGroups"); //refactor to IPlanerConfig
 }