Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
quicksln opened this issue Dec 14, 2023 · 2 comments

Comments

@quicksln
Copy link
Contributor

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.

@enchev
Copy link
Collaborator

enchev commented Dec 15, 2023

Hi @quicksln ,

Yes, sure! We accept pull requests!

quicksln added a commit to quicksln/radzen-blazor-notification that referenced this issue Dec 15, 2023
@quicksln
Copy link
Contributor Author

Pull request has been created. Please verify if everything is according to your development standards.
If I missed something, just let me know 😊

quicksln added a commit to quicksln/radzen-blazor-notification that referenced this issue Dec 18, 2023
…on in NotificationMessage - fix for GetHashCode
enchev pushed a commit that referenced this issue Dec 19, 2023
* #1288 NotificationService: Missing IEquatable<T> Implementation in NotificationMessage

* #1288 NotificationService: Missing IEquatable<T> Implementation in NotificationMessage - fix for GetHashCode
@enchev enchev closed this as completed Dec 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants