fixed command equality to take type into consideration.

pull/6/head
kay.one 11 years ago
parent 9abd5c0e28
commit 372ac79fe6

@ -1,8 +1,11 @@
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.IndexerSearch;
using NzbDrone.Core.MediaFiles.Commands;
using NzbDrone.Core.Messaging.Commands;
using NzbDrone.Core.Update.Commands;
using NzbDrone.SignalR;
namespace NzbDrone.Core.Test.Messaging.Commands
{
@ -71,5 +74,24 @@ namespace NzbDrone.Core.Test.Messaging.Commands
CommandEqualityComparer.Instance.Equals(command1, command2).Should().BeFalse();
}
[Test]
public void should_return_false_when_only_one_has_null_property()
{
var command1 = new BroadcastSignalRMessage(null);
var command2 = new BroadcastSignalRMessage(new SignalRMessage());
CommandEqualityComparer.Instance.Equals(command1, command2).Should().BeFalse();
}
[Test]
public void should_return_false_when_commands_are_diffrent_types()
{
CommandEqualityComparer.Instance.Equals(new RssSyncCommand(), new ApplicationUpdateCommand()).Should().BeFalse();
}
}
}

@ -232,6 +232,10 @@
<Project>{FF5EE3B6-913B-47CE-9CEB-11C51B4E1205}</Project>
<Name>NzbDrone.Core</Name>
</ProjectReference>
<ProjectReference Include="..\NzbDrone.SignalR\NzbDrone.SignalR.csproj">
<Project>{7C2CC69F-5CA0-4E5C-85CB-983F9F6C3B36}</Project>
<Name>NzbDrone.SignalR</Name>
</ProjectReference>
<ProjectReference Include="..\NzbDrone.Test.Common\NzbDrone.Test.Common.csproj">
<Project>{CADDFCE0-7509-4430-8364-2074E1EEFCA2}</Project>
<Name>NzbDrone.Test.Common</Name>

@ -14,6 +14,8 @@ namespace NzbDrone.Core.Messaging.Commands
public bool Equals(Command x, Command y)
{
if(x.GetType() != y.GetType()) return false;
var xProperties = x.GetType().GetProperties();
var yProperties = y.GetType().GetProperties();
@ -24,12 +26,7 @@ namespace NzbDrone.Core.Messaging.Commands
continue;
}
var yProperty = yProperties.SingleOrDefault(p => p.Name == xProperty.Name);
if (yProperty == null)
{
continue;
}
var yProperty = yProperties.Single(p => p.Name == xProperty.Name);
var xValue = xProperty.GetValue(x, null);
var yValue = yProperty.GetValue(y, null);

@ -1,6 +1,8 @@
using NzbDrone.Core.Messaging.Commands;
namespace NzbDrone.SignalR
{
public class BroadcastSignalRMessage : Core.Messaging.Commands.Command
public class BroadcastSignalRMessage : Command
{
public SignalRMessage Body { get; private set; }

Loading…
Cancel
Save