Skip to content

NotificationService: Missing IEquatable<T> Implementation in NotificationMessage #1288

@quicksln

Description

@quicksln

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);
        }

Screenshots
image

image

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions