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 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);
        }
예제 #5
0
 public MyMitController()
 {
     this.todayDate       = DateTime.Now;
     this.databaseService = new SqlDatabaseService();
 }
 public GetApprenticeshipService(SqlDatabaseService sqlDatabaseService, ILog logger)
 {
     _sqlDatabaseService = sqlDatabaseService;
     _logger             = logger;
 }
예제 #7
0
 public MeetingController()
 {
     // Iniciar conexao na base de dados
     this.databaseService = new SqlDatabaseService();
 }
예제 #8
0
 public VacancyOwnerService(SqlDatabaseService sqlDatabaseService)
 {
     _sqlDatabaseService = sqlDatabaseService;
 }
 public GetTraineeshipService(SqlDatabaseService sqlDatabaseService, ILog logger)
 {
     _sqlDatabaseService = sqlDatabaseService;
     _logger             = logger;
 }