Ejemplo n.º 1
0
        //[SetUp]
        public void GlobalSetUp()
        {
            if (_EnvironmentInitialised == false)
            {

                DirectoryInfo difo = new DirectoryInfo(Path.GetFullPath(@"..\..\TestFolders\InFolder"));
                if (difo.Exists)
                {
                    difo.RemoveReadOnly();
                    difo.Empty(true);
                }

                difo = new DirectoryInfo(Path.GetFullPath(@"..\..\TestFolders\OutFolder"));
                if (difo.Exists)
                {
                    difo.RemoveReadOnly();
                    difo.Empty(true);
                }

                DirectoryInfo dif = new DirectoryInfo(Path.GetFullPath(@"..\..\TestFolders\InToBeCopied"));
                dif.Copy(Path.GetFullPath(@"..\..\TestFolders\InFolder"));

                difo = new DirectoryInfo(Path.GetFullPath(@"..\..\TestFolders\InFolder"));
                difo.RemoveReadOnly();

                _MFH = new MusicFolderHelper(Path.GetFullPath(@"..\..\TestFolders\OutFolder"));
                CleanDirectories(_MFH);

                _MFH = new MusicFolderHelper(Path.GetFullPath(@"..\..\TestFolders\OutFolder"));
                _EnvironmentInitialised = true;
            }
        }
 internal FileCleaner(IEnumerable<string> files, IEnumerable<string> Directory, Func<string, bool> IsAlsoRemovable, Func<DirectoryInfo, bool> IsDirRemovable, bool reversible, MusicFolderHelper mfh)
 {
     _Files = new HashSet<string>(from f in ((files == null) ? Enumerable.Empty<string>() : files) select f.ToLower());
     _CanBeRemoved = IsAlsoRemovable;
     _CanDirBeRemoved = IsDirRemovable;
     _Directory = Directory ?? Enumerable.Empty<string>();
     _MFH = mfh;
 }
Ejemplo n.º 3
0
        private void CleanDirectories(MusicFolderHelper imfh)
        {
            DirectoryInfo di = new DirectoryInfo(imfh.Cache);
            di.RemoveReadOnly();
            di.Empty(true);

            GC.Collect();
            GC.WaitForPendingFinalizers();

            DirectoryInfo diroot = new DirectoryInfo(imfh.Root);
            diroot.RemoveReadOnly();
            diroot.Empty(true);
        }
        protected void Init()
        {

            _MFH = new MusicFolderHelper(DirectoryOut);
            //_SK = GetKeys();
            DirectoryIn = Path.Combine(RootDirectoryIn, InputDirectorySimpleName);
 
            object[] PIs = this.GetType().GetCustomAttributes(typeof(TestFolderAttribute), false);

            if ((PIs != null) && (PIs.Length > 0))
            {
                TestFolderAttribute tfa = PIs[0] as TestFolderAttribute;
                if (!Directory.Exists(DirectoryIn))
                {
                    Directory.CreateDirectory(DirectoryIn);
                }

                CopyName = tfa.InFolderName ?? InputDirectorySimpleName;
                CopyNameDB = tfa.DBFolderName ?? InputDirectorySimpleName;


                DirectoryInfo dif = new DirectoryInfo(Path.Combine(Path.GetFullPath(@"..\..\TestFolders\InToBeCopied"), CopyName));
                dif.Copy(DirectoryIn);


                dif = new DirectoryInfo(DirectoryIn);
                dif.RemoveReadOnly();


                //IsOverride = true;
            }
            else
            {
                CopyName = InputDirectorySimpleName;
                CopyNameDB = InputDirectorySimpleName;
            }

            CopyDBIfNeeded();

            _SK = GetKeys();
            
            OldAlbums = new List<IList<ExportAlbum>>();

            bool continu = true;
            int i = 0;

            while (continu)
            {
                string iPath = Path.Combine(DirectoryIn, string.Format("AlbumRef{0}.xml", i++));
                if (File.Exists(iPath))
                {
                    OldAlbums.Add(ExportAlbums.Import(iPath, false, String.Empty, null));
                }
                else
                    continu = false;
            }


            Albums = new List<IList<AlbumDescriptor>>();

            continu = true;
            i = 0;

            while (continu)
            {
                string iPath = Path.Combine(DirectoryIn, string.Format("Album{0}.xml", i++));
                if (File.Exists(iPath))
                {
                    Albums.Add(AlbumDescriptorExchanger.Import(iPath, false, String.Empty, null));
                }
                else
                    continu = false;
            }

            Albums.SelectMany(o => o).SelectMany(u => u.RawTrackDescriptors.Select(t => new Tuple<AlbumDescriptor, TrackDescriptor>(u, t))).Apply(o => Assert.That(o.Item1, Is.EqualTo(o.Item2.AlbumDescriptor)));

        }
 public DummySessionBuilder(MusicFolderHelper iPath, ManualSettings settings)
 {
     Folders = iPath;
     SettingFactory = settings;
     _IInfraDependencies = new CurrentInfraTools(new WindowsMusicFactory());
 }
        private MusicSessionImpl(ISessionBuilder isb,IMainWindowHwndProvider mp)
        {
            _IMW = mp;
            _AllAlbums = new AlbumCollection(this);
            _AllArtists = new ArtistCollection(this);
            _AllTracks = new TrackCollection(this);
            _MusicFolderHelper = isb.Folders;
            _ISF = isb.GetNhibernateConfiguration(DBFactoryBuilder.GetConfiguration).BuildSessionFactory();
 
            _ISFact = isb.SettingFactory;
            _CleanOnOpen = isb.DBCleanOnOpen;
            _SessionCose = isb.OnSessionClose;
            this.Dependencies = isb.InfraTools;

            TraceListener = new ApplicationTraceListener();

            _MusicConverter = new Lazy<IMusicConverter>(isb.MusicConverterBuilder);

            Trace.Listeners.Add(TraceListener);
        }