Exemplo n.º 1
0
        public void Should_Duplicate_FoldersAndChildItems()
        {
            var jobScheduler  = Substitute.For <IJobScheduler>();
            var settingsStore = Substitute.For <ISettingsStore>();

            var rootItem = new RootItem();
            var folder   = new Folder();
            var item1    = new Item();
            var item2    = new Item();

            rootItem.Add(folder);
            folder.Add(item1);
            folder.Add(item2);

            var command = new DuplicateCommand(folder);
            var handler = new DuplicateCommandHandler(jobScheduler, settingsStore);

            handler.Handle(command);

            Assert.IsTrue(rootItem.Items.Count == 2);

            var newFolder = rootItem.Items[1];

            Assert.IsTrue(newFolder.Items.Count == 2);

            Assert.AreSame(newFolder, newFolder.Items[0].Parent);
            Assert.AreSame(newFolder, newFolder.Items[1].Parent);

            jobScheduler.Received(1).Schedule(newFolder, true);

            settingsStore.Received(1).TrySave();
        }
Exemplo n.º 2
0
        /// <summary>
        /// 组合
        /// </summary>
        static void Composite()
        {
            Console.WriteLine($"组合{Environment.NewLine}-------------------------------------------");

            IFile folder   = new Folder("我的文档");
            IFile txtFileA = new Txt("新建文本文档A");
            IFile pngFileA = new Png("QQ截图A");
            IFile folderA  = new Folder("新建文件夹A");

            if (folder.IsFolder)
            {
                folder.Add(txtFileA);
                folder.Add(pngFileA);
                folder.Add(folderA);
            }

            IFile txtFileB = new Txt("新建文本文档B");
            IFile pngFileB = new Png("QQ截图B");

            if (folderA.IsFolder)
            {
                folderA.Add(txtFileB);
                folderA.Add(pngFileB);
            }

            Console.WriteLine(folder.ShowMyself());
            Console.ReadKey();
        }
Exemplo n.º 3
0
        public static void Read(IEnumerable <XElement> doc, int num, Root_system folder1)
        {
            string strN  = "";
            string strN1 = "";

            strN1 = "";
            for (int i = 0; i < num + 1; i++)
            {
                strN1 = strN1 + "\t";
            }
            for (int i = 0; i < num; i++)
            {
                strN = strN + "\t";
            }

            foreach (XElement el in doc)
            {
                //Console.WriteLine(strN+"{0}", el.Name);
                Console.WriteLine(strN + "{0}", el.Attribute("name").Value);
                //foreach (XAttribute attr in el.Attributes())
                //    Console.WriteLine(strN + " Attributes   {0}", attr);
                Root_system temp = null;
                if (el.Name == "folder")
                {
                    temp = new Folder();
                    temp.Load(el);

                    foreach (XElement element in el.Elements())
                    {
                        if (element.Name == "folder")
                        {
                            Console.WriteLine(strN1 + "{0}", element.Attribute("name").Value);
                            //Console.WriteLine(strN + "{0}", element.Name);
                            //foreach (XAttribute attr in element.Attributes())
                            //    Console.WriteLine(strN + " Attributes   {0}", attr);
                            Root_system temp1 = null;
                            temp1 = new Folder();
                            temp1.Load(element);

                            Read(element.Elements(), num + 2, folder1);
                            temp.Add(temp1);
                        }
                        else
                        {
                            Console.WriteLine(strN1 + "{0}", element.Attribute("name").Value);
                            Root_system temp1 = null;
                            temp1 = new composite.File();
                            temp1.Load(element);
                            temp.Add(temp1);
                        }
                    }
                }
                else
                {
                    temp = new composite.File();
                    temp.Load(el);
                }
                folder1.Add(temp);
            }
        }
Exemplo n.º 4
0
        public void CalculateState_FolderStateIsCalculatedWhenItemsAreAdded()
        {
            var folder = new Folder();

            var item1 = new Item {
                State = State.Ok
            };
            var item2 = new Item {
                State = State.Ok
            };
            var item3 = new Item {
                State = State.Ok
            };

            folder.Add(item1);
            folder.Add(item2);
            folder.Add(item3);

            Assert.AreEqual(State.Ok, folder.State);

            var item4 = new Item {
                State = State.Failed
            };

            folder.Add(item4);

            Assert.AreEqual(State.Failed, folder.State);
        }
