Esempio n. 1
0
        public async Task SubmitTestRequests()
        {
            var jobOutputStatusStorageService            = new JobOutputStatusStorageService(jobOutputStatusTableStorageService);
            var mediaServiceInstanceHealthStorageService = new MediaServiceInstanceHealthStorageService(mediaServiceInstanceHealthTableStorageService);
            var mediaServiceInstanceHealthService        = new MediaServiceInstanceHealthService(mediaServiceInstanceHealthStorageService, jobOutputStatusStorageService, mediaServiceCallHistoryStorageService, configService);
            var mediaServiceInstanceFactory = new MediaServiceInstanceFactory(mediaServiceCallHistoryStorageService, configService);

            foreach (var config in configService.MediaServiceInstanceConfiguration)
            {
                var client = mediaServiceInstanceFactory.GetMediaServiceInstance(config.Value.AccountName, Mock.Of <ILogger>());
                client.LongRunningOperationRetryTimeout = 2;

                await MediaServicesHelper.EnsureTransformExists(
                    client,
                    config.Value.ResourceGroup,
                    config.Value.AccountName,
                    transformName,
                    new BuiltInStandardEncoderPreset(EncoderNamedPreset.AdaptiveStreaming)).ConfigureAwait(false);

                await mediaServiceInstanceHealthService.CreateOrUpdateAsync(new MediaServiceInstanceHealthModel
                {
                    MediaServiceAccountName = config.Value.AccountName,
                    HealthState             = InstanceHealthState.Healthy,
                    LastUpdated             = DateTime.UtcNow,
                    IsEnabled = true
                },
                                                                            Mock.Of <ILogger>()).ConfigureAwait(false);

                await MediaServicesHelper.EnsureContentKeyPolicyExists(
                    client,
                    config.Value.ResourceGroup,
                    config.Value.AccountName,
                    configService.ContentKeyPolicyName,
                    configService.GetClearKeyStreamingKey(),
                    configService.TokenIssuer,
                    configService.TokenAudience).ConfigureAwait(false);
            }

            var target     = new JobRequestStorageService(jobRequestQueue);
            var uniqueness = Guid.NewGuid().ToString().Substring(0, 13);

            for (var i = 0; i < 10; i++)
            {
                Assert.IsNotNull(await target.CreateAsync(GenerateJobRequestModel(i, uniqueness), Mock.Of <ILogger>()).ConfigureAwait(false));
            }
        }