public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IApiVersionDescriptionProvider provider, ApiContext apiContext) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } FakeDataFactory.SaveFakeProducts(FakeDataFactory.CreateFakeProducts(), apiContext); app.UseSwagger(); app.UseSwaggerUI(options => { foreach (var description in provider.ApiVersionDescriptions) { options.SwaggerEndpoint( $"/swagger/{description.GroupName}/swagger.json", description.GroupName.ToUpperInvariant()); } options.DocExpansion(DocExpansion.List); }); app.UseRouting(); app.UseEndpoints(endpoints => endpoints.MapControllers()); }
public async Task GetShouldReturnDatabasesEvenIfFailsForOneServer() { string databaseName1 = "server1/db1"; string databaseName2 = "server1/db2"; string databaseName3 = "error/db3"; string databaseName4 = "server2/db4"; List <string> databasesForSubscription = new List <string>() { databaseName1, databaseName2 }; Dictionary <string, List <string> > subscriptionToDatabaseMap = new Dictionary <string, List <string> >(); subscriptionToDatabaseMap.Add(Guid.NewGuid().ToString(), databasesForSubscription); subscriptionToDatabaseMap.Add(Guid.NewGuid().ToString(), new List <string>() { databaseName3, databaseName4, }); AzureDatabaseDiscoveryProvider databaseDiscoveryProvider = FakeDataFactory.CreateAzureDatabaseDiscoveryProvider(subscriptionToDatabaseMap); ServiceResponse <DatabaseInstanceInfo> response = await databaseDiscoveryProvider.GetDatabaseInstancesAsync(serverName : null, cancellationToken : new CancellationToken()); List <DatabaseInstanceInfo> list = response.Data.ToList(); Assert.NotNull(list); Assert.True(list.Any(x => x.Name == "db1" && x.ServerInstanceInfo.Name == "server1")); Assert.True(list.Any(x => x.Name == "db2" && x.ServerInstanceInfo.Name == "server1")); Assert.True(list.Any(x => x.Name == "db4" && x.ServerInstanceInfo.Name == "server2")); Assert.False(list.Any(x => x.Name == "db3" && x.ServerInstanceInfo.Name == "error")); Assert.True(list.Count() == 3); Assert.NotNull(response.Errors); Assert.True(response.Errors.Count() == 1); }
public async Task GetShouldReturnDatabasesFromCacheIfGetCalledTwice() { Dictionary <string, List <string> > subscriptionToDatabaseMap = CreateSubscriptonMap(2); AddDatabases(subscriptionToDatabaseMap, 3); AzureDatabaseDiscoveryProvider databaseDiscoveryProvider = FakeDataFactory.CreateAzureDatabaseDiscoveryProvider(subscriptionToDatabaseMap); ServiceResponse <DatabaseInstanceInfo> response = await databaseDiscoveryProvider.GetDatabaseInstancesAsync(serverName : null, cancellationToken : new CancellationToken()); List <DatabaseInstanceInfo> list = response.Data.ToList(); ValidateResult(subscriptionToDatabaseMap, list); Dictionary <string, List <string> > subscriptionToDatabaseMap2 = CopySubscriptonMap(subscriptionToDatabaseMap); AddDatabases(subscriptionToDatabaseMap2, 5); AzureTestContext testContext = new AzureTestContext(subscriptionToDatabaseMap2); databaseDiscoveryProvider.AccountManager = testContext.AzureAccountManager; databaseDiscoveryProvider.AzureResourceManager = testContext.AzureResourceManager; response = await databaseDiscoveryProvider.GetDatabaseInstancesAsync(serverName : null, cancellationToken : new CancellationToken()); list = response.Data.ToList(); //the provider should get the databases from cache for the list should match the first created data ValidateResult(subscriptionToDatabaseMap, list); }
public async Task GetShouldReturnServersSuccessfully() { string serverName = "server"; List <string> serversForSubscription = new List <string>() { Guid.NewGuid().ToString(), serverName }; Dictionary <string, List <string> > subscriptionToDatabaseMap = new Dictionary <string, List <string> >(); subscriptionToDatabaseMap.Add(Guid.NewGuid().ToString(), serversForSubscription); subscriptionToDatabaseMap.Add(Guid.NewGuid().ToString(), new List <string>() { Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), }); AzureSqlServerDiscoveryProvider discoveryProvider = FakeDataFactory.CreateAzureServerDiscoveryProvider(subscriptionToDatabaseMap); ServiceResponse <ServerInstanceInfo> response = await discoveryProvider.GetServerInstancesAsync(); IEnumerable <ServerInstanceInfo> servers = response.Data; Assert.NotNull(servers); Assert.True(servers.Any(x => x.Name == serverName)); Assert.True(servers.Count() == 4); }
public LipaConectorTest() { _fakeDataFactory = new FakeDataFactory(RestaurantName); _googleSpreadsheetIdFactory = new GoogleSpreadsheetIdFactory(); _googleSheetService = new GoogleSheetServiceFake(); _googleSheetService_returnNull = new GoogleSheetServiceFake_ReturnNull(); _googleSheetService_returnEmpty = new GoogleSheetServiceFake_ReturnEmpty(); _lipaConector = new LipaConector(_googleSheetService, _googleSpreadsheetIdFactory); _lipaConector_NullCheck = new LipaConector(_googleSheetService_returnNull, _googleSpreadsheetIdFactory); _lipaConector_EmptyCheck = new LipaConector(_googleSheetService_returnEmpty, _googleSpreadsheetIdFactory); }
public MainWindowViewModel() { LaunchLoaderWindow = new RelayCommand((o) => { return(true); }, (o) => { LoaderViewModel lvm = new LoaderViewModel(this); LoadingFileCommand loadingFileCommand = new LoadingFileCommand(lvm, this); lvm.LoadFileCommand = loadingFileCommand; lvm.LaunchViewCommand.Execute(this); }); Metadatas = FakeDataFactory.TEMP_GenerateMeta(); RaisePropertyChangedEvent(nameof(ColumnNames)); }
public async Task GetShouldReturnEmptyGivenNotSubscriptionFound() { Dictionary <string, List <string> > subscriptionToDatabaseMap = new Dictionary <string, List <string> >(); AzureDatabaseDiscoveryProvider databaseDiscoveryProvider = FakeDataFactory.CreateAzureDatabaseDiscoveryProvider(subscriptionToDatabaseMap); ServiceResponse <DatabaseInstanceInfo> response = await databaseDiscoveryProvider.GetDatabaseInstancesAsync(serverName : null, cancellationToken : new CancellationToken()); Assert.NotNull(response); Assert.NotNull(response.Data); Assert.False(response.Data.Any()); }
public async Task GetShouldReturnEmptyGivenNoSubscriptionFound() { Dictionary <string, List <string> > subscriptionToDatabaseMap = new Dictionary <string, List <string> >(); AzureSqlServerDiscoveryProvider discoveryProvider = FakeDataFactory.CreateAzureServerDiscoveryProvider(subscriptionToDatabaseMap); ServiceResponse <ServerInstanceInfo> response = await discoveryProvider.GetServerInstancesAsync(); IEnumerable <ServerInstanceInfo> servers = response.Data; Assert.NotNull(servers); Assert.False(servers.Any()); }
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ApiContext apiContext) { IEnumerable <Student> students = FakeDataFactory.CreateStudents(); FakeDataFactory.SaveFakeStudents(students, apiContext); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => endpoints.MapODataRoute("odata", "odata", GetEdmModel())); }