File tree Expand file tree Collapse file tree 2 files changed +40
-1
lines changed
Microsoft.Toolkit.Uwp.Notifications/Toasts/Builder
UnitTests/UnitTests.Notifications.Shared Expand file tree Collapse file tree 2 files changed +40
-1
lines changed Original file line number Diff line number Diff line change @@ -355,7 +355,7 @@ public ToastContentBuilder AddAudio(
355
355
bool ? silent = default )
356
356
#endif
357
357
{
358
- if ( ! src . IsFile )
358
+ if ( ! src . IsFile && src . Scheme != "ms-winsoundevent" )
359
359
{
360
360
throw new ArgumentException ( nameof ( src ) , "Audio Source has to be a file." ) ;
361
361
}
Original file line number Diff line number Diff line change @@ -548,6 +548,45 @@ public void AddAudioTest_WithFullArgs_ReturnSelfWithCustomAudioAddedWithAllOptio
548
548
Assert . AreEqual ( testToastAudioSilent , builder . Content . Audio . Silent ) ;
549
549
}
550
550
551
+ [ TestMethod ]
552
+ public void AddAudioTest_WithMsWinSoundEvent_ReturnSelfWithCustomAudioAdded ( )
553
+ {
554
+ // Arrange
555
+ Uri testAudioUriSrc = new Uri ( "ms-winsoundevent:Notification.Reminder" ) ;
556
+
557
+ // Act
558
+ ToastContentBuilder builder = new ToastContentBuilder ( ) ;
559
+ ToastContentBuilder anotherReference = builder . AddAudio ( testAudioUriSrc ) ;
560
+
561
+ // Assert
562
+ Assert . AreSame ( builder , anotherReference ) ;
563
+ Assert . AreEqual ( testAudioUriSrc . OriginalString , builder . Content . Audio . Src . OriginalString ) ;
564
+ }
565
+
566
+ [ TestMethod ]
567
+ [ ExpectedException ( typeof ( ArgumentException ) ) ]
568
+ public void AddAudioTest_WithInvalidMsUri_ThrowException ( )
569
+ {
570
+ // Arrange
571
+ Uri testAudioUriSrc = new Uri ( "ms-doesntexist:Notification.Reminder" ) ;
572
+
573
+ // Act
574
+ ToastContentBuilder builder = new ToastContentBuilder ( ) ;
575
+ builder . AddAudio ( testAudioUriSrc ) ;
576
+ }
577
+
578
+ [ TestMethod ]
579
+ [ ExpectedException ( typeof ( ArgumentException ) ) ]
580
+ public void AddAudioTest_WithInvalidHttpUri_ThrowException ( )
581
+ {
582
+ // Arrange
583
+ Uri testAudioUriSrc = new Uri ( "https://myaudio.com/song.mp3" ) ;
584
+
585
+ // Act
586
+ ToastContentBuilder builder = new ToastContentBuilder ( ) ;
587
+ builder . AddAudio ( testAudioUriSrc ) ;
588
+ }
589
+
551
590
[ TestMethod ]
552
591
public void AddAudioTest_WithAudioObject_ReturnSelfWithCustomAudioAdded ( )
553
592
{
You can’t perform that action at this time.
0 commit comments