Beispiel #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);
            }
Beispiel #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);
            }
Beispiel #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);
            }
Beispiel #4
0
            public void ReturnsNullWhenPathInfoIsWhiteSpace()
            {
                var root = new PublicFolder();

                root.FilePathGetter(" ").ShouldBeNull();
            }
Beispiel #5
0
            public void ReturnsNullWhenPathInfoIsEmptyString()
            {
                var root = new PublicFolder();

                root.FilePathGetter(string.Empty).ShouldBeNull();
            }
Beispiel #6
0
            public void ReturnsNullWhenPathInfoIsNull()
            {
                var root = new PublicFolder();

                root.FilePathGetter(null).ShouldBeNull();
            }
Beispiel #7
0
            public void ReturnsNullWhenPathDoesNotExist()
            {
                var root = new PublicFolder();

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