public void Verify_GetContext_WorksProperly() { var dbModelMock = new Mock <EfDbModel>(); bool funcCalled = false; Func <string, EfDbModel> createDbContextBehaviour = (cs) => { funcCalled = true; return(dbModelMock.Object); }; var dbContext = new EfDbContext(createDbContextBehaviour); dbContext.DbContext = dbModelMock.Object; var contextGot = dbContext.GetContext(); Assert.That(contextGot, Is.Not.Null); Assert.That(contextGot, Is.EqualTo(dbModelMock.Object)); Assert.False(funcCalled); }