コード例 #1
0
 private static void AssertDirectoryIsCorrectlyInitialized(Directory directory)
 {
     Assert.AreEqual(DirectoryName, directory.Name);
     Assert.AreEqual(DirectoryName, directory.FullName);
     Assert.AreEqual(DirectoryLocation, directory.Path);
     Assert.AreEqual(DirectoryFullPath, directory.FullPath);
     Assert.AreEqual(DirectoryFullPath, directory.ChildrenPath);
     Assert.AreEqual(DefaultInnerFilesCount, directory.InnerFiles.Count);
 }
        public void CheckNameOrGetValidDirectoryThatNotExists()
        {
            TestWithShims(() =>
            {
                var directory = new Directory("Test", @"C:\");

                ShimDirectory.ExistsString = s => false;
                var result = SetupClass().CheckNameOrGetValid(directory);

                Assert.AreEqual(directory.Name, result);
            });
        }
コード例 #3
0
        public void CreateInstanceWithNameAndPath()
        {
            Test(resolver =>
            {
                var directory = new Directory("TestDirectory", "C:\\");

                Assert.AreEqual("TestDirectory", directory.Name);
                Assert.AreEqual("TestDirectory", directory.FullName);
                Assert.AreEqual("C:\\", directory.Path);
                Assert.AreEqual("C:\\TestDirectory", directory.FullPath);
                Assert.AreEqual("C:\\TestDirectory", directory.ChildrenPath);
                Assert.AreEqual(0, directory.InnerFiles.Count);
            });
        }
コード例 #4
0
        /// <summary>
        ///     Creates the specified directory.
        /// </summary>
        /// <param name="directory"> The directory. </param>
        public IDirectory Create(IDirectory directory)
        {
            Check.IfIsNull(directory).Throw<ArgumentNullException>(() => directory);
            Check.IfIsNullOrWhiteSpace(directory.Name).Throw<ArgumentException>(() => directory.Name);
            Check.IfIsNullOrWhiteSpace(directory.Path).Throw<ArgumentException>(() => directory.Path);

            var name = fileNameDuplicateChecker.CheckNameOrGetValid(directory);

            var createdDirectory = new Directory(name, directory.Path);

            DirectoryFacade.CreateDirectory(createdDirectory.FullPath);

            return createdDirectory;
        }
        public void CheckNameOrGetValidDirectory()
        {
            TestWithShims(() =>
            {
                var directory = new Directory("Test", @"C:\");

                ShimDirectory.ExistsString = s =>
                {
                    if (s == "C:\\Test")
                    {
                        return true;
                    }
                    return s == "C:\\Test (1)";
                };

                var result = SetupClass().CheckNameOrGetValid(directory);

                Assert.AreEqual("Test (2)", result);
            });
        }
コード例 #6
0
        /// <summary>
        ///     Creates the specified file container.
        /// </summary>
        /// <param name="parentDirectory">The parent directory where the new folder is going to be created.</param>
        /// <returns></returns>
        public IDirectory CreateWithDefaultName(IFileContainer parentDirectory)
        {
            Check.IfIsNull(parentDirectory).Throw<ArgumentNullException>(() => parentDirectory);

            var directory = new Directory(directoryInfo.DefaultFileName, parentDirectory.ChildrenPath);

            return Create(directory);
        }