Пример #1
0
            public async Task ShouldUpdateTheNewBucketsRemoteIdIfNoExistingBucketWithRemoteId(
                string remoteId,
                Bucket bucket,
                Bucket existingBucket,
                [Frozen] IBucketRepository repository,
                [Target] DefaultBucketService service,
                CancellationToken cancellationToken
                )
            {
                bucket.RemoteId            = null;
                bucket.Endpoints           = (long)ChannelEndpoint.CreateMessage;
                bucket.ApiCategory         = 'c';
                existingBucket.Endpoints   = (long)ChannelEndpoint.DeleteMessage;
                existingBucket.ApiCategory = 'c';

                var httpResponse = new HttpResponseMessage();

                httpResponse.Headers.Add("x-ratelimit-bucket", new[] { remoteId });

                repository.FindByRemoteIdAndMajorParameters(Any <string>(), Any <MajorParameters>(), Any <CancellationToken>()).Returns((Bucket)null !);
                var result = await service.MergeBucketIds(bucket, httpResponse, cancellationToken);

                result.Should().Be(bucket);
                result.RemoteId.Should().Be(remoteId);
                await repository.Received().FindByRemoteIdAndMajorParameters(Is(remoteId), Is(bucket.MajorParameters), Is(cancellationToken));
            }
Пример #2
0
            public async Task ShouldNotThrowIfNotCancelled(
                Bucket bucket,
                [Target] DefaultBucketService service,
                CancellationToken cancellationToken
                )
            {
                var httpResponse = new HttpResponseMessage();

                Func <Task> func = () => service.MergeBucketIds(bucket, httpResponse, cancellationToken);

                await func.Should().NotThrowAsync <OperationCanceledException>();
            }
Пример #3
0
            public async Task ShouldNotThrowIfHeaderIsNotPresent(
                string remoteId,
                Bucket bucket,
                [Target] DefaultBucketService service,
                CancellationToken cancellationToken
                )
            {
                var httpResponse = new HttpResponseMessage();

                Func <Task> func = () => service.MergeBucketIds(bucket, httpResponse, cancellationToken);

                await func.Should().NotThrowAsync();
            }
Пример #4
0
            public async Task ShouldUpdateRemoteIdIfItAlreadyHasOne(
                string existingId,
                string newId,
                Bucket bucket,
                [Target] DefaultBucketService service,
                CancellationToken cancellationToken
                )
            {
                bucket.RemoteId = existingId;
                var httpResponse = new HttpResponseMessage();

                httpResponse.Headers.Add("x-ratelimit-bucket", new[] { newId });

                var result = await service.MergeBucketIds(bucket, httpResponse, cancellationToken);

                result.RemoteId.Should().Be(newId);
            }