public void TestProvideContext2x() { var dbContext = Substitute.For <DbContext>(); var dbContextProvider = Substitute.For <IDbContextProvider>(); dbContextProvider.Provide().Returns(c => dbContext); var uof = new DbContextUnitOfWork(dbContextProvider); var context1 = uof.ProvideContext <DbContext>(); var context2 = uof.ProvideContext <DbContext>(); Assert.AreEqual(context1, dbContext); Assert.AreEqual(context2, dbContext); }
public void TestDisposeWithContextCreation() { var dbContext = Substitute.For <DbContext>(); var dbContextProvider = Substitute.For <IDbContextProvider>(); dbContextProvider.Provide().Returns(c => dbContext); var uof = new DbContextUnitOfWork(dbContextProvider); var context = uof.ProvideContext <DbContext>(); uof.Dispose(); dbContext.Received().Dispose(); }