예제 #1
0
        private static FakeSongLoadEngine CreateFakeLoadEngine(List <Song> songs)
        {
            var engine = new FakeSongLoadEngine(songs);

            LoaderFactory.SetLoaderInstance(new FakeAsyncSongLoader(engine, new FakeSongCollector(songs)));
            return(engine);
        }
예제 #2
0
        public void SetUpMock()
        {
            _webDriverMock         = new Mock <IWebDriver>();
            _searchContextMock     = new Mock <IHtmlElement>();
            _pageObjectFactoryMock = new Mock <IPageObjectFactory>();
            _proxyFactoryMock      = new Mock <IProxyFactory>();

            _loaderFactory = new LoaderFactory(_pageObjectFactoryMock.Object, _proxyFactoryMock.Object);

            _searchContextMock
            .Setup(ctx => ctx.WrappedDriver)
            .Returns(_webDriverMock.Object);

            _searchContextMock
            .Setup(ctx => ctx.FindElement(It.IsAny <By>()))
            .Returns(() => new Mock <IWebElement>().Object);

            _searchContextMock
            .Setup(ctx => ctx.FindElements(It.IsAny <By>()))
            .Returns(() => new ReadOnlyCollection <IWebElement>(
                         new List <IWebElement>
            {
                new Mock <IWebElement>().Object,
                new Mock <IWebElement>().Object
            }
                         ));

            _pageObjectFactoryMock
            .Setup(f => f.Create <HtmlElement>(It.IsAny <ISearchContext>()))
            .Returns(() => new HtmlElement(_searchContextMock.Object));

            _proxyFactoryMock
            .Setup(f => f.CreateWebElementProxy(It.IsAny <ILoader <IWebElement> >()))
            .Returns(() => new Mock <IWebElement>().Object);
        }
예제 #3
0
        private void LoadAsync(string path)
        {
            Messenger.Log("Load command with " + path + "|");
            var loader = new LoaderFactory().CreateAsync(path);

            controller.LoadHandler.LoadSongs(loader, model.ProgressTracker);
        }
예제 #4
0
        public void GetFileLoaderThrowsArgumentNullExceptionIfPasswordIsNull()
        {
            var loader = new LoaderFactory();

            byte[] stream = { 1, 0 };
            loader.GetFileLoader(stream, null);
        }
예제 #5
0
        public void CreatesCustomLoader()
        {
            LoaderFactory.Type = typeof(CustomLoader);
            var loader = LoaderFactory.CreateInstance(GetType().Assembly.Location);

            Assert.Equals(typeof(CustomLoader), loader.GetType());
        }
예제 #6
0
        public void TestBasicSetup2()
        {
            ILoaderFactory factory = new LoaderFactory();

            Assert.IsNotNull(factory);
            Assert.IsNull(factory.GetLoader(null));
        }
        // PUBLIC METHODS
        Loader <T> ILoaderAdapter <T> .FormToLoaderAdapt(eLoaderFactoryContext i_LoaderFactoryContext, FacebookObjectCollection <T> i_FacebookObjectCollection, ListView i_ListView)
        {
            this.r_ParamsList.Add(i_FacebookObjectCollection);
            this.r_ParamsList.Add(i_ListView);

            return(LoaderFactory <T> .CreateLoader(i_LoaderFactoryContext, this.r_ParamsList));
        }
예제 #8
0
 public void Load(string origin_path, string temp_path)
 {
     Loader ??= LoaderFactory.Invoke(Name);
     OriginPath = origin_path;
     // TODO: copy the entire folder at origin_path to temp_path
     ModuleAssembly = Loader.Load(temp_path);
 }
