You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Prowlarr/NzbDrone.Core.Test/Messaging/Commands/CommandEqualityComparerFixt...

98 lines
3.4 KiB

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
{
[TestFixture]
public class CommandEqualityComparerFixture
{
[Test]
public void should_return_true_when_there_are_no_properties()
{
var command1 = new DownloadedEpisodesScanCommand();
var command2 = new DownloadedEpisodesScanCommand();
CommandEqualityComparer.Instance.Equals(command1, command2).Should().BeTrue();
}
[Test]
public void should_return_true_when_single_property_matches()
{
var command1 = new EpisodeSearchCommand { EpisodeId = 1 };
var command2 = new EpisodeSearchCommand { EpisodeId = 1 };
CommandEqualityComparer.Instance.Equals(command1, command2).Should().BeTrue();
}
[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 };
CommandEqualityComparer.Instance.Equals(command1, command2).Should().BeTrue();
}
[Test]
public void should_return_false_when_single_property_doesnt_match()
{
var command1 = new EpisodeSearchCommand { EpisodeId = 1 };
var command2 = new EpisodeSearchCommand { EpisodeId = 2 };
CommandEqualityComparer.Instance.Equals(command1, command2).Should().BeFalse();
}
[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 };
CommandEqualityComparer.Instance.Equals(command1, command2).Should().BeFalse();
}
[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 };
CommandEqualityComparer.Instance.Equals(command1, command2).Should().BeFalse();
}
[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();
}
[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();
}
}
}