示例#1
0
        public async Task GetByIdAsyncShouldThrowArgumentNullExceptionOnNullKey()
        {
            // arrange
            var providerRepository = new ProviderRepository(_mongoDatabase);

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

            // assert
            await Assert.ThrowsAsync <ArgumentNullException>(testCode);
        }
示例#2
0
        public async Task TestGetProviderByIdAsyncCanRetrievProvider()
        {
            // arrange
            var id       = Guid.NewGuid().ToString("n");
            var provider = new Provider
            {
                Id      = id,
                City    = "Springfield",
                State   = "Illinois",
                Name    = "TowNow!",
                Email   = "*****@*****.**",
                ZipCode = "2342",
                ProviderImageBucketKey = new ImageBucketKey {
                    Store = "some-store", Bucket = Guid.NewGuid().ToString("n")
                },
                Address = "742 Evergreen Terrace",
            };

            _dataStore.EnsureProvider(provider);

            // act
            var(providerResult, outcomeAction, error) = await _providerRepository.GetByIdAsync(id);

            // assert
            Assert.NotNull(providerResult);
            Assert.Equal(RepositoryOutcomeAction.OkNone, outcomeAction);
            Assert.Null(error);
            Assert.Equal(provider.Id, providerResult.Id);
            Assert.Equal(provider.City, providerResult.City);
            Assert.Equal(provider.State, providerResult.State);
            Assert.Equal(provider.Name, providerResult.Name);
            Assert.Equal(provider.Email, providerResult.Email);
            Assert.Equal(provider.ZipCode, providerResult.ZipCode);
            Assert.Equal(provider.ProviderImageBucketKey?.Store, providerResult.ProviderImageBucketKey?.Store);
            Assert.Equal(provider.ProviderImageBucketKey?.Bucket, providerResult.ProviderImageBucketKey?.Bucket);
            Assert.Equal(provider.Address, providerResult.Address);
        }