Exemplo n.º 5
0
        public static void RefactoredVersionDemo()
        {
            AbstractFile folder1 = new Folder("EDC的资料");
            AbstractFile folder2 = new Folder("图像文件");
            AbstractFile folder3 = new Folder("文本文件");
            AbstractFile folder4 = new Folder("视频文件");

            AbstractFile image1 = new ImageFile("小龙女.jpg");
            AbstractFile image2 = new ImageFile("张无忌.gif");

            AbstractFile text1 = new TextFile("九阴真经.txt");
            AbstractFile text2 = new TextFile("葵花宝典.doc");

            AbstractFile video1 = new VideoFile("笑傲江湖.rmvb");
            AbstractFile video2 = new VideoFile("天龙八部.mp4");

            folder2.Add(image1);
            folder2.Add(image2);

            folder3.Add(text1);
            folder3.Add(text2);

            folder4.Add(video1);
            folder4.Add(video2);

            folder1.Add(folder2);
            folder1.Add(folder3);
            folder1.Add(folder4);

            //folder1.KillVirus();

            folder3.KillVirus();
        }
Exemplo n.º 6
0
        private static void CompositeModeTest()
        {
            AbstractFile folder1  = new Folder("文件夹1");
            AbstractFile folder2  = new Folder("文件夹2");
            AbstractFile fileImg1 = new ImageFile("图片文件1");
            AbstractFile fileTxt1 = new TextFile("文本文件1");

            folder2.Add(fileImg1);
            folder2.Add(fileTxt1);
            folder1.Add(folder2);
            folder1.KillVirue();
            Console.ReadKey();
        }
        private void InitializeFileStructure()
        {
            root = new Folder("root");
            foreach (var character in alpha)
            {
                var charFolder = new Folder(character.ToString());
                root.Add(charFolder);
            }

            foreach (var character in numbers)
            {
                var charFolder = new Folder(character.ToString());
                root.Add(charFolder);
            }
        }
Exemplo n.º 8
0
        private static Folder InitialiseFolders()
        {
            Folder folder = new Folder("First Folder");

            folder.Add(new Folder("Second Folder"));
            folder.Add(new Folder("Third Folder"));
            var folder2 = new Folder("Fourth Folder");

            folder2.Add(new Folder("Fifth Folder"));
            folder2.Add(new Folder("Sixth Folder"));
            folder2.Add(new Folder("Seventh Folder"));

            folder.Add(folder2);
            return(folder);
        }
Exemplo n.º 9
0
        public static void Main(string[] args)
        {
            var folder1 = new Folder();

            folder1.Add(new MyDataFile1 <string>("File1", 5, 7));
            folder1.Add(new MyDataFile1 <string>("File2", 20, 8));
            folder1.PrintLengths();
            folder1.PrintTitles();

            var folder2 = folder1.DeepCopy();

            folder2.Add(new MyDataFile1 <string>("File3", 753, 5753));
            folder2.PrintLengths();
            folder2.PrintTitles();
        }
        void CheckOverlayWithinBounds(Feature feature)
        {
            var errors = new List<string>();
            _geoArray = GeoArray.FromWellKnownText(feature.GetWellKnownText());
            OnPropertyChanged("GeoArray");
#if false
            if (_writeKML)
            {
                var kml = new KMLRoot();
                var folder = new Folder("Overlay Segment Test");
                var segments = _geoArray.Segments.ToArray();
                for (var segment = 0; segment < segments.Length; segment++)
                {
                    segments[segment].Placemark.name = string.Format("Segment {0}", segment);
                    folder.Add(segments[segment].Placemark);
                }
                kml.Document.Add(folder);
                var savePath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments), "Overlay Segment Tests", "OverlaySegmentTest.kml");
                kml.Save(savePath);
                _writeKML = false;
            }
