示例#1
0
        public void CheckRenamerWithTimeCounter()
        {
            var renamer = new RenamerWithTimeCounter(new FileRenamer());
            var file    = new Mp3File("SampleFile.mp3");

            renamer.Rename(file);

            Assert.AreNotEqual((new TimeSpan()).ToString(), renamer.Elapsed.ToString());
        }
示例#2
0
        public void CheckRenamerWithTimeCounterAndPrmissionChecker()
        {
            var renamer = new RenamerWithTimeCounter(new RenamerWithPermissionCheck(new FileRenamer(), new PermissionChecker(), UserRole.User));
            var file    = new Mp3File("SampleFile.mp3");

            renamer.Rename(file);

            Assert.AreEqual("NewSampleFile.mp3", file.Path);
            Assert.AreNotEqual((new TimeSpan()).ToString(), renamer.Elapsed.ToString());
        }
示例#3
0
        static void Main(string[] args)
        {
            var files = new List <Mp3File>()
            {
                new Mp3File("FirstSample.mp3"), new Mp3File("SecondSample.mp3"), new Mp3File("ThirdSample.mp3")
            };

            foreach (var file in files)
            {
                var oldName = file.Path;
                var renamer = new RenamerWithTimeCounter(new RenamerWithPermissionCheck(new FileRenamer(), new PermissionChecker(), UserRole.Administrator));
                renamer.Rename(file);
                Console.WriteLine($"Файл {oldName} переименован в {file.Path} за {renamer.Elapsed}");
            }

            Console.ReadKey();
        }