Ejemplo n.º 1
0
        public void EqualsTest()
        {
            PathSpec left      = new DepotPath("//depot/main/test.txt");
            PathSpec rightpos  = new DepotPath("//depot/main/test.txt");
            PathSpec rightneg1 = new DepotPath("//depot/main/empty.bmp");
            PathSpec rightneg2 = new ClientPath("//depot/main/test/txt");
            PathSpec rightnull = null;

            Assert.IsTrue(left.Equals(rightpos));
            Assert.IsFalse(left.Equals(rightneg1));
            Assert.IsFalse(left.Equals(rightneg2));
            Assert.IsFalse(left.Equals(rightnull));

            left      = new ClientPath("//user_workspace/main/test.txt");
            rightpos  = new ClientPath("//user_workspace/main/test.txt");
            rightneg1 = new ClientPath("//user_workspace/main/empty.bmp");
            rightneg2 = new DepotPath("//user_workspace/main/test.txt");
            rightnull = null;

            Assert.IsTrue(left.Equals(rightpos));
            Assert.IsFalse(left.Equals(rightneg1));
            Assert.IsFalse(left.Equals(rightneg2));
            Assert.IsFalse(left.Equals(rightnull));

            left      = new LocalPath(@"C:\workspace_root\test.txt");
            rightpos  = new LocalPath(@"C:\workspace_root\test.txt");
            rightneg1 = new LocalPath(@"C:\workspace_root\empty.bmp");
            rightneg2 = new DepotPath(@"C:\workspace_root\test.txt");
            rightnull = null;

            Assert.IsTrue(left.Equals(rightpos));
            Assert.IsFalse(left.Equals(rightneg1));
            Assert.IsFalse(left.Equals(rightneg2));
            Assert.IsFalse(left.Equals(rightnull));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// This function assumes that the files list is initialized. It also performs no cleanup
        /// of duplicates in case of incorrect of consequtive use.
        /// </summary>
        private void AddRealFiles()
        {
            if (LocalPath == null || LocalPath.Equals(EmptyLocalPath))
            {
                return;
            }

            string[] filePaths = Directory.GetFiles(LocalPath);

            if (filePaths == null || filePaths.Length == 0)
            {
                return;
            }

            if (Files == null)
            {
                files = new List <FileContents>();
            }

            foreach (string path in filePaths)
            {
                FileContents fc = new FileContents(path);
                Files.Add(fc);
            }
        }
Ejemplo n.º 3
0
 public bool Equals(IPackageMetadata other)
 {
     return(Id.Equals(other.Id) &&
            Version.Equals(other.Version) &&
            LocalPath.Equals(other.LocalPath) &&
            AreTargetFrameworksEqual(TargetFrameworks, other.TargetFrameworks) &&
            AreAssembliesEqual(Assemblies, other.Assemblies));
 }
Ejemplo n.º 4
0
        public DirContents(DirModel d, bool addRealFiles = false, bool addRemoteFiles = true)
            : this(d.Name, d.Description, d.Path, null, addRealFiles)
        {
            if ((addRealFiles && LocalPath != null && !LocalPath.Equals(EmptyLocalPath)) ||
                (addRemoteFiles && d.Files != null && d.Files.Count > 0))
            {
                this.files = new List <FileContents>();
            }

            if (addRemoteFiles)
            {
                AddRemoteFiles(d.Files);
            }
            if (addRealFiles)
            {
                AddRealFiles();
            }

            if (addRemoteFiles && addRealFiles)
            {
                RemoveDuplicateFiles();
            }
        }