#endif
            if (_geoArray.HasCrossingSegments && !AreCrossingSegmentsAllowed) errors.Add("Perimeter segments may not cross");
            if (_locationBoundsRectangle != null && !_locationBoundsRectangle.Contains(feature.GetShape())) errors.Add("Perimeter must be within location bounds");
            var areaStyle = errors.Count > 0 ? _errorAreaStyle : _normalAreaStyle;
            _wpfMap.EditOverlay.EditShapesLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = areaStyle;
            _wpfMap.EditOverlay.EditShapesLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            Errors = errors.Count == 0 ? string.Empty : string.Join("\n", errors);
            HasErrors = errors.Count > 0;
            if (HasErrors) Debug.WriteLine(string.Format("Errors: {0}", Errors));
        }
        public void Should_Enable_FolderItems()
        {
            var settingsStore = Substitute.For <ISettingsStore>();
            var jobScheduler  = Substitute.For <IJobScheduler>();

            var folder = new Folder();
            var item   = new Dummy {
                IsEnabled = false, State = State.Disabled
            };

            folder.Add(item);

            var command = new EnableCommand(folder);
            var handler = new EnableCommandHandler(settingsStore, jobScheduler);

            jobScheduler.Contains(item).Returns(true);

            handler.Handle(command);

            Assert.IsTrue(item.IsEnabled);
            Assert.IsTrue(folder.IsEnabled);

            settingsStore.Received().TrySave();

            jobScheduler.Received().Enable(item);
            jobScheduler.DidNotReceive().Enable(folder);
        }
