2013-09-11 06:33:47 +00:00
|
|
|
|
using FluentAssertions;
|
2013-08-28 06:51:42 +00:00
|
|
|
|
using NUnit.Framework;
|
2013-09-15 00:33:19 +00:00
|
|
|
|
using NzbDrone.Core.Indexers;
|
2013-08-28 06:51:42 +00:00
|
|
|
|
using NzbDrone.Core.IndexerSearch;
|
|
|
|
|
using NzbDrone.Core.MediaFiles.Commands;
|
2013-09-11 06:33:47 +00:00
|
|
|
|
using NzbDrone.Core.Messaging.Commands;
|
2013-09-15 00:33:19 +00:00
|
|
|
|
using NzbDrone.Core.Update.Commands;
|
|
|
|
|
using NzbDrone.SignalR;
|
2013-08-28 06:51:42 +00:00
|
|
|
|
|
2013-09-14 23:34:21 +00:00
|
|
|
|
namespace NzbDrone.Core.Test.Messaging.Commands
|
2013-08-28 06:51:42 +00:00
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
|
|
|
|
public class CommandEqualityComparerFixture
|
|
|
|
|
{
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_return_true_when_there_are_no_properties()
|
|
|
|
|
{
|
|
|
|
|
var command1 = new DownloadedEpisodesScanCommand();
|
|
|
|
|
var command2 = new DownloadedEpisodesScanCommand();
|
|
|
|
|
|
2013-09-11 06:33:47 +00:00
|
|
|
|
CommandEqualityComparer.Instance.Equals(command1, command2).Should().BeTrue();
|
2013-08-28 06:51:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_return_true_when_single_property_matches()
|
|
|
|
|
{
|
|
|
|
|
var command1 = new EpisodeSearchCommand { EpisodeId = 1 };
|
|
|
|
|
var command2 = new EpisodeSearchCommand { EpisodeId = 1 };
|
|
|
|
|
|
2013-09-11 06:33:47 +00:00
|
|
|
|
CommandEqualityComparer.Instance.Equals(command1, command2).Should().BeTrue();
|
2013-08-28 06:51:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_return_true_when_multiple_properties_match()
|
|
|
|
|
{
|
|
|
|
|
var command1 = new SeasonSearchCommand { SeriesId = 1, SeasonNumber = 1 };
|
|
|
|
|
var command2 = new SeasonSearchCommand { SeriesId = 1, SeasonNumber = 1 };
|
|
|
|
|
|
2013-09-11 06:33:47 +00:00
|
|
|
|
CommandEqualityComparer.Instance.Equals(command1, command2).Should().BeTrue();
|
2013-08-28 06:51:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_return_false_when_single_property_doesnt_match()
|
|
|
|
|
{
|
|
|
|
|
var command1 = new EpisodeSearchCommand { EpisodeId = 1 };
|
|
|
|
|
var command2 = new EpisodeSearchCommand { EpisodeId = 2 };
|
|
|
|
|
|
2013-09-11 06:33:47 +00:00
|
|
|
|
CommandEqualityComparer.Instance.Equals(command1, command2).Should().BeFalse();
|
2013-08-28 06:51:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_return_false_when_only_one_property_matches()
|
|
|
|
|
{
|
|
|
|
|
var command1 = new SeasonSearchCommand { SeriesId = 1, SeasonNumber = 1 };
|
|
|
|
|
var command2 = new SeasonSearchCommand { SeriesId = 1, SeasonNumber = 2 };
|
|
|
|
|
|
2013-09-11 06:33:47 +00:00
|
|
|
|
CommandEqualityComparer.Instance.Equals(command1, command2).Should().BeFalse();
|
2013-08-28 06:51:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_return_false_when_no_properties_match()
|
|
|
|
|
{
|
|
|
|
|
var command1 = new SeasonSearchCommand { SeriesId = 1, SeasonNumber = 1 };
|
|
|
|
|
var command2 = new SeasonSearchCommand { SeriesId = 2, SeasonNumber = 2 };
|
|
|
|
|
|
2013-09-11 06:33:47 +00:00
|
|
|
|
CommandEqualityComparer.Instance.Equals(command1, command2).Should().BeFalse();
|
2013-08-28 06:51:42 +00:00
|
|
|
|
}
|
2013-09-13 01:47:18 +00:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_return_false_when_only_one_has_properties()
|
|
|
|
|
{
|
|
|
|
|
var command1 = new SeasonSearchCommand();
|
|
|
|
|
var command2 = new SeasonSearchCommand { SeriesId = 2, SeasonNumber = 2 };
|
|
|
|
|
|
|
|
|
|
CommandEqualityComparer.Instance.Equals(command1, command2).Should().BeFalse();
|
|
|
|
|
}
|
2013-09-15 00:33:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[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();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2013-08-28 06:51:42 +00:00
|
|
|
|
}
|
|
|
|
|
}
|