예제 #1
0
        /// <summary>
        /// Checks if the collection already contains the given dependency.
        /// </summary>
        /// <param name="dependency">Dependency to check.</param>
        /// <returns></returns>
        public bool Contains(FileDependency dependency)
        {
            foreach (FileDependency fd in InnerList)
            {
                if (String.Compare(fd.FileName, dependency.FileName, true) == 0)
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #2
0
        //-----------------------------------------------------------------------------------------------

        /// <summary>
        /// Adds the given FileDependency object to this collection
        /// </summary>
        /// <param name="dependency">file dependency to add</param>
        public void Add(FileDependency dependency)
        {
            if (dependency == null)
            {
                throw new InvalidOperationException("The FileDependency Collection does not accept null values.", null);
            }
            if (Contains(dependency))
            {
                throw new InvalidOperationException("A file dependency with the same name already exists.", null);
            }

            InnerList.Add(dependency);
        }
        //-----------------------------------------------------------------------------------------------
        /// <summary>
        /// Adds the given FileDependency object to this collection
        /// </summary>
        /// <param name="dependency">file dependency to add</param>
        public void Add(FileDependency dependency)
        {
            if (dependency == null)
            {
                throw new InvalidOperationException("The FileDependency Collection does not accept null values.", null);
            }
            if (Contains(dependency))
            {
                throw new InvalidOperationException("A file dependency with the same name already exists.", null);
            }

            InnerList.Add(dependency);
        }
        /// <summary>
        /// Adds the given FileDependency list to this collection
        /// </summary>
        /// <param name="dependencyList">file dependencies to add</param>
        public void Add(FileDependency[] dependencyList)
        {
            if (dependencyList == null)
            {
                throw new InvalidOperationException("The FileDependency Collection does not accept null values.", null);
            }

            foreach (FileDependency fileDep in dependencyList)
            {
                if (fileDep == null)
                {
                    throw new InvalidOperationException("The FileDependency Collection does not accept null values.", null);
                }

                if (Contains(fileDep))
                {
                    throw new InvalidOperationException("A file dependency with the same name already exists.", null);
                }

                InnerList.Add(fileDep);
            }
        }
        public void AddListTestDuplicatedValue()
        {
            FileDependencyCollection collection = new FileDependencyCollection();
            FileDependency[] fdList = new FileDependency[1];
            FileDependency fd1 = new FileDependencyTestFiller(@"c:\test1.txt");
            fdList[0] = new FileDependencyTestFiller(@"c:\test1.txt");

            collection.Add(fd1);

            try
            {
                collection.Add(fdList);

                Assert.IsTrue(false, "Adding a duplicate value to the collection should throw an InvalidOretationException.");
            }
            catch (InvalidOperationException e)
            {
                Console.Write(e);
                // pass if we get here
                Assert.IsTrue(true);
            }
        }
        /// <summary>
        /// Checks if the collection already contains the given dependency.
        /// </summary>
        /// <param name="dependency">Dependency to check.</param>
        /// <returns></returns>
        public bool Contains(FileDependency dependency)
        {
            foreach (FileDependency fd in InnerList)
            {
                if (String.Compare(fd.FileName, dependency.FileName, true) == 0)
                {
                    return true;
                }
            }

            return false;
        }
        public void AddListTestNullValueInList()
        {
            FileDependencyCollection collection = new FileDependencyCollection();
            FileDependency[] fdList = new FileDependency[1];
            fdList[0] = null;

            try
            {
                collection.Add(fdList);

                Assert.IsTrue(false, "Adding a null value to the collection should throw an InvalidOretationException.");
            }
            catch (InvalidOperationException e)
            {
                Console.Write(e);
                // pass if we get here
                Assert.IsTrue(true);
            }
        }
        public void AddListTestSimpleScenario()
        {
            FileDependencyCollection collection = new FileDependencyCollection();
            FileDependency[] fdList = new FileDependency[2];
            FileDependency fd1 = new FileDependencyTestFiller(@"c:\test1.txt");
            FileDependency fd2 = new FileDependencyTestFiller(@"c:\test2.txt");
            fdList[0] = fd1;
            fdList[1] = fd2;

            collection.Add(fdList);

            Assert.IsTrue(collection.Contains(fd1));
            Assert.IsTrue(collection.Contains(fd2));
        }