예제 #1
0
        public void ReturnsCorrectDistinctPath()
        {
            var paths = new[]
            {
                Combine("logger.log"),
                Combine("Debug", "logger.log"),
                Combine("bin", "Debug", "logger.log"),
                Combine("C:\\", "App", "bin", "Debug", "logger.log"),
                Combine("D:\\", "App", "bin", "Debug", "logger.log"),
                Combine("C:\\", "App", "bin", "Release", "logger.log"),
                Combine("C:\\", "App", "obj", "Release", "logger.log")
            };

            var expected = new[]
            {
                Combine("logger.log"),
                Combine("Debug", "logger.log"),
                Combine("bin", "..", "logger.log"),
                Combine("C:\\", "..", "logger.log"),
                Combine("D:\\", "..", "logger.log"),
                Combine("bin", "..", "logger.log"),
                Combine("obj", "..", "logger.log")
            };

            var trie = new FileNamer(paths);

            var result = paths.Select(path => trie.GetName(path)).ToArray();

            Assert.Equal(expected, result);
        }
예제 #2
0
        public FileHeaderNamingJob(IWindowsController windowsController)
        {
            if (windowsController == null) throw new ArgumentNullException(nameof(windowsController));

            _cleanUp = windowsController.Views
                .Connect(vc => vc.Header is FileHeader)
                .Transform(vc => (FileHeader) vc.Header)
                .ToCollection()
                .Subscribe(files =>
                {
                    var renamer = new FileNamer(files.Select(f => f.FullName));
                    files.Select(page => new
                    {
                        Item = page,
                        Label = renamer.GetName(page.FullName)
                    })
                    .ForEach(x => x.Item.DisplayName = x.Label);
                });
        }