|
3 | 3 | using Avalonia.Platform.Storage; |
4 | 4 | using System; |
5 | 5 | using System.IO; |
| 6 | +using System.Runtime.CompilerServices; |
6 | 7 | using System.Threading.Tasks; |
7 | 8 | using Vocup.IO; |
8 | 9 | using Vocup.Models; |
@@ -81,7 +82,7 @@ public async Task TestReadVhf1_RandomBase64() |
81 | 82 | public async Task TestWriteReadVhf1() |
82 | 83 | { |
83 | 84 | string tempPath = Path.GetTempPath(); |
84 | | - string path = Path.Combine(tempPath, $"Vocup_{nameof(TestWriteReadVhf1)}.vhf"); |
| 85 | + string path = GetTempFilePath(); |
85 | 86 | string vhrCode = "o5xqm7rdg6y9fecs9ykuuckv"; |
86 | 87 | Book original = GenerateSampleBook(); |
87 | 88 | original.VhrCode = vhrCode; |
@@ -119,7 +120,7 @@ public async Task TestWriteReadVhf1() |
119 | 120 | public async Task TestWriteReadVhf1_PracticeModeMixed() |
120 | 121 | { |
121 | 122 | string tempPath = Path.GetTempPath(); |
122 | | - string path = Path.Combine(tempPath, $"Vocup_{nameof(TestWriteReadVhf1_PracticeModeMixed)}.vhf"); |
| 123 | + string path = GetTempFilePath(); |
123 | 124 | string vhrCode = "ina5ucmjup2sbcioxdsrvqsu"; |
124 | 125 | Book original = GenerateSampleBook(); |
125 | 126 | original.PracticeMode = PracticeMode.AskForBothMixed; |
@@ -158,7 +159,7 @@ public async Task TestWriteReadVhf1_PracticeModeMixed() |
158 | 159 | public async Task TestWriteReadVhf1_WithoutResults() |
159 | 160 | { |
160 | 161 | string tempPath = Path.GetTempPath(); |
161 | | - string path = Path.Combine(tempPath, $"Vocup_{nameof(TestWriteReadVhf1_WithoutResults)}.vhf"); |
| 162 | + string path = GetTempFilePath(); |
162 | 163 | string vhrCode = "wetwjlvwhspsre4slcb01mwk"; |
163 | 164 | Book original = GenerateSampleBook(); |
164 | 165 | original.VhrCode = vhrCode; |
@@ -239,7 +240,7 @@ public async Task TestReadVhf2_UpdateRequired() |
239 | 240 | public async Task TestWriteReadVhf2() |
240 | 241 | { |
241 | 242 | string tempPath = Path.GetTempPath(); |
242 | | - string path = Path.Combine(tempPath, $"Vocup_{nameof(TestWriteReadVhf2)}.vhf"); |
| 243 | + string path = GetTempFilePath(); |
243 | 244 | Book original = GenerateSampleBook(); |
244 | 245 |
|
245 | 246 | IStorageFile file; |
@@ -274,7 +275,7 @@ public async Task TestWriteReadVhf2() |
274 | 275 | public async Task TestWriteReadVhf2_WithoutResults() |
275 | 276 | { |
276 | 277 | string tempPath = Path.GetTempPath(); |
277 | | - string path = Path.Combine(tempPath, $"Vocup_{nameof(TestWriteReadVhf2_WithoutResults)}.vhf"); |
| 278 | + string path = GetTempFilePath(); |
278 | 279 | Book original = GenerateSampleBook(); |
279 | 280 |
|
280 | 281 | IStorageFile file; |
@@ -323,4 +324,11 @@ private static Book GenerateSampleBook() |
323 | 324 | } |
324 | 325 | return book; |
325 | 326 | } |
| 327 | + |
| 328 | + private static string GetTempFilePath([CallerMemberName] string? testName = null) |
| 329 | + { |
| 330 | + ArgumentException.ThrowIfNullOrWhiteSpace(testName); |
| 331 | + string tempPath = Path.GetTempPath(); |
| 332 | + return Path.Combine(tempPath, $"Vocup_{nameof(BookFileFormat2Tests)}_{testName}.vhf"); |
| 333 | + } |
326 | 334 | } |
0 commit comments