Esempio n. 1
0
        public void Verify_CreateDbContext_WorksProperly_AfterSetAllProperties()
        {
            string          connStringSample = "A_Conn_String";
            Action <string> logAction        = (x) => { };

            var dbModel = new EfDbModel(x => { return(null); });

            bool funcCalledCorrecly = false;
            Func <string, EfDbModel> createDbContextBehaviour = (cs) =>
            {
                if (cs == connStringSample)
                {
                    funcCalledCorrecly = true;
                }

                return(dbModel);
            };

            var dbContext = new EfDbContext(createDbContextBehaviour)
                            .SetConnectionString(connStringSample);

            dbContext.CreateNewContext();
            Assert.True(funcCalledCorrecly);

            dbContext.AddMappingFromAssemblyOf <TestEntityMap>();
            Assert.That(dbModel.MappingAssemblies.Count, Is.EqualTo(1));
        }
Esempio n. 2
0
        public void Verify_CreateNewContext_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.CreateNewContext();
            Assert.True(funcCalled);
        }