mirror of https://github.com/Sonarr/Sonarr
CommandComparer supports IEnumerables now
This commit is contained in:
parent
7798e8b591
commit
ba4193cc46
|
@ -1,4 +1,5 @@
|
|||
using FluentAssertions;
|
||||
using System.Collections.Generic;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Indexers;
|
||||
using NzbDrone.Core.IndexerSearch;
|
||||
|
@ -24,8 +25,8 @@ namespace NzbDrone.Core.Test.Messaging.Commands
|
|||
[Test]
|
||||
public void should_return_true_when_single_property_matches()
|
||||
{
|
||||
var command1 = new EpisodeSearchCommand { EpisodeId = 1 };
|
||||
var command2 = new EpisodeSearchCommand { EpisodeId = 1 };
|
||||
var command1 = new EpisodeSearchCommand { EpisodeIds = new List<int>{ 1 } };
|
||||
var command2 = new EpisodeSearchCommand { EpisodeIds = new List<int> { 1 } };
|
||||
|
||||
CommandEqualityComparer.Instance.Equals(command1, command2).Should().BeTrue();
|
||||
}
|
||||
|
@ -42,8 +43,8 @@ namespace NzbDrone.Core.Test.Messaging.Commands
|
|||
[Test]
|
||||
public void should_return_false_when_single_property_doesnt_match()
|
||||
{
|
||||
var command1 = new EpisodeSearchCommand { EpisodeId = 1 };
|
||||
var command2 = new EpisodeSearchCommand { EpisodeId = 2 };
|
||||
var command1 = new EpisodeSearchCommand { EpisodeIds = new List<int> { 1 } };
|
||||
var command2 = new EpisodeSearchCommand { EpisodeIds = new List<int> { 2 } };
|
||||
|
||||
CommandEqualityComparer.Instance.Equals(command1, command2).Should().BeFalse();
|
||||
}
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
|
@ -46,7 +48,18 @@ namespace NzbDrone.Core.Messaging.Commands
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!xValue.Equals(yValue))
|
||||
if (typeof(IEnumerable).IsAssignableFrom(xProperty.PropertyType))
|
||||
{
|
||||
var xValueCollection = ((IEnumerable)xValue).Cast<object>().OrderBy(t => t);
|
||||
var yValueCollection = ((IEnumerable)yValue).Cast<object>().OrderBy(t => t);
|
||||
|
||||
if (!xValueCollection.SequenceEqual(yValueCollection))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
else if (!xValue.Equals(yValue))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue