signalr cleanup

This commit is contained in:
kay.one
2013-09-10 23:33:47 -07:00
committed by Keivan Beigi
parent feda4a9b67
commit 25e2c98c45
219 changed files with 2035 additions and 1495 deletions
@@ -0,0 +1,20 @@
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Update.Commands;
namespace NzbDrone.Common.Test.MessagingTests
{
[TestFixture]
public class CommandBaseFixture
{
[Test]
public void default_values()
{
var command = new ApplicationUpdateCommand();
command.Id.Should().NotBe(0);
command.Name.Should().Be("ApplicationUpdate");
}
}
}
@@ -1,12 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FluentAssertions;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Common.Messaging;
using NzbDrone.Core.IndexerSearch;
using NzbDrone.Core.MediaFiles.Commands;
using NzbDrone.Core.Messaging;
using NzbDrone.Core.Messaging.Commands;
namespace NzbDrone.Common.Test.MessagingTests
{
@@ -18,9 +15,8 @@ namespace NzbDrone.Common.Test.MessagingTests
{
var command1 = new DownloadedEpisodesScanCommand();
var command2 = new DownloadedEpisodesScanCommand();
var comparer = new CommandEqualityComparer();
comparer.Equals(command1, command2).Should().BeTrue();
CommandEqualityComparer.Instance.Equals(command1, command2).Should().BeTrue();
}
[Test]
@@ -28,9 +24,8 @@ namespace NzbDrone.Common.Test.MessagingTests
{
var command1 = new EpisodeSearchCommand { EpisodeId = 1 };
var command2 = new EpisodeSearchCommand { EpisodeId = 1 };
var comparer = new CommandEqualityComparer();
comparer.Equals(command1, command2).Should().BeTrue();
CommandEqualityComparer.Instance.Equals(command1, command2).Should().BeTrue();
}
[Test]
@@ -38,9 +33,8 @@ namespace NzbDrone.Common.Test.MessagingTests
{
var command1 = new SeasonSearchCommand { SeriesId = 1, SeasonNumber = 1 };
var command2 = new SeasonSearchCommand { SeriesId = 1, SeasonNumber = 1 };
var comparer = new CommandEqualityComparer();
comparer.Equals(command1, command2).Should().BeTrue();
CommandEqualityComparer.Instance.Equals(command1, command2).Should().BeTrue();
}
[Test]
@@ -48,9 +42,8 @@ namespace NzbDrone.Common.Test.MessagingTests
{
var command1 = new EpisodeSearchCommand { EpisodeId = 1 };
var command2 = new EpisodeSearchCommand { EpisodeId = 2 };
var comparer = new CommandEqualityComparer();
comparer.Equals(command1, command2).Should().BeFalse();
CommandEqualityComparer.Instance.Equals(command1, command2).Should().BeFalse();
}
[Test]
@@ -58,9 +51,8 @@ namespace NzbDrone.Common.Test.MessagingTests
{
var command1 = new SeasonSearchCommand { SeriesId = 1, SeasonNumber = 1 };
var command2 = new SeasonSearchCommand { SeriesId = 1, SeasonNumber = 2 };
var comparer = new CommandEqualityComparer();
comparer.Equals(command1, command2).Should().BeFalse();
CommandEqualityComparer.Instance.Equals(command1, command2).Should().BeFalse();
}
[Test]
@@ -68,9 +60,8 @@ namespace NzbDrone.Common.Test.MessagingTests
{
var command1 = new SeasonSearchCommand { SeriesId = 1, SeasonNumber = 1 };
var command2 = new SeasonSearchCommand { SeriesId = 2, SeasonNumber = 2 };
var comparer = new CommandEqualityComparer();
comparer.Equals(command1, command2).Should().BeFalse();
CommandEqualityComparer.Instance.Equals(command1, command2).Should().BeFalse();
}
}
}
@@ -2,11 +2,12 @@
using System.Collections.Generic;
using Moq;
using NUnit.Framework;
using NzbDrone.Common.Messaging;
using NzbDrone.Common.Messaging.Tracking;
using NzbDrone.Core.Messaging;
using NzbDrone.Core.Messaging.Commands;
using NzbDrone.Core.Messaging.Tracking;
using NzbDrone.Test.Common;
namespace NzbDrone.Common.Test.EventingTests
namespace NzbDrone.Common.Test.MessagingTests
{
[TestFixture]
public class MessageAggregatorCommandTests : TestBase<MessageAggregator>
@@ -28,13 +29,10 @@ namespace NzbDrone.Common.Test.EventingTests
.Setup(c => c.Build(typeof(IExecute<CommandB>)))
.Returns(_executorB.Object);
Mocker.GetMock<ITrackCommands>()
.Setup(c => c.TrackIfNew(It.IsAny<CommandA>()))
.Returns(new TrackedCommand(new CommandA(), ProcessState.Running));
Mocker.GetMock<ITrackCommands>()
.Setup(c => c.TrackIfNew(It.IsAny<CommandB>()))
.Returns(new TrackedCommand(new CommandB(), ProcessState.Running));
.Setup(c => c.FindExisting(It.IsAny<Command>()))
.Returns<Command>(null);
}
[Test]
@@ -42,10 +40,6 @@ namespace NzbDrone.Common.Test.EventingTests
{
var commandA = new CommandA();
Mocker.GetMock<ITrackCommands>()
.Setup(c => c.TrackIfNew(commandA))
.Returns(new TrackedCommand(commandA, ProcessState.Running));
Subject.PublishCommand(commandA);
_executorA.Verify(c => c.Execute(commandA), Times.Once());
@@ -54,7 +48,7 @@ namespace NzbDrone.Common.Test.EventingTests
[Test]
public void should_publish_command_by_with_optional_arg_using_name()
{
Mocker.GetMock<IServiceFactory>().Setup(c => c.GetImplementations(typeof(ICommand)))
Mocker.GetMock<IServiceFactory>().Setup(c => c.GetImplementations(typeof(Command)))
.Returns(new List<Type> { typeof(CommandA), typeof(CommandB) });
Subject.PublishCommand(typeof(CommandA).FullName);
@@ -67,10 +61,6 @@ namespace NzbDrone.Common.Test.EventingTests
{
var commandA = new CommandA();
Mocker.GetMock<ITrackCommands>()
.Setup(c => c.TrackIfNew(commandA))
.Returns(new TrackedCommand(commandA, ProcessState.Running));
Subject.PublishCommand(commandA);
_executorA.Verify(c => c.Execute(commandA), Times.Once());
@@ -89,24 +79,18 @@ namespace NzbDrone.Common.Test.EventingTests
}
}
public class CommandA : ICommand
public class CommandA : Command
{
public String CommandId { get; private set; }
// ReSharper disable UnusedParameter.Local
public CommandA(int id = 0)
// ReSharper restore UnusedParameter.Local
{
CommandId = HashUtil.GenerateCommandId();
}
}
public class CommandB : ICommand
public class CommandB : Command
{
public String CommandId { get; private set; }
public CommandB()
{
CommandId = HashUtil.GenerateCommandId();
}
}
@@ -1,13 +1,14 @@
using System;
using System.Collections.Generic;
using System.Threading;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Common.Messaging;
using NzbDrone.Core.Messaging;
using NzbDrone.Test.Common;
using FluentAssertions;
namespace NzbDrone.Common.Test.EventingTests
namespace NzbDrone.Common.Test.MessagingTests
{
[TestFixture]
public class MessageAggregatorEventTests : TestBase<MessageAggregator>
@@ -127,7 +128,7 @@ namespace NzbDrone.Common.Test.EventingTests
counter.WaitForAllItems();
counter.MaxThreads.Should().Be(2);
counter.MaxThreads.Should().Be(3);
}
}
@@ -67,8 +67,9 @@
<Compile Include="EnsureTest\PathExtensionFixture.cs" />
<Compile Include="EnvironmentTests\StartupArgumentsFixture.cs" />
<Compile Include="EnvironmentTests\EnvironmentProviderTest.cs" />
<Compile Include="EventingTests\MessageAggregatorCommandTests.cs" />
<Compile Include="EventingTests\MessageAggregatorEventTests.cs" />
<Compile Include="MessagingTests\CommandBaseFixture.cs" />
<Compile Include="MessagingTests\MessageAggregatorCommandTests.cs" />
<Compile Include="MessagingTests\MessageAggregatorEventTests.cs" />
<Compile Include="MessagingTests\CommandEqualityComparerFixture.cs" />
<Compile Include="ReflectionExtensions.cs" />
<Compile Include="PathExtensionFixture.cs" />
@@ -2,8 +2,8 @@
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Common.Messaging;
using NzbDrone.Core.Lifecycle;
using NzbDrone.Core.Messaging;
using NzbDrone.Host;
using NzbDrone.Test.Common;