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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 6
0
 public NewsService(AzureSqlDbContext context)
 {
     this.context = context;
 }
Exemplo n.º 7
0
 public DbGetter(AzureSqlDbContext context)
 {
     this.context = context;
 }
Exemplo n.º 8
0
 public OrderService(AzureSqlDbContext context)
 {
     this.context = context;
 }
Exemplo n.º 9
0
 public ProductService(AzureSqlDbContext context)
 {
     this.context = context;
 }
Exemplo n.º 10
0
 public DetailsModel(AzureSqlDbContext context, UserManager <IdentityUser> userManager, IOrderService orderService)
 {
     _context          = context;
     this.orderService = orderService;
     this.userManager  = userManager;
 }
Exemplo n.º 11
0
 public SqlRowService(AzureSqlDbContext context)
 {
     this.context = context;
 }
Exemplo n.º 12
0
 public CategoryService(AzureSqlDbContext context)
 {
     this.context = context;
 }
Exemplo n.º 13
0
 public DbSaver(AzureSqlDbContext context)
 {
     this.context = context;
 }
 public SqlTableService(AzureSqlDbContext context)
 {
     this.context = context;
 }
Exemplo n.º 15
0
 public SqlDatabaseService(AzureSqlDbContext context)
 {
     this.context = context;
 }