示例#1
0
        public ConfigurationSetter(IManualInputProvider manualInputProvider)
        {
            _message      = manualInputProvider.message;
            _languageType = manualInputProvider.ReturnLanguageTypeInputValue();

            ReaderFactory = new ReaderFactory(_languageType);

            try
            {
                LanguageConfiguration = new LanguageDataProvider(ReaderFactory);
            }
            catch (Exception e)
            {
                Log.Error($"{nameof(ConfigurationSetter)}, {e.Message}, {e.StackTrace}");
                Console.WriteLine(e.StackTrace);
                Console.ReadKey();
                Environment.Exit(0);
            }

            try
            {
                Message        = new Messages(LanguageConfiguration);
                Alert          = new Alerts(LanguageConfiguration);
                Constant       = new DefaultConstants(LanguageConfiguration);
                CardAttributes = new CardAttributesConverter(LanguageConfiguration);
            }
            catch (Exception e)
            {
                Log.Error($"{nameof(ConfigurationSetter)}, {e.Message}, {e.StackTrace}");
                Console.WriteLine(e.StackTrace);
                Console.ReadKey();
                Environment.Exit(0);
            }
        }
示例#2
0
        public void DefaultConstantsTestIntPropertyShouldBeNotZero()
        {
            //Assign
            var mockConfiguration = new Mock <ILanguageDataProvider>();

            mockConfiguration.Setup(x => x.GetTextFromConfiguration(It.IsAny <string>()))
            .Returns("1");
            //Act
            var defaultConsts = new DefaultConstants(mockConfiguration.Object);

            //Assert
            Assert.IsTrue(defaultConsts.numberOfCards_1_ != 0);
        }
