This commit is contained in:
Andrew Leader 2021-02-12 12:59:45 -08:00
Родитель e407e07171
Коммит 80f7871dbe
2 изменённых файлов: 40 добавлений и 1 удалений

Просмотреть файл

@ -355,7 +355,7 @@ namespace Microsoft.Toolkit.Uwp.Notifications
bool? silent = default)
#endif
{
if (!src.IsFile)
if (!src.IsFile && src.Scheme != "ms-winsoundevent")
{
throw new ArgumentException(nameof(src), "Audio Source has to be a file.");
}

Просмотреть файл

@ -548,6 +548,45 @@ namespace UnitTests.Notifications
Assert.AreEqual(testToastAudioSilent, builder.Content.Audio.Silent);
}
[TestMethod]
public void AddAudioTest_WithMsWinSoundEvent_ReturnSelfWithCustomAudioAdded()
{
// Arrange
Uri testAudioUriSrc = new Uri("ms-winsoundevent:Notification.Reminder");
// Act
ToastContentBuilder builder = new ToastContentBuilder();
ToastContentBuilder anotherReference = builder.AddAudio(testAudioUriSrc);
// Assert
Assert.AreSame(builder, anotherReference);
Assert.AreEqual(testAudioUriSrc.OriginalString, builder.Content.Audio.Src.OriginalString);
}
[TestMethod]
[ExpectedException(typeof(ArgumentException))]
public void AddAudioTest_WithInvalidMsUri_ThrowException()
{
// Arrange
Uri testAudioUriSrc = new Uri("ms-doesntexist:Notification.Reminder");
// Act
ToastContentBuilder builder = new ToastContentBuilder();
builder.AddAudio(testAudioUriSrc);
}
[TestMethod]
[ExpectedException(typeof(ArgumentException))]
public void AddAudioTest_WithInvalidHttpUri_ThrowException()
{
// Arrange
Uri testAudioUriSrc = new Uri("https://myaudio.com/song.mp3");
// Act
ToastContentBuilder builder = new ToastContentBuilder();
builder.AddAudio(testAudioUriSrc);
}
[TestMethod]
public void AddAudioTest_WithAudioObject_ReturnSelfWithCustomAudioAdded()
{