예제 #1
0
        public async Task TestNewImageBucketCreatesResult()
        {
            // arrange
            var key = new ImageBucketKey
            {
                Store = "some-store"
            };
            var imageBucket = new ImageBucket
            {
                StoreBucket = key,
                ImageList   = new List <string> {
                    "profile-picture-1", "profile-picture-2"
                }
            };

            // act
            var(newImageBucket, outcomeAction, error) = await _imageBucketRepository.NewImageBucket(imageBucket);

            // assert
            Assert.NotNull(newImageBucket);
            Assert.Equal(RepositoryOutcomeAction.OkCreated, outcomeAction);
            Assert.Null(error);
            Assert.Equal(key.Store, newImageBucket.StoreBucket.Store);
            Assert.NotNull(newImageBucket.StoreBucket.Bucket);
            Assert.Collection(newImageBucket.ImageList,
                              _ => Assert.Equal("profile-picture-1", _),
                              _ => Assert.Equal("profile-picture-2", _));
            Assert.True(
                _dataStore
                .TestImageBucket(_ =>
                                 _.StoreBucket.Store == newImageBucket.StoreBucket.Store &&
                                 _.StoreBucket.Bucket == newImageBucket.StoreBucket.Bucket));
        }
예제 #2
0
        public async Task NewImageBucketShouldThrowArgumentNullExceptionOnNullKey()
        {
            // arrange
            var imageBucketRepository = new ImageBucketRepository(_mongoDatabase);

            // act (deferred)
            var testCode = (Func <Task>)(async() => await imageBucketRepository.NewImageBucket(null));

            // assert
            await Assert.ThrowsAsync <ArgumentNullException>(testCode);
        }