-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathTestHelper.cs
721 lines (645 loc) · 28.1 KB
/
TestHelper.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
// <copyright file="TestHelper.cs" company="QutEcoacoustics">
// All code in this file and all associated files are the copyright and property of the QUT Ecoacoustics Research Group (formerly MQUTeR, and formerly QUT Bioacoustics Research Group).
// </copyright>
namespace Acoustics.Test.TestHelpers
{
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using Acoustics.Shared;
using Acoustics.Shared.Contracts;
using Acoustics.Tools;
using Acoustics.Tools.Audio;
using Acoustics.Tools.Wav;
using global::AudioAnalysisTools.DSP;
using global::AudioAnalysisTools.StandardSpectrograms;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using static System.Environment;
/// <summary>
/// The test helper.
/// </summary>
public static class TestHelper
{
/// <summary>
/// A generally tolerable delta for unit tests that experience
/// computational errors. Use this only if needed and only for
/// errors derived from floating-point calculations.
/// </summary>
public const double AllowedDelta = 1.0E-9;
public static readonly IReadOnlyDictionary<string, AudioUtilityInfo> AudioDetails = new Dictionary<string, AudioUtilityInfo>
{
{
"06Sibylla.asf",
new AudioUtilityInfo
{
Duration = TimeSpan.FromMinutes(1) + TimeSpan.FromSeconds(49.6),
SampleRate = 44100,
ChannelCount = 2,
BitsPerSecond = 130000,
MediaType = MediaTypes.MediaTypeAsf,
}
},
{
"Currawongs_curlew_West_Knoll_Bees_20091102-183000.mp3",
new AudioUtilityInfo
{
Duration = TimeSpan.FromSeconds(240.03102040816326530612244897959),
SampleRate = 22050,
ChannelCount = 1,
BitsPerSecond = 96000,
MediaType = MediaTypes.MediaTypeMp3,
}
},
{
"A French Fiddle Speaks.mp3",
new AudioUtilityInfo
{
Duration = TimeSpan.FromMinutes(2) + TimeSpan.FromSeconds(41.6),
SampleRate = 44100,
ChannelCount = 2,
BitsPerSecond = 160000,
MediaType = MediaTypes.MediaTypeMp3,
}
},
{
"ocioncosta-lindamenina.ogg",
new AudioUtilityInfo
{
Duration = TimeSpan.FromMinutes(2) + TimeSpan.FromSeconds(32.173),
SampleRate = 32000,
ChannelCount = 2,
BitsPerSecond = 84000,
MediaType = MediaTypes.MediaTypeOggAudio,
}
},
{
"Lewins Rail Kekkek.wav",
new AudioUtilityInfo
{
Duration = TimeSpan.FromMinutes(1) + TimeSpan.FromSeconds(0.245),
SampleRate = 22050,
ChannelCount = 1,
BitsPerSecond = 353000,
MediaType = MediaTypes.MediaTypeWav,
BitsPerSample = 16,
}
},
{
"FemaleKoala MaleKoala.wav",
new AudioUtilityInfo
{
Duration = TimeSpan.FromMinutes(2) + TimeSpan.FromSeconds(0),
SampleRate = 22050,
ChannelCount = 1,
BitsPerSecond = 353000,
MediaType = MediaTypes.MediaTypeWav,
BitsPerSample = 16,
}
},
{
"geckos.wav",
new AudioUtilityInfo
{
Duration = TimeSpan.FromMinutes(1) + TimeSpan.FromSeconds(59.902),
SampleRate = 44100,
ChannelCount = 2,
BitsPerSecond = 1410000,
MediaType = MediaTypes.MediaTypeWav,
BitsPerSample = 16,
}
},
{
"Lewins Rail Kekkek.webm",
new AudioUtilityInfo
{
Duration = TimeSpan.FromMinutes(1) + TimeSpan.FromSeconds(0.257),
SampleRate = 22050,
ChannelCount = 1,
BitsPerSecond = 66400,
MediaType = MediaTypes.MediaTypeWebMAudio,
//BitsPerSample = 32 // only relevant to PCM data
}
},
{
"06Sibylla.wma",
new AudioUtilityInfo
{
Duration = TimeSpan.FromMinutes(1) + TimeSpan.FromSeconds(49.6),
SampleRate = 44100,
ChannelCount = 2,
BitsPerSecond = 130000,
MediaType = MediaTypes.MediaTypeWma,
}
},
{
"Raw_audio_id_cd6e8ba1-11b4-4724-9562-f6ec893110aa.wv",
new AudioUtilityInfo
{
Duration = TimeSpan.FromMinutes(2) + TimeSpan.FromSeconds(0),
SampleRate = 22050,
ChannelCount = 1,
BitsPerSecond = 171000,
MediaType = MediaTypes.MediaTypeWavpack,
//BitsPerSample = 16,
}
},
{
"f969b39d-2705-42fc-992c-252a776f1af3_090705-0600.wv",
new AudioUtilityInfo
{
Duration = TimeSpan.FromMinutes(10) + TimeSpan.FromSeconds(0),
SampleRate = 22050,
ChannelCount = 1,
BitsPerSecond = 158000,
MediaType = MediaTypes.MediaTypeWavpack,
//BitsPerSample = 16,
}
},
{
"4channelsPureTones.wav",
new AudioUtilityInfo
{
Duration = TimeSpan.FromSeconds(60.0),
SampleRate = 44100,
ChannelCount = 4,
BitsPerSecond = 2822400,
MediaType = MediaTypes.MediaTypeWav,
BitsPerSample = 16,
}
},
{
"4channelsPureTones.flac",
new AudioUtilityInfo
{
Duration = TimeSpan.FromSeconds(60.0),
SampleRate = 44100,
ChannelCount = 4,
BitsPerSecond = 693000,
MediaType = MediaTypes.MediaTypeFlacAudio,
BitsPerSample = 16,
}
},
{
"4channelsPureTones.mp3",
new AudioUtilityInfo
{
Duration = TimeSpan.FromSeconds(60.0),
SampleRate = 44100,
ChannelCount = 4,
BitsPerSecond = 125000,
MediaType = MediaTypes.MediaTypeMp3,
//BitsPerSample = 16,
}
},
{
"4channelsPureTones.ogg",
new AudioUtilityInfo
{
Duration = TimeSpan.FromSeconds(60.0),
SampleRate = 44100,
ChannelCount = 4,
BitsPerSecond = 694989,
MediaType = MediaTypes.MediaTypeOggAudio,
BitsPerSample = 16,
}
},
{
"4channelsPureTones.raw",
new AudioUtilityInfo()
{
// We can't actually determine this information from the file (since it is headerless)
// but this is the 'true' information of the file that generated this raw file.
Duration = TimeSpan.FromSeconds(60.0),
SampleRate = 44100,
ChannelCount = 4,
BitsPerSecond = 2822400,
MediaType = MediaTypes.MediaTypeWav,
BitsPerSample = 16,
}
},
{
"4channelsPureTones.wv",
new AudioUtilityInfo
{
Duration = TimeSpan.FromSeconds(60.0),
SampleRate = 44100,
ChannelCount = 4,
BitsPerSecond = 1275000,
MediaType = MediaTypes.MediaTypeWavpack,
//BitsPerSample = 16,
}
},
{
"different_channels_tone.wav",
new AudioUtilityInfo
{
Duration = TimeSpan.FromSeconds(30.0),
SampleRate = 22050,
ChannelCount = 2,
BitsPerSecond = 706000,
MediaType = MediaTypes.MediaTypeWav,
BitsPerSample = 16,
}
},
{
"different_channels_tone.mp3",
new AudioUtilityInfo
{
Duration = TimeSpan.FromSeconds(30.016825),
SampleRate = 22050,
ChannelCount = 2,
BitsPerSecond = 64100,
MediaType = MediaTypes.MediaTypeMp3,
//BitsPerSample = 16,
}
},
{
"4min test.mp3",
new AudioUtilityInfo
{
Duration = TimeSpan.FromSeconds(240.113),
SampleRate = 44100,
ChannelCount = 1,
BitsPerSecond = 128000,
MediaType = MediaTypes.MediaTypeMp3,
//BitsPerSample = 16,
}
},
{
"20190401T000000+1000_REC [19.21440152.8811].flac",
new AudioUtilityInfo()
{
Duration = TimeSpan.FromSeconds(60.0),
SampleRate = 22050,
ChannelCount = 1,
BitsPerSecond = 170 * 8,
MediaType = MediaTypes.MediaTypeFlacAudio,
BitsPerSample = 16,
}
},
};
public static bool OnContinuousIntegrationServer => !GetEnvironmentVariable("TF_BUILD").IsNullOrEmpty() || !GetEnvironmentVariable("APPVEYOR").IsNullOrEmpty();
/// <summary>
/// Tests that an exception is thrown, and that it is of
/// the correct type, with the correct error message.
/// If anything does not match what is supplied, the test fails.
/// </summary>
/// <param name="testCode">
/// The test code.
/// </param>
/// <param name="expectedExceptionPartialString">
/// The expected exception partial string.
/// </param>
/// <typeparam name="T">
/// Expected Exception Type.
/// </typeparam>
/// <returns>
/// Actual Exception, if any.
/// </returns>
[DebuggerHidden]
public static T ExceptionMatches<T>(Action testCode, string expectedExceptionPartialString)
where T : Exception
{
try
{
testCode();
}
catch (Exception exception)
{
Check(typeof(T), expectedExceptionPartialString, exception);
return (T)exception;
}
Assert.Fail("Did not throw " + typeof(T));
return null;
}
/// <summary>
/// Tests that an exception is thrown, and that it is of
/// the correct type, with the correct error message.
/// If anything does not match what is supplied, the test fails.
/// </summary>
/// <param name="exceptionType">
/// Expected Exception Type.
/// </param>
/// <param name="testCode">
/// The test code.
/// </param>
/// <param name="expectedExceptionPartialString">
/// The expected exception partial string.
/// </param>
/// <returns>
/// Actual Exception, if any.
/// </returns>
public static object ExceptionMatches(Type exceptionType, Action testCode, string expectedExceptionPartialString)
{
Contract.Requires<ArgumentException>(
exceptionType.IsSubclassOf(typeof(Exception)) || exceptionType == typeof(Exception),
"must be a TypeInfo for an Exception type",
nameof(exceptionType));
try
{
testCode();
}
catch (Exception exception)
{
Check(exceptionType, expectedExceptionPartialString, exception);
return exception;
}
Assert.Fail("Did not throw " + exceptionType);
return null;
}
/// <summary>
/// Tests that an exception is thrown, and that it is of
/// the correct type, with the correct error message.
/// If anything does not match what is supplied, the test fails.
/// </summary>
/// <param name="testCode">
/// The test code.
/// </param>
/// <param name="expectedExceptionPartialString">
/// The expected exception partial string.
/// </param>
/// <typeparam name="T">
/// Expected Exception Type.
/// </typeparam>
/// <returns>
/// Actual Exception, if any.
/// </returns>
public static T ExceptionMatches<T>(Func<object> testCode, string expectedExceptionPartialString)
where T : Exception
{
try
{
testCode();
}
catch (Exception exception)
{
Check(typeof(T), expectedExceptionPartialString, exception);
return (T)exception;
}
Assert.Fail("Did not throw " + typeof(T));
return null;
}
public static void ExceptionMatches<T>(this Assert assert, Action testCode, string expectedExceptionPartialString)
where T : Exception
{
ExceptionMatches<T>(testCode, expectedExceptionPartialString);
}
/// <summary>
/// Datetimes may not be exactly equal.
/// </summary>
/// <param name="dt1">
/// First DateTime.
/// </param>
/// <param name="dt2">
/// Second DateTime.
/// </param>
/// <returns>
/// True if datetimes are within +-2 milliseconds of each other.
/// </returns>
public static bool CompareDates(DateTime dt1, DateTime dt2)
{
// date times loose precision
return dt1.Year == dt2.Year && dt1.Month == dt2.Month && dt1.Day == dt2.Day && dt1.Hour == dt2.Hour
&& dt1.Minute == dt2.Minute && dt1.Second == dt2.Second && ( // millisecond may be -+2
dt1.Millisecond == dt2.Millisecond
|| dt1.Millisecond == dt2.Millisecond + 2
|| dt1.Millisecond == dt2.Millisecond - 2);
}
/// <summary>
/// Datetimes may not be exactly equal.
/// </summary>
/// <param name="dt1">
/// First DateTime.
/// </param>
/// <param name="dt2">
/// Second DateTime.
/// </param>
/// <param name="range">
/// Max variance in milliseconds.
/// </param>
/// <returns>
/// True if datetimes are within +-<paramref name="range"/> milliseconds of each other.
/// </returns>
public static bool CompareDates(DateTime dt1, DateTime dt2, int range)
{
// date times loose precision
return dt1.Year == dt2.Year && dt1.Month == dt2.Month && dt1.Day == dt2.Day && dt1.Hour == dt2.Hour
&& dt1.Minute == dt2.Minute && dt1.Second == dt2.Second && ( // millisecond may be -+ range
dt1.Millisecond == dt2.Millisecond
||
dt1.Millisecond == dt2.Millisecond + range
||
dt1.Millisecond == dt2.Millisecond - range);
}
/// <summary>
/// TimeSpans may not be exactly equal.
/// </summary>
/// <param name="ts1">
/// First TimeSpan.
/// </param>
/// <param name="ts2">
/// Second TimeSpan.
/// </param>
/// <param name="range">
/// Max variance.
/// </param>
/// <returns>
/// True if TimeSpan are within +-<paramref name="range"/> milliseconds of each other.
/// </returns>
public static bool CompareTimeSpans(TimeSpan ts1, TimeSpan ts2, TimeSpan range)
{
return ts1 == ts2
||
ts1 <= ts2 + range
&& ts1 >= ts2 - range;
}
public static object GetValue<T>(T obj, string name)
{
var objType = typeof(T);
//create reflection bindings - will be used to retrive private fields,methods or properties
BindingFlags privateBindings = BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.GetField;
var field = objType.GetField(name, privateBindings);
if (field != null)
{
var value = field.GetValue(obj);
return value;
}
var property = objType.GetProperty(name, privateBindings);
if (property != null)
{
var value = property.GetValue(obj, null);
return value;
}
return null;
}
public static void SetValue<T>(T obj, string name, object newValue)
{
var objType = typeof(T);
//create reflection bindings - will be used to retrive private fields,methods or properties
BindingFlags privateBindings = BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.SetField;
var field = objType.GetField(name, privateBindings);
if (field != null)
{
field.SetValue(obj, newValue);
return;
}
var property = objType.GetProperty(name, privateBindings);
if (property != null)
{
property.SetValue(obj, newValue, null);
}
}
public static void CheckAudioUtilityInfo(AudioUtilityInfo expected, AudioUtilityInfo actual, int epsilonDurationMilliseconds = 150)
{
if (expected.BitsPerSample.HasValue && actual.BitsPerSample.HasValue)
{
Assert.AreEqual(expected.BitsPerSample.Value, actual.BitsPerSample.Value);
}
if (expected.BitsPerSample.HasValue && !actual.BitsPerSample.HasValue)
{
Assert.Fail($"BitsPerSample failed. Expected: {expected.BitsPerSample}, actual: {actual.BitsPerSample}");
}
if (expected.BitsPerSecond.HasValue && actual.BitsPerSecond.HasValue)
{
// Sox only reports three decimal places and rounds other things
var actualBps = (int)((double)actual.BitsPerSecond.Value).RoundToSignificantDigits(3);
var expectedBps = (int)((double)expected.BitsPerSecond.Value).RoundToSignificantDigits(3);
Assert.AreEqual(expectedBps, actualBps, 0);
}
if (expected.BitsPerSecond.HasValue && !actual.BitsPerSecond.HasValue)
{
Assert.Fail($"BitsPerSecond failed. Expected: {expected.BitsPerSecond}, actual: {actual.BitsPerSecond}");
}
Assert.IsTrue(!string.IsNullOrWhiteSpace(expected.MediaType));
Assert.IsTrue(expected.ChannelCount.HasValue);
Assert.IsTrue(expected.Duration.HasValue);
Assert.IsTrue(expected.SampleRate.HasValue);
Assert.IsTrue(!string.IsNullOrWhiteSpace(actual.MediaType));
Assert.IsTrue(actual.ChannelCount.HasValue);
Assert.IsTrue(actual.Duration.HasValue);
Assert.IsTrue(actual.SampleRate.HasValue);
Assert.AreEqual(expected.MediaType, actual.MediaType);
Assert.AreEqual(expected.ChannelCount.Value, actual.ChannelCount.Value);
Assert.AreEqual(expected.Duration.Value.TotalMilliseconds, actual.Duration.Value.TotalMilliseconds, TimeSpan.FromMilliseconds(epsilonDurationMilliseconds).TotalMilliseconds);
Assert.AreEqual(expected.SampleRate.Value, actual.SampleRate.Value);
}
public static FileInfo GetAudioFile(string filename)
{
var source = PathHelper.GetTestAudioFile(filename);
return source;
}
public static IAudioUtility GetAudioUtility()
{
var ffmpegExe = new FileInfo(AppConfigHelper.FfmpegExe);
var ffmpeg = new FfmpegAudioUtility(ffmpegExe, AppConfigHelper.FfprobeExe.ToFileInfo());
var ffmpegRawPcm = new FfmpegRawPcmAudioUtility(ffmpegExe);
var wvunpack = AppConfigHelper.WvunpackExe;
var wvunpackUtility = wvunpack != null ? new WavPackAudioUtility(wvunpack.ToFileInfo()) : null;
var sox = new SoxAudioUtility(AppConfigHelper.SoxExe.ToFileInfo());
return new MasterAudioUtility(ffmpeg, wvunpackUtility, sox, ffmpegRawPcm, PathHelper.GetTempDir());
}
public static IAudioUtility GetAudioUtilitySox()
{
var soxExe = AppConfigHelper.SoxExe?.ToFileInfo();
var sox = new SoxAudioUtility(soxExe);
return sox;
}
public static IAudioUtility GetAudioUtilityFfmpeg()
{
var ffmpegExe = new FileInfo(AppConfigHelper.FfmpegExe);
var ffprobeExe = new FileInfo(AppConfigHelper.FfprobeExe);
var ffmpeg = new FfmpegAudioUtility(ffmpegExe, ffprobeExe);
return ffmpeg;
}
public static IAudioUtility GetAudioUtilityFfmpegRawPcm()
{
var ffmpegExe = new FileInfo(AppConfigHelper.FfmpegExe);
var ffmpeg = new FfmpegRawPcmAudioUtility(ffmpegExe);
return ffmpeg;
}
public static IAudioUtility GetAudioUtilityWavunpack()
{
var wavunpackExe = new FileInfo(AppConfigHelper.WvunpackExe);
var util = new WavPackAudioUtility(wavunpackExe);
return util;
}
public static void AssertFrequencyInSignal(WavReader wavReader, double[] signal, int[] frequencies, int variance = 1)
{
var fft = DSP_Frames.ExtractEnvelopeAndAmplSpectrogram(signal, wavReader.SampleRate, wavReader.Epsilon, 512, 0.0);
var histogram = SpectrogramTools.CalculateAvgSpectrumFromEnergySpectrogram(fft.AmplitudeSpectrogram);
var max = histogram.Max();
double threshold = max * 0.8;
var highBins = frequencies.Select(f => (int)(f / fft.FreqBinWidth)).ToArray();
bool isOk = true;
for (int bin = 0; bin < histogram.Length; bin++)
{
var value = histogram[bin];
if (value > threshold)
{
bool anyMatch = false;
foreach (var highBin in highBins)
{
if (bin >= highBin - variance && bin <= highBin + variance)
{
anyMatch = true;
break;
}
}
isOk = anyMatch;
}
if (!isOk)
{
break;
}
}
Assert.IsTrue(isOk);
}
public static void WavReaderAssertions(WavReader reader, AudioUtilityInfo info)
{
Assert.AreEqual(info.ChannelCount.Value, reader.Channels);
if (info.BitsPerSample.HasValue)
{
Assert.AreEqual(info.BitsPerSample.Value, reader.BitsPerSample);
}
Assert.AreEqual(info.SampleRate.Value, reader.SampleRate);
Assert.AreEqual(info.Duration.Value.TotalMilliseconds, reader.Time.TotalMilliseconds, 150);
Assert.AreEqual(
(int)(info.Duration.Value.TotalSeconds * info.SampleRate.Value),
reader.BlockCount,
100);
}
//[DebuggerHidden]
private static void Check(Type expectedException, string expectedExceptionPartialString, Exception actualException)
{
string FormatException(Exception actual)
{
var type = actual.GetType();
var message = actual.Message;
var stack = actual.StackTrace;
return $"{type}: {message}\n{stack}";
}
var formattedException = FormatException(actualException);
var error = $"Exception type did not match expected type. Expected: {expectedException}" +
" Actual: " + formattedException;
Assert.AreEqual(expectedException, actualException.GetType(), error);
if (string.IsNullOrWhiteSpace(actualException.Message))
{
Assert.Fail("Exception was thrown with an empty message - this is not allowed." + formattedException);
}
if (string.IsNullOrWhiteSpace(expectedExceptionPartialString))
{
var messageEmpty =
"Parameter \'expectedExceptionPartialString\' was null, empty or white space." +
$"{NewLine}Actual: {formattedException}{NewLine}";
throw new ArgumentException(messageEmpty, nameof(expectedExceptionPartialString));
}
StringAssert.Contains(
actualException.Message,
expectedExceptionPartialString,
$"\nException did not contain expected actual partial string.\nExpected: {expectedExceptionPartialString}");
}
}
}