예제 #9
0
        public void OnLoad(string fileName)
        {
            Preconditions.CheckNotNullOrEmpty(fileName, "fileName");

            _view.OnShowProgress(true);

            _root.Clear();
            _vertices.Clear();

            var loader = LoaderFactory.Create(LoaderFactory.Excel);

            if (!Preconditions.CheckNotNull(loader))
            {
                _view.OnShowError("Ошибка при загрузке файла.");
                return;
            }

            var thread = new Thread(() =>
            {
                _root = loader.Load(fileName);
                _root.Traverse(AddVertices);

                _view.OnGraphLoaded(_root, _vertices);
                _view.OnUpdateView();
                _view.OnShowProgress(false);
            })
            {
                IsBackground = true
            };

            thread.Start();
        }
        public void SetUpMock()
        {
            _webDriverMock = new Mock<IWebDriver>();
            _searchContextMock = new Mock<IHtmlElement>();
            _pageObjectFactoryMock = new Mock<IPageObjectFactory>();
            _proxyFactoryMock = new Mock<IProxyFactory>();

            _loaderFactory = new LoaderFactory(_pageObjectFactoryMock.Object, _proxyFactoryMock.Object);

            _searchContextMock
                .Setup(ctx => ctx.WrappedDriver)
                .Returns(_webDriverMock.Object);

            _searchContextMock
                .Setup(ctx => ctx.FindElement(It.IsAny<By>()))
                .Returns(() => new Mock<IWebElement>().Object);

            _searchContextMock
                .Setup(ctx => ctx.FindElements(It.IsAny<By>()))
                .Returns(() => new ReadOnlyCollection<IWebElement>(
                    new List<IWebElement>
                    {
                        new Mock<IWebElement>().Object,
                        new Mock<IWebElement>().Object
                    }
                ));

            _pageObjectFactoryMock
                .Setup(f => f.Create<HtmlElement>(It.IsAny<ISearchContext>()))
                .Returns(() => new HtmlElement(_searchContextMock.Object));

            _proxyFactoryMock
                .Setup(f => f.CreateElementProxy(It.IsAny<ILoader<IWebElement>>()))
                .Returns(() => new Mock<IWebElement>().Object);
        }
예제 #11
0
        private void LoadDocument(string fileName, IPassword password)
        {
            var buffer     = _fileProxy.Load(fileName);
            var loader     = new LoaderFactory();
            var fileLoader = loader.GetFileLoader(buffer, password);

            EncodedData = fileLoader.Load(buffer);
        }
예제 #12
0
        public void GetFileLoaderThrowsInValidOperationExceptionForInvalifFileFormat()
        {
            var loader = new LoaderFactory();

            byte[] stream           = { 1, 2 };
            var    password         = new Password("password", "password2");
            var    fileFormatLoader = loader.GetFileLoader(stream, password);
        }
예제 #13
0
        Loader <T> ILoaderAdapter <T> .FormToLoaderAdapt(eLoaderFactoryContext i_LoaderFactoryContext, FacebookObjectCollection <T> i_FacebookObjectCollection, List <PropertyCounter> i_PropertyCounterList, Chart i_PieChart, string i_PieChartTitle, string i_PieChartID)
        {
            this.r_ParamsList.Add(i_FacebookObjectCollection);
            this.r_ParamsList.Add(i_PropertyCounterList);
            this.r_ParamsList.Add(i_PieChart);
            this.r_ParamsList.Add(i_PieChartTitle);
            this.r_ParamsList.Add(i_PieChartID);

            return(LoaderFactory <T> .CreateLoader(i_LoaderFactoryContext, this.r_ParamsList));
        }
예제 #14
0
        public void CreateTest()
        {
            LoaderFactory loaderFactory = new LoaderFactory();
            ILoader       loader        = loaderFactory.CreateLoader();

            Assert.IsNotNull(loader);
            Assert.IsInstanceOfType(loader, typeof(Loader));
            Assert.IsNotNull(((Loader)loader).Components);
            Assert.AreEqual(12, ((Loader)loader).Components.Count);
        }
예제 #15
0
        public void GetFileLoaderReturnsLoaderForVersion10Files()
        {
            var loader = new LoaderFactory();

            byte[] stream           = { 1, 0 };
            var    password         = new Password("password", "password2");
            var    fileFormatLoader = loader.GetFileLoader(stream, password);

            Assert.AreEqual(typeof(Version10Loader), fileFormatLoader.GetType());
        }
