Ejemplo n.º 1
0
        public CreateBookSqlTransaction(Books.Data.Sql.Entity.Book book)
        {
            this.db = CreateSqlDbContext();

            this.book = book;
            Start();
        }
 private static void InitSqlDbContext()
 {
     using (var sql = new BooksSqlDbContext())
     {
         sql.Database.EnsureDeleted();
         sql.Database.Migrate();
     }
 }
Ejemplo n.º 3
0
        private static BooksSqlDbContext CreateSqlDbContext()
        {
            var sql = new BooksSqlDbContext();

            sql.Database.EnsureDeleted();
            sql.Database.Migrate();
            return(sql);
        }
Ejemplo n.º 4
0
 private static void AssertSqlBookNotAdded(Guid bookId)
 {
     using (var db = new BooksSqlDbContext())
     {
         var addedBookSql = db.Books.Find(bookId);
         Assert.Null(addedBookSql);
     }
 }
Ejemplo n.º 5
0
 private static void AssertSqlBookAdded(Guid bookId)
 {
     using (var db = new BooksSqlDbContext())
     {
         var addedBookSql = db.Books.Find(bookId);
         Assert.Equal(bookId, addedBookSql.Id);
     }
 }
 public static void ApplySqlDbMigrations(this IApplicationBuilder app)
 {
     using (IServiceScope serviceScope = app.ApplicationServices.GetService <IServiceScopeFactory>().CreateScope())
     {
         BooksSqlDbContext context = serviceScope.ServiceProvider.GetRequiredService <BooksSqlDbContext>();
         context.Database.EnsureDeleted();
         context.Database.Migrate();
     }
 }
Ejemplo n.º 7
0
 private void CleanupBookPostgreSqlDb(Guid bookId)
 {
     using (var db = new BooksSqlDbContext())
     {
         var addedBook = db.Books.Find(bookId);
         db.Books.Remove(addedBook);
         db.SaveChanges();
     }
 }
Ejemplo n.º 8
0
 public UnitOfWork(
     BooksSqlDbContext sqlDbContext,
     BooksNoSqlDbContext noSqlDbContext,
     IBookWriteRepository bookWriteRepository,
     IBookReadRepository bookReadRepository)
 {
     sqlTransaction      = sqlDbContext.CreateTransaction();
     noSqlTransaction    = noSqlDbContext.CreateTransaction();
     BookWriteRepository = bookWriteRepository;
     BookReadRepository  = bookReadRepository;
 }
Ejemplo n.º 9
0
        public void AddBookAddedTest()
        {
            var bookId = Guid.NewGuid();

            using (var db = new BooksSqlDbContext())
            {
                var book = new Book
                {
                    Id     = bookId,
                    Title  = "test",
                    Author = "test",
                    Path   = "test"
                };

                db.Books.Add(book);
                db.SaveChanges();
                var addedBook = db.Books.Find(bookId);
                Assert.Equal(bookId, addedBook.Id);
            }

            CleanupAddedBook(bookId);
        }
Ejemplo n.º 10
0
 public BookSagaEventRepository(BooksSqlDbContext dbContext)
 {
     this.dbContext = dbContext;
 }
Ejemplo n.º 11
0
 public BookWriteRepository(BooksSqlDbContext dbContext)
 {
     this.dbContext = dbContext;
 }