1
0
mirror of https://github.com/Radarr/Radarr.git synced 2026-04-17 21:26:22 -04:00
Files
Radarr/src/NzbDrone.Core.Test/Messaging/Commands/CommandEqualityComparerFixture.cs
2013-10-05 16:55:43 -07:00

113 lines
4.2 KiB
C#

using System.Collections.Generic;
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 { EpisodeIds = new List<int>{ 1 } };
var command2 = new EpisodeSearchCommand { EpisodeIds = new List<int> { 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 { EpisodeIds = new List<int> { 1 } };
var command2 = new EpisodeSearchCommand { EpisodeIds = new List<int> { 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();
}
[Test]
public void should_return_false_when_commands_list_are_different_lengths()
{
var command1 = new EpisodeSearchCommand { EpisodeIds = new List<int> { 1 } };
var command2 = new EpisodeSearchCommand { EpisodeIds = new List<int> { 1, 2 } };
CommandEqualityComparer.Instance.Equals(command1, command2).Should().BeFalse();
}
[Test]
public void should_return_false_when_commands_list_dont_match()
{
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();
}
}
}