how to use the class IDirectoryInfoWrap

Nov 1, 2014 at 8:20 PM
I have this code
    public override void AdicionarEntidade(ArquivoHierarquia model, ArquivoHierarquiaViewModel viewModel)
    {
        var folderFormat = Server.MapPath(ConfigurationManager.AppSettings["pastaArquivosFormat"]);
        var folderName = RouteData.Values["id"].ToString();

        _arquivosHierarquiaRepositorio.ImportarFromExcelTo(string.Format(folderFormat, FOLDERNAME, folderName) + model.FileName, model);

        base.AdicionarEntidade(model, viewModel);

        // Nome da pasta = Id da entidade
        new DirectoryInfo(string.Format(folderFormat, FOLDERNAME, folderName)).Rename(model.Id.ToString());
    }
How to use IDirectoryInfoWrap with this code new DirectoryInfo
Nov 2, 2014 at 12:56 PM
Is Rename some kind of extension? Really there is only MoveTo. I used this against UnitWrappers, but should work with small modifications SystemWrapper to:
     [Test]
        public void CreateDirectory_MoveTo()
        {
            //arange
            IDirectory directory = new DirectoryWrap(); // should create this somewhere and inject into you method for later mocking
            var source = Path.GetRandomFileName();
            var target = Path.GetRandomFileName();

            //act
            IDirectoryInfo info = directory.CreateDirectory(source);           
            info.MoveTo(target);

            //assert
            Assert.IsTrue(info.Exists);

            // clean
            info.Delete();    
        }