Beispiel #1
0
        public void RenameMethodOverwritesFilesSuccesfully()
        {
            CurrentUser.user.username = "******";
            RenameFileBindingModel bindingModel = new RenameFileBindingModel();

            bindingModel.FileName = @"C:\Users\Nikih\Desktop\Resources\banan.docx";
            bindingModel.NewName  = "banan";
            RenamerFileService renameFileService = new RenamerFileService();

            renameFileService.Rename(bindingModel);

            FileAssert.Exists(@"C:\Users\Nikih\Desktop\Resources\Overwrite -banan.docx");
        }
Beispiel #2
0
        public void RenameMethodRenamesFilesCorrectlly()
        {
            CurrentUser.user.username = "******";
            RenameFileBindingModel bindingModel = new RenameFileBindingModel();

            bindingModel.FileName = @"C:\Users\Nikih\Desktop\Resources\banan.docx";
            bindingModel.NewName  = "izrod";
            RenamerFileService renameFileService = new RenamerFileService();

            renameFileService.Rename(bindingModel);

            FileAssert.Exists(@"C:\Users\Nikih\Desktop\Resources\izrod.docx");
        }
Beispiel #3
0
        public void RenameMethodFailed()
        {
            CurrentUser.user.username = "******";
            RenameFileBindingModel bindingModel = new RenameFileBindingModel();

            bindingModel.FileName = @"C:\Users\Nikih\Desktop\Resources\banan.docx";
            bindingModel.NewName  = "ggg";
            RenamerFileService renameFileService = new RenamerFileService();

            FieldInfo[] fields    = typeof(RenamerFileService).GetFields(BindingFlags.Instance | BindingFlags.NonPublic).ToArray();
            FieldInfo   isRenamed = fields.FirstOrDefault(x => x.Name == "isRenamed");

            isRenamed.SetValue(renameFileService, false);

            renameFileService.Rename(bindingModel);

            Assert.IsFalse((bool)isRenamed.GetValue(renameFileService));
        }