Exemplo n.º 12
0
        public void RemoveTest()
        {
            //arrange
            string a = @"\test";
            string b = @"\test1";
            string c = @"\test2";
            string d = @"\test3";

            string expected = a;

            //act
            Component f1 = new Folder(a);
            Component f2 = new Folder(b);
            Component f3 = new Folder(c);
            Component f4 = new Folder(d);

            f1.Add(f2);
            f2.Add(f3);
            f3.Add(f4);
            f3.Remove(f4);
            f2.Remove(f3);
            f1.Remove(f2);
            string actual = f1.AddName("");

            //assert
            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 13
0
        public void DisplayTest()
        {
            Folder   folder1   = new Folder();
            FakeFile textFile  = new TextFile();
            FakeFile videoFile = new VideoFile();

            folder1.Add(textFile);
            folder1.Add(videoFile);
            folder1.Display();
            Assert.Equal("TextFile", folder1.Records[0]);
            Assert.Equal("VideoFile", folder1.Records[1]);

            Folder folder2 = new Folder();

            folder2.Add(folder1);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Creates a new empty Lua script in the specified project, in the specified folder.
        /// </summary>
        /// <param name="data">The solution creation data, usually derived from the user's input in a NewSolutionForm.</param>
        /// <returns>A new solution that can be loaded.</returns>
        public override Moai.Platform.Management.File Create(string name, Project project, Folder folder)
        {
            File f = null;

            // Determine where to place the file.
            if (folder == null)
            {
                // Place the file in the root of the project
                f = new File(project, project.ProjectInfo.DirectoryName, name);
                project.AddFile(f);
            }
            else
            {
                // Place the file in the specified folder
                f = new File(project, project.ProjectInfo.DirectoryName, System.IO.Path.Combine(folder.FolderInfo.Name, name));
                folder.Add(f);
            }

            // Write the contents of the data into the file.
            using (System.IO.StreamWriter writer = new System.IO.StreamWriter(f.FileInfo.FullName))
            {
                writer.WriteLine("-- An empty script file.");
                writer.WriteLine();
            }

            return(f);
        }
Exemplo n.º 15
0
        /// <summary>
        /// Creates a new empty folder in the specified project, in the specified folder.
        /// </summary>
        /// <param name="data">The solution creation data, usually derived from the user's input in a NewSolutionForm.</param>
        /// <returns>A new solution that can be loaded.</returns>
        public override Moai.Platform.Management.File Create(string name, Project project, Folder folder)
        {
            Folder ff = null;

            // Determine where to place the folder.
            if (folder == null)
            {
                // Place the folder in the root of the project
                ff = new Folder(project, project.ProjectInfo.DirectoryName, name);
                project.AddFile(ff);
            }
            else
            {
                // Place the folder in the specified folder
                ff = new Folder(project, project.ProjectInfo.DirectoryName, Path.Combine(folder.FolderInfo.Name, name));
                folder.Add(ff);
            }

            // Create the new folder on disk.
            if (!Directory.Exists(ff.FolderInfo.FullName))
            {
                Directory.CreateDirectory(ff.FolderInfo.FullName);
            }

            return(ff);
        }
Exemplo n.º 16
0
        /// <summary>
        /// Creates a new empty Lua script in the specified project, in the specified folder.
        /// </summary>
        /// <param name="data">The solution creation data, usually derived from the user's input in a NewSolutionForm.</param>
        /// <returns>A new solution that can be loaded.</returns>
        public override Moai.Platform.Management.File Create(string name, Project project, Folder folder)
        {
            File f = null;

            // Determine where to place the file.
            if (folder == null)
            {
                // Place the file in the root of the project
                f = new File(project, project.ProjectInfo.DirectoryName, name);
                project.AddFile(f);
            }
            else
            {
                // Place the file in the specified folder
                f = new File(project, project.ProjectInfo.DirectoryName, System.IO.Path.Combine(folder.FolderInfo.Name, name));
                folder.Add(f);
            }

            // Write the contents of the data into the file.
            using (System.IO.StreamWriter writer = new System.IO.StreamWriter(f.FileInfo.FullName))
            {
                writer.WriteLine("-- An empty script file.");
                writer.WriteLine();
            }

            return f;
        }
Exemplo n.º 17
0
        public async Task JenkinsView_Should_NOT_DuplicateJobs_When_Refreshing()
        {
            var logger = Substitute.For <ILogger>();

            var folder = new Folder();

            var jenkinsView = new JenkinsView_v1
            {
                Name            = "Jenkins View",
                Interval        = 0,
                URL             = @"https://jenkins.mono-project.com/view/Urho/",
                IgnoreSslErrors = true
            };

            folder.Add(jenkinsView);

            var handler = new JenkinsViewStatus(logger);
            var request = HealthCheckRequest.Create(jenkinsView);

            await handler.Handle(request, CancellationToken.None);

            Assert.IsNotNull(jenkinsView.Items);
            Assert.IsTrue(jenkinsView.Items.Any());

            var count = jenkinsView.Items.Count;

            await handler.Handle(request, CancellationToken.None);

            Assert.AreEqual(count, jenkinsView.Items.Count);
        }
Exemplo n.º 18
0
        public static void DownloadFile(string path)
        {
            try
            {
                Settings.RelativePath = path = path.Replace(Devider, Path.DirectorySeparatorChar);

                var last = path.Split(Path.DirectorySeparatorChar).Last();

                Settings.RelativePath = path.Substring(0, path.Length - last.Length);

                var folder = new Folder("");
                var file   = new File(last);
                folder.Add(file);

                var fileName = file.Name;
                var data     = file.GetData();

                HttpContext.Current.Response.AddHeader("Content-disposition", "attachment;filename=" + fileName);
                HttpContext.Current.Response.ContentType = "application/octet-stream";
                HttpContext.Current.Response.BinaryWrite(data);

                HttpContext.Current.Response.Flush();
                HttpContext.Current.Response.Close();
                HttpContext.Current.Response.End();
            }
            catch (Exception ex)
            {
                // ignored
            }
        }
        /// <summary>
        ///     获取当前目录下的文件夹递归文件编码
        /// </summary>
        private void InspectFaceFolderEncoding()
        {
            foreach (var temp in FaceFolder.GetDirectories())
            {
                var folder = new EncodingScrutatorFolder(temp, InspectFileWhiteListSetting, IncludeFileSetting)
                {
                    //IncludeFileSetting = IncludeFileSetting,
                    //InspectFileWhiteListSetting = InspectFileWhiteListSetting,
                    SitpulationEncodingSetting = SitpulationEncodingSetting,
                    _includeRegexFile          = _includeRegexFile,
                    //Parent = FaceFolder,
                    Parent   = this,
                    Progress = Progress
                };

                Folder.Add(folder);
                //不包含
                if (InspectFileWhiteListSetting.FolderWhiteList.Any(t => String.Equals(t, temp.Name)))
                {
                    folder.Ignore = true;
                }
                if (!folder.Ignore)
                {
                    //递归
                    folder.InspectFolderEncoding();
                }
            }
        }
Exemplo n.º 20
0
        public static string GetChildren(int operation, bool isFolder, string path, string option)
        {
            Settings.RelativePath = path = path.Replace(Devider, Path.DirectorySeparatorChar);

            var last = path.Split(Path.DirectorySeparatorChar).Last();

            Settings.RelativePath = path.Substring(0, path.Length - last.Length);
            var folder = new Folder(last);
            var file   = isFolder ? null : new File(last);

            var element = isFolder ? (IElement)folder : (IElement)file;

            switch (operation)
            {
            case 1:     // Delete
                element.Delete();
                break;

            case 2:     // Rename
                if (!string.IsNullOrWhiteSpace(option))
                {
                    element.Rename(option);
                }
                break;

            case 3:     // Copy
                var parent   = new Folder("");
                var original = parent.GetChildren().First(c => c.Name == last);
                ((ICopiable)original).Copy(parent);
                break;

            case 4:     // New
                folder.Add(new Folder(option));
                break;

            case 6:
                break;

            default:
                // Just refresh
                break;
            }

            var size = isFolder ? folder.GetSize() : file.GetSize();

            var elements = new
            {
                Meta  = size,
                Items = folder.GetChildren().Select(e => new
                {
                    e.Id,
                    e.Name,
                    IsFolder = e is IContainer,
                })
            };

            return(JsonConvert.SerializeObject(elements));
        }
Exemplo n.º 21
0
        /// <summary>
        /// 访问者
        /// </summary>
        static void Visitor()
        {
            Console.WriteLine($"访问者模式{Environment.NewLine}-------------------------------------------");

            //创建目录结构 Start
            IFile folderA = new Folder("FolderA");

            folderA.Add(new Txt("TxtA"));
            folderA.Add(new Png("PngA"));

            IFile folderB = new Folder("FolderB");

            folderB.Add(new Txt("TxtB"));
            folderB.Add(new Png("PngB"));

            IFile folderC = new Folder("FolderC");

            folderC.Add(new Txt("TxtC"));
            folderC.Add(new Png("PngC"));

            folderB.Add(folderC);
            IFile folder = new Folder("Folder");

            folder.Add(folderA);
            folder.Add(folderB);
            //创建目录结构 End

            FolderSumVisitor folderSumVisitor = new FolderSumVisitor();

            folder.Accept(folderSumVisitor);
            Console.WriteLine($"共有文件夹{folderSumVisitor.Sum}个");

            PngSumVisitor pngSumVisitor = new PngSumVisitor();

            folder.Accept(pngSumVisitor);
            Console.WriteLine($"共有png文件{pngSumVisitor.Sum}个");

            TxtNameVisitor txtNameVisitor = new TxtNameVisitor();

            folder.Accept(txtNameVisitor);
            Console.WriteLine($"{Environment.NewLine}所有的txt文件名如下:");
            txtNameVisitor.NameList.ForEach(t => Console.WriteLine(t));

            Console.ReadKey();
        }
Exemplo n.º 22
0
 public void ProjectIsChangedAfterAddingDataItemInAFolder()
 {
     var project = CreateEmptyProject();
     var folder = new Folder();
     project.RootFolder.Items.Add(folder);
     project.IsChanged = false;
     folder.Add(new DataItem());
     Assert.IsTrue(project.IsChanged);
 }
Exemplo n.º 23
0
        public void Should_Aggregate_State_By_Priority()
        {
            var folder = new Folder();

            var item1 = new Item();
            var item2 = new Item();
            var item3 = new Item();

            folder.Add(item1);
            folder.Add(item2);
            folder.Add(item3);

            item1.State = State.Ok;
            item2.State = State.Failed;
            item3.State = State.Running;

            Assert.AreEqual(State.Running, folder.State);
        }
Exemplo n.º 24
0
        public void CalculateState_FolderStateIsOkWhenAllItemsAreOk()
        {
            var folder = new Folder();

            var item1 = new Item();
            var item2 = new Item();
            var item3 = new Item();

            folder.Add(item1);
            folder.Add(item2);
            folder.Add(item3);

            item1.State = State.Ok;
            item2.State = State.Ok;
            item3.State = State.Ok;

            Assert.AreEqual(State.Ok, folder.State);
        }
Exemplo n.º 25
0
        public void Assert_That_State_Bubbles_Up_By_Priority()
        {
            var grandParent = new Folder();
            var parent      = new Folder();
            var widget1     = new WidgetMock();
            var widget2     = new WidgetMock();

            grandParent.Add(parent);
            parent.Add(widget1);
            parent.Add(widget2);

            Assert.AreEqual(State.None, parent.State);
            Assert.AreEqual(State.None, grandParent.State);

            widget1.State = State.Ok;
            widget2.State = State.None;

            Assert.AreEqual(State.Ok, widget1.State);
            Assert.AreEqual(State.None, widget2.State);
            Assert.AreEqual(State.Ok, parent.State);
            Assert.AreEqual(State.Ok, grandParent.State);
            Assert.AreEqual(0, grandParent.Count);

            widget2.State = State.Error;

            Assert.AreEqual(State.Ok, widget1.State);
            Assert.AreEqual(State.Error, widget2.State);
            Assert.AreEqual(State.Error, parent.State);
            Assert.AreEqual(State.Error, grandParent.State);
            Assert.AreEqual(1, grandParent.Count);

            widget1.State = State.Error;

            Assert.AreEqual(2, grandParent.Count);

            widget1.State = State.Ok;
            widget2.State = State.None;

            Assert.AreEqual(State.Ok, widget1.State);
            Assert.AreEqual(State.None, widget2.State);
            Assert.AreEqual(State.Ok, parent.State);
            Assert.AreEqual(State.Ok, grandParent.State);
            Assert.AreEqual(0, grandParent.Count);
        }
Exemplo n.º 26
0
        static void Main(string[] args)
        {
            var         readMeFile      = new File("readme.txt", 130);
            var         instructionsDoc = new File("instructions.doc", 3200);
            var         fileGit         = new File("file.git", 50);
            List <File> files           = new List <File>()
            {
                readMeFile, instructionsDoc, fileGit
            };

            var folderVisualStudio = new Folder("ProjectFolder");

            folderVisualStudio.Add(new File("app.config", 215));
            folderVisualStudio.Add(new File("Project1.csproj", 15));
            folderVisualStudio.Add(new File("Program.cs", 1600));

            var folderSolution = new Folder("Properties");

            folderSolution.Add(new File("AssemblyInfo.cs", 56));

            int totalSizeInKB = 0;

            foreach (var file in files)
            {
                totalSizeInKB += file.SizeInKB;
                file.Display(0);
            }

            Console.WriteLine($" + {folderVisualStudio.Name}");
            foreach (var file in folderVisualStudio.Files)
            {
                totalSizeInKB += file.SizeInKB;
                file.Display(1);
            }

            Console.WriteLine($" + {folderSolution.Name}");
            foreach (var file in folderSolution.Files)
            {
                totalSizeInKB += file.SizeInKB;
                file.Display(1);
            }

            Console.WriteLine($"Total size: {totalSizeInKB} KB");
        }
Exemplo n.º 27
0
        private KMLRoot CreateKmlFeat()
        {
            KMLRoot kml  = new KMLRoot();
            Folder  fldr = new Folder("Test Folder");

            fldr.Add(new Folder("Sub Folder"));

            GroundOverlay g = new GroundOverlay();

            g.altitude     = 100;
            g.altitudeMode = AltitudeMode.relativeToGround;
            g.color        = Color.Blue;
            g.description  = "Cool overlay";

            fldr.Add(g);
            kml.Feature = fldr;

            return(kml);
        }
Exemplo n.º 28
0
        public void ProjectIsChangedAfterAddingDataItemInAFolder()
        {
            var project = CreateEmptyProject();
            var folder  = new Folder();

            project.RootFolder.Items.Add(folder);
            project.IsChanged = false;
            folder.Add(new DataItem());
            Assert.IsTrue(project.IsChanged);
        }
Exemplo n.º 29
0
        public void Duplicate_AddsNewItemToParent()
        {
            var folder = new Folder();
            var item   = new Item();

            folder.Add(item);

            var clone = item.Duplicate();

            item.Parent.Items.Contains(clone);
        }
Exemplo n.º 30
0
        public void State_Should_Be_Failed_When_OneOrMoreItemsFailed()
        {
            State.SetMetadata(Theme.Default.Metadata); //set states priority

            var folder = new Folder();

            var item1 = new Item();
            var item2 = new Item();
            var item3 = new Item();

            folder.Add(item1);
            folder.Add(item2);
            folder.Add(item3);

            item1.State = State.Ok;
            item2.State = State.Failed;
            item3.State = State.Ok;

            Assert.AreEqual(State.Failed, folder.State);
        }
Exemplo n.º 31
0
        public void Should_Aggregate_State_When_Moving_Items()
        {
            var folder1 = new Folder();
            var folder2 = new Folder();

            var item1 = new Item();
            var item2 = new Item();

            folder1.Add(item1);
            folder1.Add(item2);

            item1.State = State.Ok;
            item2.State = State.Failed;

            Assert.AreSame(State.Failed, folder1.State);

            item2.MoveTo(folder2);

            Assert.AreSame(State.Ok, folder1.State);
        }
Exemplo n.º 32
0
        public void AddDataItemImplicitly()
        {
            var folder = new Folder();

            var value = "test";

            folder.Add(value);

            Assert.AreEqual(1, folder.Items.Count);
            Assert.AreEqual(typeof(string), folder.DataItems.FirstOrDefault().ValueType);
            Assert.AreEqual(value, folder.DataItems.FirstOrDefault().Value);
        }
Exemplo n.º 33
0
    static Folder Traverse(string root)
    {
        var folder = new Folder(root);

        foreach (string file in Directory.GetFiles(root))
            folder.Add(new File(file, new FileInfo(file).Length));

        foreach (string directory in Directory.GetDirectories(root))
            folder.AddFolder(Traverse(directory));

        return folder;
    }
Exemplo n.º 34
0
        public void AddDataItemImplicitly()
        {
            var folder = new Folder();

            var value = "test";

            folder.Add(value);

            Assert.AreEqual(1, folder.Items.Count);
            Assert.AreEqual(typeof(string), folder.DataItems.FirstOrDefault().ValueType);
            Assert.AreEqual(value, folder.DataItems.FirstOrDefault().Value);
        }
Exemplo n.º 35
0
        public void State_Should_Be_None_When_No_Items()
        {
            var folder1 = new Folder();
            var folder2 = new Folder();

            var item1 = new Item();
            var item2 = new Item();

            folder1.Add(item1);
            folder1.Add(item2);

            item1.State = State.Ok;
            item2.State = State.Failed;

            Assert.AreSame(State.Failed, folder1.State);

            item1.MoveTo(folder2);
            item2.MoveTo(folder2);

            Assert.AreSame(State.None, folder1.State);
        }
Exemplo n.º 36
0
        public static void Run()
        {
            Folder dir1 = new Folder("dir1"),
                      dir2 = new Folder("dir2"),
                      dir3 = new Folder("dir3");

            File file1 = new File("file1"),
                file2 = new File("file2"),
                file3 = new File("file3"),
                file4 = new File("file4"),
                file5 = new File("file5");

            dir1.Add(file1);
            dir1.Add(dir2);
            dir2.Add(file3);
            dir2.Add(file4);
            dir2.Add(dir3);
            dir3.Add(file5);
            dir1.Add(file2);

            dir1.ls();
        }
Exemplo n.º 37
0
        /// <summary>
        /// Creates a new empty folder in the specified project, in the specified folder.
        /// </summary>
        /// <param name="data">The solution creation data, usually derived from the user's input in a NewSolutionForm.</param>
        /// <returns>A new solution that can be loaded.</returns>
        public override Moai.Platform.Management.File Create(string name, Project project, Folder folder)
        {
            Folder ff = null;

            // Determine where to place the folder.
            if (folder == null)
            {
                // Place the folder in the root of the project
                ff = new Folder(project, project.ProjectInfo.DirectoryName, name);
                project.AddFile(ff);
            }
            else
            {
                // Place the folder in the specified folder
                ff = new Folder(project, project.ProjectInfo.DirectoryName, Path.Combine(folder.FolderInfo.Name, name));
                folder.Add(ff);
            }

            // Create the new folder on disk.
            if (!Directory.Exists(ff.FolderInfo.FullName))
                Directory.CreateDirectory(ff.FolderInfo.FullName);

            return ff;
        }
Exemplo n.º 38
0
        public void CloneProject()
        {
            Project p = new Project();
            Folder f = new Folder();
            Folder f2 = new Folder();
            f.Add(f2);
            p.RootFolder.Items.Add(f);

            Project p2 = new Project();
            p2.RootFolder.Items.Add((Folder) f.DeepClone());
            Assert.AreEqual(p2.RootFolder.Items.Count, 1);
            Assert.AreEqual(p2.RootFolder.Folders.FirstOrDefault().Items.Count(), 1);
        }