コード例 #1
0
        private static FileItem GetNewFolder(bool isNull, int PerantId)
        {
            if (isNull)
                return null;
            FileType t = new FileType
            {
                ID = 1,
                ImageUrl = "folder.png",
                Extension = null,
                Description = "Folder"
            };

            FileItem fi = new FileItem
            {
                FileName = "folder" + item,
                ID = item,
                IsFolder = true,
                OwnerId = 1,
                PerantID = PerantId,
                Rate = 0,
                SubItems = new List<FileItem>(),
                Type = t
            };

            item++;
            return fi;
        }
コード例 #2
0
        private static FileItem GetNewFile(bool isNull, int PerantId)
        {
            if (isNull)
                return null;
            FileType t = new FileType
            {
                ID = 2,
                ImageUrl = "doc.png",
                Extension = "doc",
                Description = "Word 2003 file"
            };

            FileItem fi = new FileItem
            {
                FileName = "file" + item + ".doc",
                ID = item,
                IsFolder = false,
                OwnerId = 1,
                PerantID = PerantId,
                Rate = 0,
                SubItems = new List<FileItem>(),
                Type = t
            };

            item++;
            return fi;
        }
コード例 #3
0
        public void TestRootSubItemsIsNull()
        {
            FileType t = new FileType
            {
                ID = 1,
                ImageUrl = "folder.png",
                Extension = null,
                Description = "Folder"
            };

            FileItem fi = new FileItem
            {
                FileName = "Root",
                ID = 0,
                IsFolder = true,
                OwnerId = 1,
                PerantID = -1,
                Rate = 0,
                SubItems = null,
                Type = t
            };
            Assert.Throws<NullReferenceException>(() => { new FileStructure(null); }, "Root can't be null");
        }
コード例 #4
0
        /*
            root
                -folder0
                    -folder1
                        -folder2
                            -folder3
                                -file0
                    -folder4
                        -folder5
                        -file1
                    -folder6
                        file2
                        file3
                        file4
                -folder7
                    folder8
                        file5
                        file6
                    file7
                -folder9
                    file8
                    file9
                    file10
                -file11
                -file12
         */
        private static void CreateNewStaticStructure()
        {
            item = 1;
            FileType t = new FileType
            {
                ID = 1,
                ImageUrl = "folder.png",
                Extension = null,
                Description = "Folder"
            };

            FileItem fi = new FileItem
            {
                FileName = "Root",
                ID = 0,
                IsFolder = true,
                OwnerId = 1,
                PerantID = -1,
                Rate = 0,
                SubItems = new List<FileItem>(),
                Type = t
            };
            List<FileItem> folders = new List<FileItem>();
            for (int i = 0; i < 10; i++)
            {
                folders.Add(GetNewFolder(false, -1));
            }
            List<FileItem> files = new List<FileItem>();
            for (int i = 0; i < 13; i++)
            {
                files.Add(GetNewFile(false, -1));
            }
            //root
            AddToFolder(fi, folders[0]);
                AddToFolder(folders[0], folders[1]);
                    AddToFolder(folders[1], folders[2]);
                        AddToFolder(folders[2], folders[3]);
                            AddToFolder(folders[3], files[0]);
                AddToFolder(fi, folders[4]);
                    AddToFolder(folders[4], folders[5]);
                    AddToFolder(folders[4], files[1]);
                AddToFolder(fi, folders[6]);
                    AddToFolder(folders[6], files[2]);
                    AddToFolder(folders[6], files[3]);
                    AddToFolder(folders[6], files[4]);
                AddToFolder(fi, folders[7]);
                    AddToFolder(folders[7], folders[8]);
                        AddToFolder(folders[8], files[5]);
                        AddToFolder(folders[8], files[6]);
                    AddToFolder(folders[7], files[7]);
                AddToFolder(fi, folders[9]);
                    AddToFolder(folders[9], files[8]);
                    AddToFolder(folders[9], files[9]);
                    AddToFolder(folders[9], files[10]);
                AddToFolder(fi, files[11]);
                AddToFolder(fi, files[12]);
            fs = new FileStructure(fi);
        }
コード例 #5
0
        public void TestRootIsValid()
        {
            FileType t = new FileType
            {
                ID = 1,
                ImageUrl = "folder.png",
                Extension = null,
                Description = "Folder"
            };

            FileItem fi = new FileItem
            {
                FileName = "Root",
                ID = 0,
                IsFolder = true,
                OwnerId = 1,
                PerantID = -1,
                Rate = 0,
                SubItems = new List<FileItem>(),
                Type = t
            };
            FileStructure fs = new FileStructure(fi);
            Assert.NotNull(fs.RootFolder);
        }