示例#3
0
        public void DefaultConstantsTestStringPropertyShouldBeSet()
        {
            //Assign
            var mockConfiguration = new Mock <ILanguageDataProvider>();

            mockConfiguration.Setup(x => x.GetTextFromConfiguration(It.IsAny <string>()))
            .Returns("fakeMessage");
            //Act
            var defaultConsts = new DefaultConstants(mockConfiguration.Object);

            //Assert
            Assert.IsNotNull(defaultConsts.strategy_1_4_ == "fakeMessage");
            Assert.IsNotNull(defaultConsts.strategy_2_5_ == "fakeMessage");
            Assert.IsNotNull(defaultConsts.strategy_Human_6_ == "fakeMessage");
            Assert.IsNotNull(defaultConsts.WantToContinue_7_ == "fakeMessage");
        }
        static void Main(string[] args)
        {
            IDownloadService        ds = new DownloadService();
            IResourcePackageManager rpm;

            DefaultConstants dc = new DefaultConstants();

            dc.CourseId          = 201;
            dc.CultureCode       = "en";
            dc.SiteVersion       = "development";
            dc.PartnerCode       = "none";
            dc.LocalContentPath  = @"d:\offline\content\";
            dc.LocalMediaPath    = @"d:\offline\media\";
            dc.ServicePrefix     = "http://mobiledev.englishtown.com";
            dc.ResourcePrefix    = "http://local.englishtown.com";
            dc.ContentGenerateBy = LevelType.Level;
            dc.MediaGenerateBy   = LevelType.Lesson;

            IContentResourceServcie courseContentResourceService = new CourseContentResourceService(ds, dc);

            ICourseStructureManager cs = new CourseStructureManager(ds, courseContentResourceService, dc);
            Course course = cs.BuildCourseStructure();

            var json = JsonConvert.SerializeObject(course);

            // Get all Activities under the level.
            foreach (Level level in course.Levels)
            {
                IMapfileManager contentMapFileManager = new ContentMapfileManager(level, dc);

                foreach (Unit unit in level.Units)
                {
                    foreach (Lesson lesson in unit.Lessons)
                    {
                        IMapfileManager mediaMapFileManager = new MediaMapfileManager(lesson, dc);

                        foreach (Step step in lesson.Steps)
                        {
                            foreach (Activity activity in step.Activities)
                            {
                                IContentResourceServcie activityContentService = new ActivityContentResourceService(ds, activity.Id, dc);

                                IResourceDownloadManager activityContent = new ActivityContentResourceDownloadManager(ds, activity, activityContentService, dc);
                                activityContent.Download();
                                contentMapFileManager.Add(activityContent.ResourceList);

                                IResourceDownloadManager mediaResource = new MediaResourceDownloadManager(ds, activity, activityContentService, dc);
                                mediaResource.Download();
                                mediaMapFileManager.Add(mediaResource.ResourceList);

                                System.Console.WriteLine("Downlaoded Contontent & Media -- Activity: " + activity.Id);
                            }
                        }

                        // Update Mapfile.
                        // TODO


                        if (mediaMapFileManager.CreateOrUpdated())
                        {
                            // Package by..
                            IResourcePackageManager mpm = new MediaResourcePackageManager(lesson, dc);
                            mpm.Package();

                            System.Console.WriteLine("Package -- Lesson: " + lesson.Id);
                        }
                    }

                    // Get Unit content structure
                    IContentResourceServcie  ucs         = new UnitContentResourceService(ds, unit.Id, dc);
                    IResourceDownloadManager unitContent = new UnitContentResourceDownloadManager(ds, unit, ucs, dc);
                    unitContent.Download();
                    contentMapFileManager.Add(unitContent.ResourceList);

                    System.Console.WriteLine("Downloaded -- Unit: " + unit.Id);
                }

                // Get level content structure
                IContentResourceServcie  lcs          = new LevelContentResourceService(ds, level.Id, dc);
                IResourceDownloadManager levelContent = new LevelContentResourceDownloadManager(ds, level, lcs, dc);
                levelContent.Download();
                contentMapFileManager.Add(levelContent.ResourceList);

                if (contentMapFileManager.CreateOrUpdated())
                {
                    // if the local mapfile is different with new, just repackage and replace it.
                    IResourcePackageManager cpm = new ContentResourcePackageManager(level, dc);
                    cpm.Package();
                    System.Console.WriteLine("Packaged -- Level: " + level.Id);
                }
            }
        }
        public void CanDownloadCourseStructureSuccessful()
        {
            string content;

            LogEntry logEntry = new LogEntry();

            using (StreamReader reader = new StreamReader(@"CourseStructureLite.json"))
            {
                content = reader.ReadToEnd();
            }

            var ds = new Mock<IDownloadService>();
            ds.Setup(foo => foo.DownloadFromPath(It.IsAny<Uri>())).Returns((string s) => s.ToLower());

            var crs = new Mock<IContentResourceServcie>();
            // auto-mocking hierarchies (a.k.a. recursive mocks)
            crs.Setup(foo => foo.Content).Returns(content);

            DefaultConstants dc = new DefaultConstants();
            dc.CourseId = 201;
            dc.CultureCode = "en";
            dc.SiteVersion = "development";
            dc.PartnerCode = "none";
            dc.LocalContentPath = @"d:\offline\content\";
            dc.LocalMediaPath = @"d:\offline\media\";
            dc.ServicePrefix = "http://mobiledev.englishtown.com";
            dc.ResourcePrefix = "http://local.englishtown.com";
            dc.ContentGenerateBy = LevelType.Level;
            dc.MediaGenerateBy = LevelType.Lesson;

            //IContentResourceServcie courseContentResourceService = new CourseContentResourceService(mock.Object, dc);

            ICourseStructureManager cs = new CourseStructureManager(ds.Object, crs.Object, dc);
            Course course = cs.BuildCourseStructure();

            string json = JsonConvert.SerializeObject(course, Formatting.Indented);

            // Get all Activities under the level.
            foreach (Level level in course.Levels)
            {
                foreach (Unit unit in level.Units)
                {
                    foreach (Lesson lesson in unit.Lessons)
                    {
                        foreach (Step step in lesson.Steps)
                        {
                            foreach (Activity activity in step.Activities)
                            {
                                IContentResourceServcie activityContentService = new ActivityContentResourceService(new DownloadService(), activity.Id, dc);

                                IResourceDownloadManager activityContent = new ActivityContentResourceDownloadManager(ds.Object, activity, activityContentService, dc);
                                activityContent.Download();

                                IResourceDownloadManager mediaResource = new MediaResourceDownloadManager(ds.Object, activity, activityContentService, dc);
                                mediaResource.Download();
                            }
                        }

                        IResourcePackageManager mpm = new MediaResourcePackageManager(lesson, dc);
                        mpm.Package();
                    }

                    IContentResourceServcie ucs = new UnitContentResourceService(new DownloadService(), unit.Id, dc);
                    // Get Unit content structure
                    IResourceDownloadManager unitContent = new UnitContentResourceDownloadManager(ds.Object, unit, ucs, dc);
                    unitContent.Download();
                }

                // Get level content structure
                IContentResourceServcie lcs = new LevelContentResourceService(new DownloadService(), level.Id, dc);
                IResourceDownloadManager levelContent = new LevelContentResourceDownloadManager(ds.Object, level, lcs, dc);
                levelContent.Download();

                IResourcePackageManager cpm = new ContentResourcePackageManager(level, dc);
                cpm.Package();
            }

            Assert.IsNotNull(cs.Course);
        }