chore: some tests

This commit is contained in:
Mikhail Shabanov committed 2021-05-19 16:32:11 +02:00
1 parent a7f9ce19ac
commit 85ed224769
3 files changed
+57 -3

No files matched your search

@@ -3,12 +3,14 @@ using Bunit;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using Radzen;
using WotBlitzStatisticsPro.Blazor.Messages;
using WotBlitzStatisticsPro.Blazor.Model;
using WotBlitzStatisticsPro.Blazor.Shared;
namespace WotBlitzStatisticsPro.Blazor.Tests.Pages
{
public class MainLayoutTest: TestContextBase
public class MainLayoutTest : TestContextBase
{
private IRenderedComponent<MainLayout> _component;
@@ -45,9 +47,34 @@ By.css('.parent .child') // get child who has a parent
{
elements[i].Click();
MediatorMock.Verify(m => m.Publish(
It.Is<ChangeCurrentCultureMessage>(m => m.CultureName == expectedLanguages[0]),
It.Is<ChangeCurrentCultureMessage>(m => m.CultureName == expectedLanguages[0]),
It.IsAny<CancellationToken>()), Times.Once);
}
}
[TestCase(NotificationType.Info, NotificationSeverity.Info)]
[TestCase(NotificationType.Warning, NotificationSeverity.Warning)]
[TestCase(NotificationType.Error, NotificationSeverity.Error)]
public void ShouldEmitRadzenMessageWhenNotificationsServiceHasMessage(NotificationType notificationType, NotificationSeverity expectedSeverity)
{
string expectedSummary = "Foo";
string expectedMessage = "Bar";
NotificationsServiceMock.SetupGet(n => n.Type).Returns(notificationType);
NotificationsServiceMock.SetupGet(n => n.Summary).Returns(expectedSummary);
NotificationsServiceMock.SetupGet(n => n.Message).Returns(expectedMessage);
// Action
NotificationsServiceMock.Raise(n => n.MessageArrived += null);
var radzenNotification = TestContext?.Services.GetService<NotificationService>();
var msg = radzenNotification?.Messages;
msg.Should().NotBeNull();
msg?.Count.Should().Be(1);
msg?[0].Summary.Should().Be(expectedSummary);
msg?[0].Detail.Should().Be(expectedMessage);
msg?[0].Severity.Should().Be(expectedSeverity);
}
}
}