public void GetShouldReturnDefaultAzureServiceGivenDefaultCatalog()
        {
            // given
            ExtensionServiceProvider provider = ExtensionServiceProvider.Create(new Assembly[]
            {
                typeof(IAccountManager).Assembly,
                typeof(IAzureResourceManager).Assembly
            });
            var serverDefinition = new ServerDefinition("sqlserver", "azure");

            // when I query each provider
            IServerDiscoveryProvider serverDiscoveryProvider = ExtensionUtils.GetService <IServerDiscoveryProvider>(provider, serverDefinition);

            // Then I get a valid provider back
            Assert.NotNull(serverDiscoveryProvider);
            Assert.True(serverDiscoveryProvider is AzureSqlServerDiscoveryProvider);

            IDatabaseDiscoveryProvider databaseDiscoveryProvider =
                ExtensionUtils.GetService <IDatabaseDiscoveryProvider>(provider, serverDefinition);

            // TODO Verify account manager is detected as soon as the account manager has a real implementation
            //IAccountManager accountManager = ((AzureSqlServerDiscoveryProvider)serverDiscoveryProvider).AccountManager;
            //Assert.NotNull(accountManager);
            //Assert.True(accountManager is IAzureAuthenticationManager);

            Assert.NotNull(databaseDiscoveryProvider);
            Assert.True(databaseDiscoveryProvider is AzureDatabaseDiscoveryProvider);
        }
        public void GetShouldReturnImplementedAzureServiceIfFoundInCatalog()
        {
            //given
            ExtensionServiceProvider provider = ExtensionServiceProvider.Create(typeof(FakeAzureServerDiscoveryProvider).SingleItemAsEnumerable());

            //when
            IServerDiscoveryProvider serverDiscoveryProvider = ExtensionUtils.GetService <IServerDiscoveryProvider>(provider, new ServerDefinition("sqlserver", "azure"));

            Assert.NotNull(serverDiscoveryProvider);
            Assert.True(serverDiscoveryProvider is FakeAzureServerDiscoveryProvider);
        }
        public void RequiresUserAccountShouldReturnFalseGivenNotSecuredService()
        {
            //given
            var serverDefinition           = new ServerDefinition("SqlServer", "Local");
            IMultiServiceProvider provider = CreateServiceProvider();

            //when
            IServerDiscoveryProvider service = ExtensionUtils.GetService <IServerDiscoveryProvider>(provider, serverDefinition);

            //then
            Assert.NotNull(service);
        }
        public void GetServiceShouldReturnNullGivenUnSupportedMetadata()
        {
            //given
            var serverDefinition           = new ServerDefinition("SqlServer", "Local");
            IMultiServiceProvider provider = CreateServiceProvider();

            //when
            IAccountManager service = ExtensionUtils.GetService <IAccountManager>(provider, serverDefinition);

            //then
            Assert.Null(service);
        }
        public void GetServiceShouldReturnNullGivenInvalidMetadata()
        {
            //given
            var serverDefinition           = new ServerDefinition(Guid.NewGuid().ToString(), Guid.NewGuid().ToString());
            IMultiServiceProvider provider = CreateServiceProvider();

            //when
            IServerDiscoveryProvider service = ExtensionUtils.GetService <IServerDiscoveryProvider>(provider, serverDefinition);

            //then
            Assert.Null(service);
        }
        public void GetServiceShouldReturnTheServiceThatHasGivenMetadataCorrectly()
        {
            //given
            var serverDefinition           = new ServerDefinition("SqlServer", "Azure");
            IMultiServiceProvider provider = CreateServiceProvider();

            //when
            IServerDiscoveryProvider service = ExtensionUtils.GetService <IServerDiscoveryProvider>(provider, serverDefinition);

            //then
            Assert.NotNull(service);
            Assert.True(service.GetType() == typeof(FakeSecureServerDiscoveryProvider));
        }
        public void GetGetServiceOfExportableShouldReturnNullGivenSameTypeAsExportable()
        {
            //given
            ExtensionServiceProvider provider = ExtensionServiceProvider.Create(typeof(FakeAzureServerDiscoveryProvider).SingleItemAsEnumerable());

            //when
            IServerDiscoveryProvider serverDiscoveryProvider = ExtensionUtils.GetService <IServerDiscoveryProvider>(provider, new ServerDefinition("sqlserver", "azure"));

            Assert.NotNull(serverDiscoveryProvider);
            FakeAzureServerDiscoveryProvider fakeAzureServerDiscovery = serverDiscoveryProvider as FakeAzureServerDiscoveryProvider;

            Assert.NotNull(fakeAzureServerDiscovery);
            Assert.Null(fakeAzureServerDiscovery.ServerDiscoveryProvider);
        }