예제 #16
0
 protected override Task AsyncExecute(object parameter)
 {
     return(Task.Run(async() =>
     {
         var loader = new LoaderFactory().CreateLibraryLoader("library.xml");
         await controller.LoadHandler.LoadSongs(loader, model.ProgressTracker);
         Messenger.Log("Done loading library");
         view.CommandCompleted(this);
     }));
 }
예제 #17
0
        public void TestFileLoaderReturn()
        {
            ILoaderFactory factory = new LoaderFactory();

            Mock <ILoaderConfiguration> testConfig = new Mock <ILoaderConfiguration>();

            testConfig.Setup(x => x.LoaderType).Returns(LoaderTypeEnum.FileLoader);

            ILoader loader = factory.GetLoader(testConfig.Object);

            Assert.AreEqual(typeof(FileLoader), loader.GetType());
        }
예제 #18
0
        public static Mesh CreateMesh(string pathToMesh)
        {
            var modelLoader     = LoaderFactory.GetModelLoader(pathToMesh);
            var indices         = new List <uint>();
            var indexedVertices = new List <Vector3>();
            var indexedUvs      = new List <Vector2>();
            var indexedNormals  = new List <Vector3>();

            modelLoader.LoadModel(pathToMesh, indices, indexedVertices, indexedUvs, indexedNormals);

            return(new Mesh(indexedVertices, indexedUvs, indexedNormals, indices));
        }
예제 #19
0
        public IntroWindow(JukeViewModel viewModel)
        {
            InitializeComponent();
            DataContext    = viewModel;
            viewModel.View = this;

            viewModel.PropertyChanged += ViewModel_PropertyChanged;
            LoaderFactory.SetLoaderInstance(new AsyncSongLoader(new FileFinderEngine(),
                                                                new TaglibTagReaderFactory()
            {
                BackupFactory = new WmpTagReaderFactory()
            }));
        }
예제 #20
0
 protected override Task AsyncExecute(object parameter)
 {
     return(Task.Run(() =>
     {
         Messenger.Log("Load songs async, prompt path");
         var path = view.PromptPath();
         if (!string.IsNullOrEmpty(path))
         {
             Messenger.Log("Loading songs async from " + path);
             var loader = new LoaderFactory().CreateAsync(path);
             controller.LoadHandler.LoadSongs(loader, model.ProgressTracker);
         }
     }));
 }
        public void LoadSongs_ViewControlNotifiedOnCompletion()
        {
            var songs  = ViewModelFaker.CreateSongs(1, 2, 1);
            var engine = CreateFakeLoadEngine(songs);

            var viewControl = new FakeViewControl("path");

            LoaderFactory.SetLoaderInstance(new FakeAsyncSongLoader(engine, new FakeSongCollector(songs)));

            var viewModel = CreateAdminViewModel(viewControl);

            viewModel.LoadSongs.Execute(this);
            engine.SignalComplete();
            IsTrue(viewControl.Completed);
        }
        public void LoadSongs_LoaderStartedWithPath()
        {
            var engine      = CreateFakeLoadEngine(ViewModelFaker.CreateSongs(1, 2, 1));
            var listener    = new EventListener(JukeController.Instance);
            var viewControl = new FakeViewControl("path");

            LoaderFactory.SetLoaderInstance(new FakeAsyncSongLoader(engine));

            var viewModel = CreateAdminViewModel(viewControl);

            viewModel.LoadSongs.Execute(this);

            AreEqual("path", engine.Path);
            IsTrue(listener.LoadInitiated);
        }
