-
Notifications
You must be signed in to change notification settings - Fork 909
Description
Describe the bug
The Notification Service relies on distributing messages from an observable collection:
ObservableCollection<NotificationMessage> Messages
The Notification Service includes two 'Notify' methods that check whether the collection contains a specific instance of NotificationMessage and add messages to the collection.
However, it does not function correctly because NotificationMessage does not implement IEquatable.
This interface implementation is necessary to determine if specific object instances are equal when using the List.Contains method.
To Reproduce
Steps to reproduce the behavior:
Run unit test :
[Fact]
public void NotificationService_MessagesCount_AfterAddingMessages()
{
NotificationService notificationService = new NotificationService();
//Messages are the same so only one should be added
notificationService.Notify(NotificationSeverity.Info, "Info Summary", "Info Detail", 4000);
notificationService.Notify(new NotificationMessage()
{
Severity = NotificationSeverity.Info,
Summary = "Info Summary",
Detail = "Info Detail",
Duration = 4000
});
int expectedMessagesNumber = 1;
Assert.Equal(expectedMessagesNumber, notificationService.Messages.Count);
}
Desktop (please complete the following information):
• OS: all
• Browser: [edge, chrome, safari
• Version: 4.22.1
Additional context
If my assumption is correct, I’ll be happy to fix it.