Ejemplo n.º 1
0
        public void Sorter_Run_Multiple_Times_Contains_Both_Images_Current_Year()
        {
            ImageHelper helper         = new ImageHelper();
            string      imageFileName1 = helper.GetRandomImageFileName();
            var         fileInfo1      = helper.CopyLarge(_sortingDirectory.FullName, DateTime.Now, imageFileName1);

            var generatedName1 = new CreateDateAndUploadDateStrategy(fileInfo1);
            var name1          = generatedName1.GenerateName();

            var sorter = new Sorter(_sortingDirectory.FullName, _destinationDirectory.FullName);

            sorter.RaiseFileSortEvent += HandleSortEvent;
            sorter.Sort();

            string imageFileName2 = helper.GetRandomImageFileName();
            var    fileInfo2      = helper.CopyLarge(_sortingDirectory.FullName, DateTime.Now, imageFileName2);

            var generatedName2 = new CreateDateAndUploadDateStrategy(fileInfo2);
            var name2          = generatedName2.GenerateName();

            var sorter1 = new Sorter(_sortingDirectory.FullName, _destinationDirectory.FullName);

            sorter1.RaiseFileSortEvent += HandleSortEvent;
            sorter1.Sort();


            Assert.True(File.Exists(Path.Combine(_destinationDirectory.FullName, DateTime.Now.Year.ToString(), name1)));
            Assert.True(File.Exists(Path.Combine(_destinationDirectory.FullName, DateTime.Now.Year.ToString(), name2)));
        }
Ejemplo n.º 2
0
        public string Move(bool deleteSourceFile)
        {
            var strategy = new CreateDateAndUploadDateStrategy(FileToSort);
            var newFile  = Path.Combine(DestinationPath, strategy.GenerateName());

            if (!File.Exists(newFile))
            {
                if (deleteSourceFile)
                {
                    File.Move(FileToSort.FullName, newFile);
                }
                else
                {
                    File.Copy(FileToSort.FullName, newFile);
                }
                Moved = true;
            }
            return(newFile);
        }