예제 #23
0
        static void Main(string[] args)
        {
            var arguments = ArgumentParser.ParseArguments(args);

            RegisterComponents();
            var loaderFactory       = new LoaderFactory();
            var newGameProvider     = new LocalNewGameProvider(loaderFactory);
            var gameProcessor       = new GameProcessor(Configuration.TickPeriod);
            var gamePersistence     = new LocalGamePersistence(loaderFactory, Configuration.DefaultSaveDirectory);
            var gameRendererFactory = new GameRendererFactory();

            var client = new LoopingGameClient(gameProcessor, newGameProvider, gamePersistence, gameRendererFactory, arguments.SaveFileName);

            client.PlayGame(arguments);
        }
예제 #24
0
        void OnGUI()
        {
            defaultPath = GUILayout.TextField(defaultPath);

            if (GUILayout.Button("Load File"))
            {
                var dataLoader = LoaderFactory.CreateFileLoader(defaultPath);
                var type       = CADTypeUtils.FromFileExtension(defaultPath);
                var model      = _loader.Load(type, dataLoader);


                var gameObject = Builder.Create("Model", "defaultMat");
                Builder.UpdateMesh(gameObject, model);
                dataLoader.Close();
            }
        }
예제 #25
0
        public async Task <byte[]> LoadDocumentFromSystemAsync(string client, string documentName)
        {
            var path = Path.Combine(_root, client, documentName);

            using (var source = File.OpenRead(path))
            {
                using (var destination = new MemoryStream())
                {
                    await source.CopyToAsync(destination);

                    var extension = Path.GetExtension(documentName)?.Replace(".", "");
                    var loader    = LoaderFactory.Select(extension);
                    return(await loader.LoadFileAsync(destination));
                }
            }
        }
예제 #26
0
        public void LoadTest()
        {
            TestModel     model         = new TestModel();
            LoaderFactory loaderFactory = new LoaderFactory();
            ILoader       loader        = loaderFactory.CreateLoader();

            Assert.IsInstanceOfType(loader, typeof(Loader));
            using (DbDataReader reader = CreateReader())
            {
                Assert.IsTrue(reader.Read());
                loader.Load(model, reader);
                reader.Close();
            }
            Assert.AreEqual(TEST_ID, model.Id);
            Assert.AreEqual(TEST_NAME.TrimEnd(), model.Name);
            Assert.AreEqual(TEST_TIMESTAMP, model.Timestamp);
        }
예제 #27
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            JukeController.Instance.Player.RegisterPlayerEngine(new WmpPlayerEngine());
            LoaderFactory.SetLoaderInstance(new AsyncSongLoader(new FileFinderEngine(),
                                                                new TaglibTagReaderFactory()
            {
                BackupFactory = new WmpTagReaderFactory()
            }));
            LoaderFactory.SetLibraryLoaderInstance(new XmlSongReader("library.xml"));
            WriterFactory.SetWriterInstance(new XmlSongWriter("library.xml"));


            Logger.Start("juke.log");
            //Logger.ConsoleLog();
            Messenger.Log("Starting J.U.K.E.");
            this.DispatcherUnhandledException += App_DispatcherUnhandledException;
        }
