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(); } }
private static BooksSqlDbContext CreateSqlDbContext() { var sql = new BooksSqlDbContext(); sql.Database.EnsureDeleted(); sql.Database.Migrate(); return(sql); }
private static void AssertSqlBookNotAdded(Guid bookId) { using (var db = new BooksSqlDbContext()) { var addedBookSql = db.Books.Find(bookId); Assert.Null(addedBookSql); } }
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(); } }
private void CleanupBookPostgreSqlDb(Guid bookId) { using (var db = new BooksSqlDbContext()) { var addedBook = db.Books.Find(bookId); db.Books.Remove(addedBook); db.SaveChanges(); } }
public UnitOfWork( BooksSqlDbContext sqlDbContext, BooksNoSqlDbContext noSqlDbContext, IBookWriteRepository bookWriteRepository, IBookReadRepository bookReadRepository) { sqlTransaction = sqlDbContext.CreateTransaction(); noSqlTransaction = noSqlDbContext.CreateTransaction(); BookWriteRepository = bookWriteRepository; BookReadRepository = bookReadRepository; }
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); }
public BookSagaEventRepository(BooksSqlDbContext dbContext) { this.dbContext = dbContext; }
public BookWriteRepository(BooksSqlDbContext dbContext) { this.dbContext = dbContext; }