コード例 #1
0
        public void When_getting_provider_with_valid_context_should_return_instance()
        {
            // Act
            IStorageProvider storage = _sut.GetStorageProvider(_storageContext);

            // Assert
            storage
            .Should()
            .NotBeNull()
            .And
            .BeOfType <StorageProviderStub>()
            .Which.Context
            .Should()
            .Be(_storageContext);
        }
コード例 #2
0
        public void When_getting_provider_cant_be_created_should_throw()
        {
            Type invalidProviderType = typeof(StorageProviderStubWithMissingCtorParams);

            _sut = new StorageProviderFactory(new NullLogger <StorageProviderFactory>(), new ServiceCollection().BuildServiceProvider(), invalidProviderType);

            // Act
            Action act = () => _sut.GetStorageProvider(new StorageProviderContext());

            // Assert
            StorageException ex = act.Should().Throw <StorageException>().Which;

            ex.Message.Should().Be($"Unable to create storage provider {typeof(StorageProviderStubWithMissingCtorParams).FullName}.");
            ex.InnerException.Should().BeOfType <InvalidOperationException>();
        }