Пример #1
0
            public void ReturnsExistingFilePath()
            {
                var root = new PublicFolder();
                var file = GenerateUniqueString();

                var filepath = Path.Combine(root.FolderPath, file);

                using (var sw = File.CreateText(filepath)) { sw.WriteLine("Hello"); }

                root.FilePathGetter(file).ShouldBe(filepath);
                root.FilePathGetter($"/{file}").ShouldBe(filepath);

                File.Delete(filepath);
            }
Пример #2
0
            public void ReturnsExistingDefaultFilePath()
            {
                var root   = new PublicFolder();
                var folder = GenerateUniqueString();

                var folderpath = Directory.CreateDirectory(Path.Combine(root.FolderPath, folder)).FullName;

                if (!Directory.Exists(folderpath))
                {
                    throw new Exception("Folder to test did not get created");
                }

                var filepath = Path.Combine(folderpath, root.DefaultFileName);

                using (var sw = File.CreateText(filepath)) { sw.WriteLine("Hello"); }

                root.FilePathGetter(folder).ShouldBe(filepath);
                root.FilePathGetter($"/{folder}").ShouldBe(filepath);

                CleanUp(folderpath);
            }
Пример #3
0
            public void ReturnsNullWhenDefaultFileDoesNotExist()
            {
                var folder = GenerateUniqueString();
                var root   = new PublicFolder();

                var folderpath = Directory.CreateDirectory(Path.Combine(root.FolderPath, folder)).FullName;

                if (!Directory.Exists(folderpath))
                {
                    throw new Exception("Folder to test did not get created");
                }

                root.FilePathGetter($"/{folder}").ShouldBeNull();

                CleanUp(folderpath);
            }
Пример #4
0
            public void ReturnsNullWhenPathInfoIsWhiteSpace()
            {
                var root = new PublicFolder();

                root.FilePathGetter(" ").ShouldBeNull();
            }
Пример #5
0
            public void ReturnsNullWhenPathInfoIsEmptyString()
            {
                var root = new PublicFolder();

                root.FilePathGetter(string.Empty).ShouldBeNull();
            }
Пример #6
0
            public void ReturnsNullWhenPathInfoIsNull()
            {
                var root = new PublicFolder();

                root.FilePathGetter(null).ShouldBeNull();
            }
Пример #7
0
            public void ReturnsNullWhenPathDoesNotExist()
            {
                var root = new PublicFolder();

                root.FilePathGetter("/nope.txt").ShouldBeNull();
            }