Ejemplo n.º 1
0
        public void FileOpen()
        {
            FileSourceFactory    fileSourceFactory    = new FileSourceFactory();
            ImageSourceService   imageSourceManager   = new ImageSourceService(fileSourceFactory);
            FileOperationService fileOperationService = new FileOperationService(imageSourceManager);
            ApplicationLogic     applicationLogic     = new ApplicationLogic();

            FileOperationController fileOperationController = new FileOperationController(fileOperationService, applicationLogic);

            string[] files = new string[3] {
                "ValidFile", "InvalidFile", "ValidFile"
            };

            // IList<IFileSource> imageSourceControllers = null;
            fileOperationController.OpenFiles(files);

            // Assert.AreEqual(2, imageSourceControllers.Count);
            // Assert.AreEqual(files[0], imageSourceControllers[0].Filename);

            // imageSourceControllers.Clear();
            files = null;

            // Make sure it doesn't crash with these parameters
            fileOperationController.OpenFiles(files);

            // Assert.AreEqual(0, imageSourceControllers.Count);
            files = Array.Empty <string>();

            // Make sure it doesn't crash with these parameters
            fileOperationController.OpenFiles(files);

            // Assert.AreEqual(0, imageSourceControllers.Count);
        }
Ejemplo n.º 2
0
        public void Constructor()
        {
            FileSourceFactory    fileSourceFactory    = new FileSourceFactory();
            ImageSourceService   imageSourceManager   = new ImageSourceService(fileSourceFactory);
            FileOperationService fileOperationService = new FileOperationService(imageSourceManager);
            ApplicationLogic     applicationLogic     = new ApplicationLogic();

            FileOperationController fileOperationController = new FileOperationController(fileOperationService, applicationLogic);
        }
        public void RemoveImageSource()
        {
            ImageSourceService imageSourceManager = new ImageSourceService(new FileSourceFactory());

            List <string> files = new List <string>
            {
                "ValidFile",
            };

            IEnumerable <IImageSource> imageSources = imageSourceManager.AddImageFiles(files);

            foreach (IImageSource imageSource in imageSources)
            {
                imageSourceManager.RemoveImageSource(imageSource);
            }
        }
        public void AddImageFiles()
        {
            ImageSourceService imageSourceManager = new ImageSourceService(new FileSourceFactory());

            List <string> files = new List <string>();

            imageSourceManager.AddImageFiles(files);

            files.Add("ValidFile");

            imageSourceManager.AddImageFiles(files);

            // Invalid file
            files.Add("dummy");

            imageSourceManager.AddImageFiles(files);
        }
Ejemplo n.º 5
0
        public void CloseAllFiles()
        {
            FileSourceFactory    fileSourceFactory    = new FileSourceFactory();
            ImageSourceService   imageSourceManager   = new ImageSourceService(fileSourceFactory);
            FileOperationService fileOperationService = new FileOperationService(imageSourceManager);
            ApplicationLogic     applicationLogic     = new ApplicationLogic();

            FileOperationController fileOperationController = new FileOperationController(fileOperationService, applicationLogic);

            string[] files = new string[1] {
                "ValidFile"
            };
            List <IFileSource> imageSourceControllers = new List <IFileSource>();

            // bool fileClosed = false;

            ////fileOperationController.OpenFile += (sender, eventArgs) => { imageSourceControllers.AddRange(eventArgs.ImageSourceControllers); };
            ////fileOperationController.CloseAllFiles += (sender, eventArgs) => { fileClosed = true; };

            fileOperationController.OpenFiles(files);
            ////fileOperationController.CloseFiles();

            // Assert.IsTrue(fileClosed);
        }
		IImageSourceService Create(Lazy<IBackgroundImageOptionDefinition, IBackgroundImageOptionDefinitionMetadata> lazy) {
			IImageSourceService imageSourceService;
			if (!imageSourceServices.TryGetValue(lazy.Value, out imageSourceService))
				imageSourceServices.Add(lazy.Value, imageSourceService = new ImageSourceService(themeService, backgroundImageSettingsService.GetSettings(lazy)));
			return imageSourceService;
		}
        public void RemoveImageSourceNullArgument()
        {
            ImageSourceService imageSourceManager = new ImageSourceService(new FileSourceFactory());

            Assert.Throws <ArgumentNullException>(() => imageSourceManager.RemoveImageSource(null));
        }
 public void Constructor()
 {
     ImageSourceService imageSourceManager = new ImageSourceService(new FileSourceFactory());
 }