|
1 |
| -using NUnit.Framework; |
| 1 | +using System; |
| 2 | +using NUnit.Framework; |
2 | 3 | using SqlCollaborative.Azure.DataPipelineTools.DataLake;
|
3 | 4 |
|
4 | 5 | namespace DataPipelineTools.Tests.DataLake
|
@@ -50,9 +51,19 @@ public void CheckPathAsync_Given_ValidFilePath_Should_ReturnValidPath()
|
50 | 51 | }
|
51 | 52 |
|
52 | 53 | [Test]
|
53 |
| - public void CheckPathAsync_Given_FilePathWithIncorrectCase_Should_ReturnCorrectedFilePath() |
| 54 | + public void CheckPathAsync_Given_FilePathWithIncorrectFilenameCase_Should_ReturnCorrectedFilePath() |
54 | 55 | {
|
55 |
| - var testPath = "raw/DATABASE/jan/extract_1.csv"; |
| 56 | + var testPath = "raw/database/jan/eXTRact_1.csv"; |
| 57 | + var resultPath = Sut.CheckPathAsync(testPath, false).Result; |
| 58 | + |
| 59 | + Assert.That("raw/database/jan/extract_1.csv", Is.EqualTo(resultPath)); |
| 60 | + } |
| 61 | + |
| 62 | + |
| 63 | + [Test] |
| 64 | + public void CheckPathAsync_Given_FilePathWithIncorrectDirectoryCase_Should_ReturnCorrectedFilePath() |
| 65 | + { |
| 66 | + var testPath = "raw/database/JAN/extract_1.csv"; |
56 | 67 | var resultPath = Sut.CheckPathAsync(testPath, false).Result;
|
57 | 68 |
|
58 | 69 | Assert.That("raw/database/jan/extract_1.csv", Is.EqualTo(resultPath));
|
@@ -101,15 +112,69 @@ public void CheckPathAsync_Given_DirectoryPathWithIncorrectCase_When_MatchesMult
|
101 | 112 |
|
102 | 113 | Assert.CatchAsync(() => Sut.CheckPathAsync(testPath, true));
|
103 | 114 | }
|
| 115 | + |
| 116 | + [Test] |
| 117 | + public void CheckPathAsync_Given_NullPath_Should_Return_EmptyString() |
| 118 | + { |
| 119 | + string testPath = null; |
| 120 | + var resultPath = Sut.CheckPathAsync(testPath, true).Result; |
| 121 | + |
| 122 | + Assert.That(string.Empty, Is.EqualTo(resultPath)); |
| 123 | + } |
104 | 124 |
|
105 | 125 | [Test]
|
106 |
| - public void CheckPathAsync_Given_FilePathWithIncorrectCase_When_MatchesMultiplePaths_Should_Throw() |
| 126 | + public void CheckPathAsync_Given_EmptyStringPath_Should_Return_EmptyString() |
107 | 127 | {
|
108 |
| - var testPath = "raw/aPi/jan/delta_extract_1.json"; |
| 128 | + var testPath = string.Empty; |
| 129 | + var resultPath = Sut.CheckPathAsync(testPath, true).Result; |
109 | 130 |
|
110 |
| - Assert.CatchAsync(() => Sut.CheckPathAsync(testPath, true)); |
| 131 | + Assert.That(string.Empty, Is.EqualTo(resultPath)); |
| 132 | + } |
| 133 | + |
| 134 | + [Test] |
| 135 | + public void CheckPathAsync_Given_WhitespacePath_Should_Return_EmptyString() |
| 136 | + { |
| 137 | + var testPath = " \t\r\n "; |
| 138 | + var resultPath = Sut.CheckPathAsync(testPath, true).Result; |
| 139 | + |
| 140 | + Assert.That(string.Empty, Is.EqualTo(resultPath)); |
111 | 141 | }
|
112 | 142 |
|
| 143 | + [Test] |
| 144 | + public void CheckPathAsync_Given_ForwardSlashPath_Should_Return_EmptyString() |
| 145 | + { |
| 146 | + var testPath = "/"; |
| 147 | + var resultPath = Sut.CheckPathAsync(testPath, true).Result; |
| 148 | + |
| 149 | + Assert.That(string.Empty, Is.EqualTo(resultPath)); |
| 150 | + } |
| 151 | + |
| 152 | + [Test] |
| 153 | + public void CheckPathAsync_Given_DirectoryPathWithIncorrectCase_Should_ThrowWhenMultipleDirectoriesMatch() |
| 154 | + { |
| 155 | + var testPath = "RaW/api/jan"; |
| 156 | + |
| 157 | + var exception = Assert.CatchAsync(() => Sut.CheckPathAsync(testPath, true)); |
| 158 | + Assert.That(exception, Is.TypeOf(typeof(Exception))); |
| 159 | + } |
| 160 | + |
| 161 | + [Test] |
| 162 | + public void CheckPathAsync_Given_FilePathWithIncorrectCase_Should_ThrowWhenMultipleDirectoriesMatch() |
| 163 | + { |
| 164 | + var testPath = "RaW/api/jan/delta_extract_1.json"; |
| 165 | + |
| 166 | + var exception = Assert.CatchAsync(() => Sut.CheckPathAsync(testPath, false)); |
| 167 | + Assert.That(exception, Is.TypeOf(typeof(Exception))); |
| 168 | + } |
| 169 | + |
| 170 | + [Test] |
| 171 | + public void CheckPathAsync_Given_FilePathWithIncorrectCase_Should_ThrowWhenMultipleFilesMatch() |
| 172 | + { |
| 173 | + var testPath = "raw/database/feb/Extract_2.csv"; |
| 174 | + |
| 175 | + var exception = Assert.CatchAsync(() => Sut.CheckPathAsync(testPath, false)); |
| 176 | + Assert.That(exception, Is.TypeOf(typeof(Exception))); |
| 177 | + } |
113 | 178 |
|
114 | 179 |
|
115 | 180 | //[Test]
|
|
0 commit comments