예제 #28
0
        // Metodos para Crear y destruir configuraciones dinamicas en tiempo de ejecuccion.
        // Se puede usar estos metodos a modo de cache seguro dentro de las aplicaciones.

        /// <summary>
        /// Crea un contenedor en modo manual y los guarda en el sistema de configuracion.
        /// El programador puede crear un contenedor en tiempo de ejecuccion y usarlo posteriormente con los demas contenedores.
        /// </summary>
        /// <param name="appKey">Llave para el contenedor. No puede estar repetida.</param>
        /// <param name="groups">Listado de nombres para los grupos. Debe tener almenos uno.</param>
        /// <returns>Contenedor creado.</returns>
        public static SettingsManager CreateContainer(string appKey, IEnumerable <string> groups)
        {
            lock (_instanceLock)
            {
                //Validaciones
                if (String.IsNullOrWhiteSpace(appKey))
                {
                    throw new ArgumentException("AppKey must be not null and not empty", "appKey");
                }
                if (groups == null)
                {
                    throw new ArgumentNullException("groups", "Groups cannot be null.");
                }
                if (!groups.Any())
                {
                    throw new ArgumentException("Groups must have at least 1 element.", "groups");
                }
                if (groups.Any(x => String.IsNullOrWhiteSpace(x)))
                {
                    throw new ArgumentException("All groups must be not null and not empty.", "groups");
                }
                if (_stores.ContainsKey(appKey))
                {
                    throw new DuplicateKeyException(appKey, String.Format("Cannot create SettingsManager with key {0}, call method MergeSettings instead.", appKey));
                }

                //Crear contenedor
                var storeData = new ConcurrentDictionary <string, IDictionary <string, object> >(
                    groups.Select(groupKey =>
                                  new KeyValuePair <string, IDictionary <string, object> >(
                                      groupKey,
                                      new ConcurrentDictionary <string, object>()
                                      )));
                var newStore = new SettingsManager(appKey, storeData);
                foreach (var group in groups)
                {
                    newStore._loaders.Add(LoaderFactory.GetLoader(Sections.LoaderType.Manual, appKey, null, group));
                }
                _stores.Add(appKey, newStore);
                Logger.InfoFormat("[Manual-Mode] {0} SettingsManager Store Added successfully.", appKey);
                return(newStore);
            }
        }
예제 #29
0
 public static void AddGroup(string appKey, string group)
 {
     lock (_instanceLock)
     {
         if (String.IsNullOrWhiteSpace(group))
         {
             throw new ArgumentException("Group must be not null and not empty", "group");
         }
         var store = GetStore(appKey);   //Get the Store
         if (store._settingsContainer.ContainsKey(group))
         {
             throw new DuplicateKeyException(group, String.Format("Group {0} already exisit in Store {1}.", group, appKey));
         }
         if (!store._settingsContainer.TryAdd(group, new ConcurrentDictionary <string, object>()))
         {
             throw new Exception(String.Format("Error adding Group {0} into Store {1}", group, appKey));
         }
         store._loaders.Add(LoaderFactory.GetLoader(Sections.LoaderType.Manual, appKey, null, group));
     }
 }
예제 #30
0
        static void RunResourceLoader()
        {
            Console.WriteLine("Please enter url");
            var urlString = Console.ReadLine();

            if (!string.IsNullOrWhiteSpace(urlString))
            {
                Console.WriteLine("Please select type of loader:\nA - WebClientLoader\nB - HttpWebRequestLoader");


                //pattern Fabric
                ILoader loader = LoaderFactory.Create(Console.ReadKey().Key);

                Console.WriteLine(" - will be used -> {0} ", loader.GetType().Name);
                string resultOfLoad = string.Empty;
                try
                {
                    resultOfLoad = loader.Load(new Uri(urlString));
                }
                catch (ResourseNotLoadedException ex)
                {
                    Console.WriteLine(ex.ToString());
                }

                if (!string.IsNullOrWhiteSpace(resultOfLoad))
                {
                    Console.WriteLine("Website as string:\n{0}", resultOfLoad);
                }
                else
                {
                    Console.WriteLine("The webClientLoader returned an empty string");
                }
            }
            else
            {
                Console.WriteLine("Url is not valid");
                Console.ReadLine();
                return;
            }
        }
예제 #31
0
 private KeyboardModel LoadKeyboardModel(string path)
 {
     try
     {
         Loader ldr = LoaderFactory.CreateLoader();
         return(ldr.LoadKeyboard(path));
     }
     catch (LoaderException e)
     {
         string msg = e.Message;
         if (e.InnerException != null)
         {
             msg += "\n" + e.InnerException.Message;
         }
         logger.Warn("Exception occurred while loading keyboard!\n{0}", msg);
         throw new Exception(msg);
     }
     catch (Exception e)
     {
         string msg = "Unrecognized exception occurred while loading keyboard!";
         logger.Error(ExceptionUtil.Format(msg, e));
         throw new Exception(msg);
     }
 }