public async Task UpdateAsync() { // Arrange var database = new Database { Id = Guid.NewGuid(), Name = databaseName }; using var context = new AzureSqlDbContext(DbContextUtilities.GetContextOptions()); await context.Databases.AddAsync(database); await context.SaveChangesAsync(); var updatedName = "updatedTestDatabaseName"; database.Name = updatedName; var databaseService = new SqlDatabaseService(context); // Act await databaseService.UpdateAsync(database); // Assert Assert.AreEqual(context.Databases.FirstOrDefault().Name, updatedName); Assert.AreEqual(context.Databases.FirstOrDefault(), database); }
public async Task SearchAsync() { // Arrange var table = new Table { Id = Guid.NewGuid(), DatabaseId = Guid.NewGuid(), Name = tableName, Schema = JsonConvert.SerializeObject(new BrandTableSchema { Name = StringType, Country = StringType }) }; var row1 = new Row { Id = Guid.NewGuid(), TableId = table.Id, Content = JsonConvert.SerializeObject(new BrandTableSchema { Name = row1Name, Country = row1Country }) }; var row2 = new Row { Id = Guid.NewGuid(), TableId = table.Id, Content = JsonConvert.SerializeObject(new BrandTableSchema { Name = row2Name, Country = row2Country }) }; using var context = new AzureSqlDbContext(DbContextUtilities.GetContextOptions()); await context.Rows.AddAsync(row1); await context.Rows.AddAsync(row2); await context.Tables.AddAsync(table); await context.SaveChangesAsync(); var rowService = new SqlRowService(context); // Act var result = await rowService.SearchByKeywordAsync(table.Id, searchKeyword, searchColumn); var resultResponse = result.Select(r => RowConverter.GetRowResponse(r)).ToList(); // Assert Assert.IsNotNull(resultResponse); Assert.AreEqual(1, resultResponse.Count); Assert.AreEqual(row2Name, resultResponse.FirstOrDefault().Content["name"]); }
public async Task CreateAsync() { // Arrange var database = new Database { Id = Guid.NewGuid(), Name = databaseName }; using var context = new AzureSqlDbContext(DbContextUtilities.GetContextOptions()); var databaseService = new SqlDatabaseService(context); // Act await databaseService.CreateAsync(database); // Assert Assert.AreNotEqual(context.Databases.Count(), 0); Assert.AreEqual(context.Databases.FirstOrDefault(), database); }
public async Task DeleteAsync() { // Arrange var database = new Database { Id = Guid.NewGuid(), Name = databaseName }; using var context = new AzureSqlDbContext(DbContextUtilities.GetContextOptions()); await context.Databases.AddAsync(database); await context.SaveChangesAsync(); var databaseService = new SqlDatabaseService(context); // Act await databaseService.DeleteAsync(database.Id); // Assert Assert.AreEqual(context.Databases.Count(), 0); }
public async Task GetAsync() { // Arrange var database = new Database { Id = Guid.NewGuid(), Name = databaseName }; using var context = new AzureSqlDbContext(DbContextUtilities.GetContextOptions()); await context.Databases.AddAsync(database); await context.SaveChangesAsync(); var databaseService = new SqlDatabaseService(context); // Act var result = await databaseService.GetAsync(database.Id); // Assert Assert.IsNotNull(result); Assert.AreEqual(database, result); }
public NewsService(AzureSqlDbContext context) { this.context = context; }
public DbGetter(AzureSqlDbContext context) { this.context = context; }
public OrderService(AzureSqlDbContext context) { this.context = context; }
public ProductService(AzureSqlDbContext context) { this.context = context; }
public DetailsModel(AzureSqlDbContext context, UserManager <IdentityUser> userManager, IOrderService orderService) { _context = context; this.orderService = orderService; this.userManager = userManager; }
public SqlRowService(AzureSqlDbContext context) { this.context = context; }
public CategoryService(AzureSqlDbContext context) { this.context = context; }
public DbSaver(AzureSqlDbContext context) { this.context = context; }
public SqlTableService(AzureSqlDbContext context) { this.context = context; }
public SqlDatabaseService(AzureSqlDbContext context) { this.context = context; }