Example #1
0
 protected override void RegisterEFTestContext()
 {
     EffortProviderConfiguration.RegisterProvider();
     /// create a new DbConnection using Effort(at runtime, the type of the object created is EffortConnection)
      _connection = Effort.DbConnectionFactory.CreateTransient();
     _container.RegisterType<EFTestContext>(new InjectionConstructor(_connection));
 } 
 public void Initialize()
 {
     try
     {
         EffortProviderConfiguration.RegisterProvider();
         connection      = Effort.DbConnectionFactory.CreateTransient();
         databaseContext = new TestContext(connection);
         objRepo         = new CountryRepository(databaseContext);
     }
     catch (Exception ex) {
     }
 }
Example #3
0
        public void Init()
        {
            EffortProviderConfiguration.RegisterProvider();
            var efforConnection = Effort.DbConnectionFactory.CreateTransient();

            _db              = new FakeDbContext(efforConnection);
            _repo            = new EfRepository <MockEntity>(_db);
            _repoNested      = new EfRepository <MockNestedEntity>(_db);
            _repoInterpreted = new EfRepository <MockInterpretedEntity>(_db);
            _identity        = Thread.CurrentPrincipal.Identity;

            EfChangeListener.Reset();
            Entity1 = new MockEntity()
            {
                Id         = 1,
                IsValid    = true,
                IsVisible  = true,
                IsVisible2 = true
            };

            Entity2 = new LogicalDeleteEntity()
            {
                Id         = 2,
                IsValid    = true,
                IsVisible  = true,
                IsVisible2 = true
            };

            Entity3 = new LogicalDeleteEntity()
            {
                Id         = 3,
                IsValid    = true,
                IsVisible  = true,
                IsVisible2 = true
            };

            Entity4 = new InheritedLogicalDeleteEntity()
            {
                Id         = 2,
                IsValid    = true,
                IsVisible  = true,
                IsVisible2 = true
            };

            Entity5 = new InheritedLogicalDeleteEntity()
            {
                Id         = 3,
                IsValid    = true,
                IsVisible  = true,
                IsVisible2 = true
            };
        }
        /// <summary>
        ///     Initializes static members of the <see cref="ObjectContextFactory" /> class.
        /// </summary>
        static ObjectContextFactory()
        {
            EffortProviderConfiguration.RegisterProvider();

            // Dynamic Library for Effort
            AssemblyBuilder assembly =
                Thread.GetDomain().DefineDynamicAssembly(
                    new AssemblyName(string.Format("DynamicObjectContextLib")),
                    AssemblyBuilderAccess.Run);

            // Module for the entity types
            objectContextContainer = assembly.DefineDynamicModule("ObjectContexts");
            objectContextCount     = 0;
        }
        public void ImageServiceFixtureSetup()
        {
            string baseDir = AppDomain.CurrentDomain.BaseDirectory;
            var    dirInfo = new DirectoryInfo(Path.Combine(baseDir, "Images"));

            if (dirInfo.Exists)
            {
                dirInfo.Delete(true);
            }

            EffortProviderConfiguration.RegisterProvider();
            _context = new ImageContext(Effort.DbConnectionFactory.CreateTransient());
            _context.Database.CreateIfNotExists();
            // _context.Database.Initialize(true);
        }
        public SpecifiedObjCrudTest()
        {
            EffortProviderConfiguration.RegisterProvider();

            LocalIocManager.IocContainer.Register(
                Component.For <DbConnection>()
                .UsingFactoryMethod(Effort.DbConnectionFactory.CreateTransient)
                .LifestyleSingleton()
                );


            _userRepository = LocalIocManager.IocContainer.Resolve <IUserRepository>();


            CreateInitialData();
        }
