コード例 #1
0
        private DisciplineCurriculumTestEngine()
        {
            // Constructors
            this.MockCurriculumManagementPlugin = new Mock <CurriculumManagementPlugin>();
            this.MockDisciplineManagementPlugin = new Mock <DisciplineManagementPlugin>();

            this.MockCurriculumDataContext = new Mock <IDataContext>();
            this.MockDisciplineDataContext = new Mock <DisciplineManagement.Models.IDataContext>();

            this.MockWindsorContainer = new Mock <IWindsorContainer>();
            this.MockLmsService       = new Mock <LmsService>(this.WindsorContainer);
            this.MockUserService      = new Mock <IUserService>();
            this.MockCourseService    = new Mock <ICourseService>();

            var mockCacheProvider = new Mock <HttpCache>();

            this.MockDbCurriculumStorage = new Mock <DatabaseCurriculumStorage>(this.LmsService);
            this.MockCurriculumStorage   = new Mock <CachedCurriculumStorage>(this.MockDbCurriculumStorage.Object, mockCacheProvider.Object);
            this.MockDbDisciplineStorage = new Mock <DatabaseDisciplineStorage>(this.LmsService);
            this.MockDisciplineStorage   = new Mock <CachedDisciplineStorage>(this.MockDbDisciplineStorage.Object, mockCacheProvider.Object);

            // Setup links
            this.MockDbCurriculumStorage.Protected().Setup <IDataContext>("GetDbContext").Returns(
                this.CurriculumDataContext);
            this.MockDbDisciplineStorage.Protected().Setup <DisciplineManagement.Models.IDataContext>("GetDbContext").Returns(this.DisciplineDataContext);

            this.MockWindsorContainer.Setup(l => l.Resolve <IUserService>()).Returns(this.MockUserService.Object);
            this.MockWindsorContainer.Setup(l => l.Resolve <ICourseService>()).Returns(this.MockCourseService.Object);
            this.MockWindsorContainer.Setup(l => l.Resolve <IDisciplineService>()).Returns(
                new DisciplineService(this.DisciplineStorage));
            this.MockWindsorContainer.Setup(l => l.Resolve <ICurriculumService>()).Returns(
                new CurriculumService(this.CurriculumStorage));
            this.MockWindsorContainer.Setup(l => l.Resolve <ICurriculumStorage>()).Returns(this.CurriculumStorage);
            this.MockWindsorContainer.Setup(l => l.Resolve <IDisciplineStorage>()).Returns(this.DisciplineStorage);
            this.MockWindsorContainer.Setup(c => c.ResolveAll <IPlugin>()).Returns(
                new IPlugin[] { this.CurriculumManagementPlugin, this.DisciplineManagementPlugin });
            this.CurriculumManagementPlugin.Install(this.WindsorContainer, null);
            this.DisciplineManagementPlugin.Install(this.WindsorContainer, null);

            this.DataPreparer = new DataPreparer(this.DisciplineStorage, this.CurriculumStorage, this.LmsService);

            // _MockCurriculumManagementPlugin.Protected().SetupGet<ICurriculumStorage>(p => p._CurriculumStorage).Returns(CurriculumStorage);
            // _MockDisciplineManagementPlugin.Protected().SetupGet<IDisciplineStorage>(p => p._DisciplineStorage).Returns(DisciplineStorage);
            // can be replace with: (butt call it in Setup())
            this.SetupData();
        }
コード例 #2
0
        private DisciplineCurriculumTestEngine()
        {
            // Constructors
            this.MockCurriculumManagementPlugin = new Mock<CurriculumManagementPlugin>();
            this.MockDisciplineManagementPlugin = new Mock<DisciplineManagementPlugin>();

            this.MockCurriculumDataContext = new Mock<IDataContext>();
            this.MockDisciplineDataContext = new Mock<DisciplineManagement.Models.IDataContext>();

            this.MockWindsorContainer = new Mock<IWindsorContainer>();
            this.MockLmsService = new Mock<LmsService>(this.WindsorContainer);
            this.MockUserService = new Mock<IUserService>();
            this.MockCourseService = new Mock<ICourseService>();

            var mockCacheProvider = new Mock<HttpCache>();
            this.MockDbCurriculumStorage = new Mock<DatabaseCurriculumStorage>(this.LmsService);
            this.MockCurriculumStorage = new Mock<CachedCurriculumStorage>(this.MockDbCurriculumStorage.Object, mockCacheProvider.Object);
            this.MockDbDisciplineStorage = new Mock<DatabaseDisciplineStorage>(this.LmsService);
            this.MockDisciplineStorage = new Mock<CachedDisciplineStorage>(this.MockDbDisciplineStorage.Object, mockCacheProvider.Object);

            // Setup links
            this.MockDbCurriculumStorage.Protected().Setup<IDataContext>("GetDbContext").Returns(
                this.CurriculumDataContext);
            this.MockDbDisciplineStorage.Protected().Setup<DisciplineManagement.Models.IDataContext>("GetDbContext").Returns(this.DisciplineDataContext);

            this.MockWindsorContainer.Setup(l => l.Resolve<IUserService>()).Returns(this.MockUserService.Object);
            this.MockWindsorContainer.Setup(l => l.Resolve<ICourseService>()).Returns(this.MockCourseService.Object);
            this.MockWindsorContainer.Setup(l => l.Resolve<IDisciplineService>()).Returns(
                new DisciplineService(this.DisciplineStorage));
            this.MockWindsorContainer.Setup(l => l.Resolve<ICurriculumService>()).Returns(
                new CurriculumService(this.CurriculumStorage));
            this.MockWindsorContainer.Setup(l => l.Resolve<ICurriculumStorage>()).Returns(this.CurriculumStorage);
            this.MockWindsorContainer.Setup(l => l.Resolve<IDisciplineStorage>()).Returns(this.DisciplineStorage);
            this.MockWindsorContainer.Setup(c => c.ResolveAll<IPlugin>()).Returns(
                new IPlugin[] { this.CurriculumManagementPlugin, this.DisciplineManagementPlugin });
            this.CurriculumManagementPlugin.Install(this.WindsorContainer, null);
            this.DisciplineManagementPlugin.Install(this.WindsorContainer, null);

            this.DataPreparer = new DataPreparer(this.DisciplineStorage, this.CurriculumStorage, this.LmsService);

            // _MockCurriculumManagementPlugin.Protected().SetupGet<ICurriculumStorage>(p => p._CurriculumStorage).Returns(CurriculumStorage);
            // _MockDisciplineManagementPlugin.Protected().SetupGet<IDisciplineStorage>(p => p._DisciplineStorage).Returns(DisciplineStorage);
            // can be replace with: (butt call it in Setup())
            this.SetupData();
        }