Example #7
0
        public UowTests()
        {
            EffortProviderConfiguration.RegisterProvider();

            LocalIocManager.IocContainer.Register(
                Component.For <DbConnection>()
                .UsingFactoryMethod(Effort.DbConnectionFactory.CreateTransient)
                .LifestyleSingleton()
                );

            //注册dbcontext中的实体泛型仓储
            using (var repositoryRegistrar = LocalIocManager.ResolveAsDisposable <EfGenericRepositoryRegistrar>())
            {
                repositoryRegistrar.Object.RegisterForDbContext(typeof(SampleDbContext), LocalIocManager, EfAutoRepositoryTypes.Default);
            }

            CreateInitialData();
        }
Example #8
0
 public static void Register()
 {
     EffortProviderConfiguration.RegisterProvider();
 }
 public void FixtureSetup()
 {
     EffortProviderConfiguration.RegisterProvider();
 }
Example #10
0
 public void InitializeOneTime()
 {
     EffortProviderConfiguration.RegisterProvider();
 }
Example #11
0
 public static void AssemblyInit(TestContext context)
 {
     EffortProviderConfiguration.RegisterProvider();
 }
Example #12
0
 public void InitializarUmaVez()
 {
     EffortProviderConfiguration.RegisterProvider();
 }
 /// <summary>
 ///     Initializes static members of the <see cref="DbConnectionFactory" /> class.
 /// </summary>
 static DbConnectionFactory()
 {
     EffortProviderConfiguration.RegisterProvider();
 }
 /// <summary>
 ///     The class initialize.
 /// </summary>
 public static void ClassInitialize()
 {
     EffortProviderConfiguration.RegisterProvider(); ////ToDo this code will move to Testing.Repository project for good design
     Server     = TestServerCustom.Create <T>();
     HttpClient = TestServerCustom.GetHttpClient();
 }
 public DatabaseConnectionTest()
 {
     EffortProviderConfiguration.RegisterProvider();
 }
        public TestDataModel()
        {
            EffortProviderConfiguration.RegisterProvider();

            var DataActivityGroup = new List <ActivityGroupModel> {
                new ActivityGroupModel {
                    ClassId = 1, SubjectId = 1, TeacherId = 0, GradeId = 60, ActivityRefId = 1, Id = 1
                },
                new ActivityGroupModel {
                    ClassId = 2, SubjectId = 0, TeacherId = 4, GradeId = 60, ActivityRefId = 2
                },
                new ActivityGroupModel {
                    ClassId = 2, SubjectId = 1, TeacherId = 4, GradeId = 60, ActivityRefId = 1, Id = 3
                },
            }.AsQueryable();

            var MockSetActivityGroup = new Mock <DbSet <ActivityGroupModel> >();

            MockSetActivityGroup.As <IQueryable <ActivityGroupModel> >().Setup(m => m.Provider).Returns(DataActivityGroup.Provider);
            MockSetActivityGroup.As <IQueryable <ActivityGroupModel> >().Setup(m => m.Expression).Returns(DataActivityGroup.Expression);
            MockSetActivityGroup.As <IQueryable <ActivityGroupModel> >().Setup(m => m.ElementType).Returns(DataActivityGroup.ElementType);
            MockSetActivityGroup.As <IQueryable <ActivityGroupModel> >().Setup(m => m.GetEnumerator()).Returns(DataActivityGroup.GetEnumerator());

            var DataClass = new List <LookupClassModel> {
                new LookupClassModel {
                    ClassName = "test", ClassId = 1, GradeId = 60, IsActive = true
                },
                new LookupClassModel {
                    ClassName = "test2", ClassId = 2, GradeId = 60
                },
            }.AsQueryable();

            var MockSetClass = new Mock <DbSet <LookupClassModel> >();

            MockSetClass.As <IQueryable <LookupClassModel> >().Setup(m => m.Provider).Returns(DataClass.Provider);
            MockSetClass.As <IQueryable <LookupClassModel> >().Setup(m => m.Expression).Returns(DataClass.Expression);
            MockSetClass.As <IQueryable <LookupClassModel> >().Setup(m => m.ElementType).Returns(DataClass.ElementType);
            MockSetClass.As <IQueryable <LookupClassModel> >().Setup(m => m.GetEnumerator()).Returns(DataClass.GetEnumerator());

            var DataSubjectGrade = new List <SubjectGradeModel> {
                new SubjectGradeModel {
                    GradeId = 60, NumberOfLessonsPerWeek = 4, NumberOfLessonsPerDay = 1, SubjectId = 1, CollectionId = 1, BuildingUnitTypeId = 1
                },
                new SubjectGradeModel {
                    GradeId = 2, NumberOfLessonsPerWeek = 8, NumberOfLessonsPerDay = 1, SubjectId = 1
                },
                new SubjectGradeModel {
                    GradeId = 60, NumberOfLessonsPerWeek = 6, NumberOfLessonsPerDay = 4, SubjectId = 0
                },
                new SubjectGradeModel {
                    GradeId = 60, NumberOfLessonsPerWeek = 4, NumberOfLessonsPerDay = 1, SubjectId = 1, CollectionId = 2, BuildingUnitTypeId = 1
                },
                new SubjectGradeModel {
                    GradeId = 60, NumberOfLessonsPerWeek = 4, NumberOfLessonsPerDay = 1, SubjectId = 1, CollectionId = 2, BuildingUnitTypeId = 1
                }
            }.AsQueryable();

            var MockSetSubjectGrade = new Mock <DbSet <SubjectGradeModel> >();

            MockSetSubjectGrade.As <IQueryable <SubjectGradeModel> >().Setup(m => m.Provider).Returns(DataSubjectGrade.Provider);
            MockSetSubjectGrade.As <IQueryable <SubjectGradeModel> >().Setup(m => m.Expression).Returns(DataSubjectGrade.Expression);
            MockSetSubjectGrade.As <IQueryable <SubjectGradeModel> >().Setup(m => m.ElementType).Returns(DataSubjectGrade.ElementType);
            MockSetSubjectGrade.As <IQueryable <SubjectGradeModel> >().Setup(m => m.GetEnumerator()).Returns(DataSubjectGrade.GetEnumerator());

            var DataEmployees = new List <EmployeeModel> {
                new EmployeeModel {
                    EmployeeId = 0, IsActive = true, IsTeacher = true
                },
                new EmployeeModel {
                    EmployeeId = 4, IsActive = true, IsTeacher = true
                },
            }.AsQueryable();

            var MockSetEmployees = new Mock <DbSet <EmployeeModel> >();

            MockSetEmployees.As <IQueryable <EmployeeModel> >().Setup(m => m.Provider).Returns(DataEmployees.Provider);
            MockSetEmployees.As <IQueryable <EmployeeModel> >().Setup(m => m.Expression).Returns(DataEmployees.Expression);
            MockSetEmployees.As <IQueryable <EmployeeModel> >().Setup(m => m.ElementType).Returns(DataEmployees.ElementType);
            MockSetEmployees.As <IQueryable <EmployeeModel> >().Setup(m => m.GetEnumerator()).Returns(DataEmployees.GetEnumerator());

            var DataGrades = new List <LookupGradeModel> {
                new LookupGradeModel {
                    GradeId = 60, IsActive = true, GradeName = "gradeTest", StageId = 4
                }
            }.AsQueryable();

            var MockSetGrades = new Mock <DbSet <LookupGradeModel> >();

            MockSetGrades.As <IQueryable <LookupGradeModel> >().Setup(m => m.Provider).Returns(DataGrades.Provider);
            MockSetGrades.As <IQueryable <LookupGradeModel> >().Setup(m => m.Expression).Returns(DataGrades.Expression);
            MockSetGrades.As <IQueryable <LookupGradeModel> >().Setup(m => m.ElementType).Returns(DataGrades.ElementType);
            MockSetGrades.As <IQueryable <LookupGradeModel> >().Setup(m => m.GetEnumerator()).Returns(DataGrades.GetEnumerator());

            var DataSubjects = new List <SubjectModel> {
                new SubjectModel {
                    SubjectId = 0, IsActive = true
                },
                new SubjectModel {
                    SubjectId = 1, IsActive = true
                },
                new SubjectModel {
                    SubjectId = 2, IsActive = false
                }
            }.AsQueryable();

            var MockSetSubjects = new Mock <DbSet <SubjectModel> >();

            MockSetSubjects.As <IQueryable <SubjectModel> >().Setup(m => m.Provider).Returns(DataSubjects.Provider);
            MockSetSubjects.As <IQueryable <SubjectModel> >().Setup(m => m.Expression).Returns(DataSubjects.Expression);
            MockSetSubjects.As <IQueryable <SubjectModel> >().Setup(m => m.ElementType).Returns(DataSubjects.ElementType);
            MockSetSubjects.As <IQueryable <SubjectModel> >().Setup(m => m.GetEnumerator()).Returns(DataSubjects.GetEnumerator());

            var DataClassTeacherSubject = new List <ClassTeacherSubjectsModel> {
                new ClassTeacherSubjectsModel {
                    SubjectId = 1, ClassId = 1, TeacherId = 0
                },
                new ClassTeacherSubjectsModel {
                    SubjectId = 0, ClassId = 2, TeacherId = 4
                },
            }.AsQueryable();

            var MockSetClassTeacherSubject = new Mock <DbSet <ClassTeacherSubjectsModel> >();

            MockSetClassTeacherSubject.As <IQueryable <ClassTeacherSubjectsModel> >().Setup(m => m.Provider).Returns(DataClassTeacherSubject.Provider);
            MockSetClassTeacherSubject.As <IQueryable <ClassTeacherSubjectsModel> >().Setup(m => m.Expression).Returns(DataClassTeacherSubject.Expression);
            MockSetClassTeacherSubject.As <IQueryable <ClassTeacherSubjectsModel> >().Setup(m => m.ElementType).Returns(DataClassTeacherSubject.ElementType);
            MockSetClassTeacherSubject.As <IQueryable <ClassTeacherSubjectsModel> >().Setup(m => m.GetEnumerator()).Returns(DataClassTeacherSubject.GetEnumerator());

            var DataTimeOff = new List <TimeOffModel> {
                new TimeOffModel {
                    ItemId = 4, Day = 2, LessonIndex = 3, ItemType = 4
                },
                new TimeOffModel {
                    ItemId = 1, Day = 2, LessonIndex = 3, ItemType = 2
                },
                new TimeOffModel {
                    ItemId = 1, Day = 2, LessonIndex = 3, ItemType = 1
                },
                new TimeOffModel {
                    ItemId = 4, Day = 2, LessonIndex = 3, ItemType = 3
                },
            }.AsQueryable();

            var MockSetTimeOff = new Mock <DbSet <TimeOffModel> >();

            MockSetTimeOff.As <IQueryable <TimeOffModel> >().Setup(m => m.Provider).Returns(DataTimeOff.Provider);
            MockSetTimeOff.As <IQueryable <TimeOffModel> >().Setup(m => m.Expression).Returns(DataTimeOff.Expression);
            MockSetTimeOff.As <IQueryable <TimeOffModel> >().Setup(m => m.ElementType).Returns(DataTimeOff.ElementType);
            MockSetTimeOff.As <IQueryable <TimeOffModel> >().Setup(m => m.GetEnumerator()).Returns(DataTimeOff.GetEnumerator());

            var DataBuildings = new List <BuildingModel> {
                new BuildingModel {
                    Id = 4, IsActive = true
                },
                new BuildingModel {
                    Id = 1, IsActive = true, TypeId = 1
                },
            }.AsQueryable();

            var MockSetBuildings = new Mock <DbSet <BuildingModel> >();

            MockSetBuildings.As <IQueryable <BuildingModel> >().Setup(m => m.Provider).Returns(DataBuildings.Provider);
            MockSetBuildings.As <IQueryable <BuildingModel> >().Setup(m => m.Expression).Returns(DataBuildings.Expression);
            MockSetBuildings.As <IQueryable <BuildingModel> >().Setup(m => m.ElementType).Returns(DataBuildings.ElementType);
            MockSetBuildings.As <IQueryable <BuildingModel> >().Setup(m => m.GetEnumerator()).Returns(DataBuildings.GetEnumerator());

            var DataSectionWeekend = new List <SectionWeekendModel> {
                new SectionWeekendModel {
                    DayIndex = 0, SectionId = 1
                },
                new SectionWeekendModel {
                    DayIndex = 1, SectionId = 1
                },
                new SectionWeekendModel {
                    DayIndex = 3, SectionId = 1
                }
            }.AsQueryable();

            var MockSetSectionWeekend = new Mock <DbSet <SectionWeekendModel> >();

            MockSetSectionWeekend.As <IQueryable <SectionWeekendModel> >().Setup(m => m.Provider).Returns(DataSectionWeekend.Provider);
            MockSetSectionWeekend.As <IQueryable <SectionWeekendModel> >().Setup(m => m.Expression).Returns(DataSectionWeekend.Expression);
            MockSetSectionWeekend.As <IQueryable <SectionWeekendModel> >().Setup(m => m.ElementType).Returns(DataSectionWeekend.ElementType);
            MockSetSectionWeekend.As <IQueryable <SectionWeekendModel> >().Setup(m => m.GetEnumerator()).Returns(DataSectionWeekend.GetEnumerator());

            var DataStage = new List <LookupStageModel> {
                new LookupStageModel {
                    IsActive = true, SectionId = 1, StageId = 4
                },
            }.AsQueryable();

            var MockSetStage = new Mock <DbSet <LookupStageModel> >();

            MockSetStage.As <IQueryable <LookupStageModel> >().Setup(m => m.Provider).Returns(DataStage.Provider);
            MockSetStage.As <IQueryable <LookupStageModel> >().Setup(m => m.Expression).Returns(DataStage.Expression);
            MockSetStage.As <IQueryable <LookupStageModel> >().Setup(m => m.ElementType).Returns(DataStage.ElementType);
            MockSetStage.As <IQueryable <LookupStageModel> >().Setup(m => m.GetEnumerator()).Returns(DataStage.GetEnumerator());

            MockDataModel = new Mock <DataModel>(new List <int> {
                { 4 }
            });
            MockDataModel.Setup(item => item.ActitvityGroups).Returns(MockSetActivityGroup.Object);
            MockDataModel.Setup(item => item.ClassesLookup).Returns(MockSetClass.Object);
            MockDataModel.Setup(item => item.SubjectGrades).Returns(MockSetSubjectGrade.Object);
            MockDataModel.Setup(item => item.Employees).Returns(MockSetEmployees.Object);
            MockDataModel.Setup(item => item.GradesLookup).Returns(MockSetGrades.Object);
            MockDataModel.Setup(item => item.Subjects).Returns(MockSetSubjects.Object);
            MockDataModel.Setup(item => item.ClassTeacherSubjects).Returns(MockSetClassTeacherSubject.Object);
            MockDataModel.Setup(item => item.TimesOff).Returns(MockSetTimeOff.Object);
            MockDataModel.Setup(item => item.Buildings).Returns(MockSetBuildings.Object);
            MockDataModel.Setup(item => item.Weekends).Returns(MockSetSectionWeekend.Object);
            MockDataModel.Setup(item => item.StagesLookup).Returns(MockSetStage.Object);
        }
Example #17
0
 static EntityConnectionHelper()
 {
     DataReaderInspectorProviderConfiguration.RegisterProvider();
     EffortProviderConfiguration.RegisterProvider();
 }
Example #18
0
 public void Initialize()
 {
     EffortProviderConfiguration.RegisterProvider();
     DiContainerConfiguration.BuildDiContainer();
 }
 public void TestInitialize()
 {
     EffortProviderConfiguration.RegisterProvider();
     _data         = new ObjectData();
     _dbConnection = Effort.DbConnectionFactory.CreateTransient(new ObjectDataLoader(_data));
 }