1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-16 11:37:58 +02:00
Sonarr/NzbDrone.Update.Test/ProgramFixture.cs

53 lines
1.3 KiB
C#
Raw Normal View History

2011-11-13 23:31:02 +03:00
using System;
using System.Linq;
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Common.Model;
using NzbDrone.Test.Common;
2013-05-21 07:03:05 +03:00
using NzbDrone.Update.UpdateEngine;
2011-11-13 23:31:02 +03:00
namespace NzbDrone.Update.Test
{
[TestFixture]
2013-05-21 07:03:05 +03:00
public class ProgramFixture : TestBase<Program>
2011-11-13 23:31:02 +03:00
{
[Test]
public void should_throw_if_null_passed_in()
{
2013-05-21 07:03:05 +03:00
Assert.Throws<ArgumentOutOfRangeException>(() => Subject.Start(null));
2011-11-13 23:31:02 +03:00
}
[TestCase("d", "")]
[TestCase("", "")]
[TestCase("0", "")]
[TestCase("-1", "")]
[TestCase(" ", "")]
[TestCase(".", "")]
public void should_throw_if_first_arg_isnt_an_int(string arg1, string arg2)
{
2013-05-21 07:03:05 +03:00
Assert.Throws<ArgumentOutOfRangeException>(() => Subject.Start(new[] { arg1, arg2 }));
2011-11-13 23:31:02 +03:00
}
[Test]
public void should_call_update_with_corret_path()
{
const string ProcessPath = @"C:\NzbDrone\nzbdrone.exe";
2013-05-11 02:53:50 +03:00
Mocker.GetMock<IProcessProvider>().Setup(c => c.GetProcessById(12))
2011-11-13 23:31:02 +03:00
.Returns(new ProcessInfo() { StartPath = ProcessPath });
2013-05-21 07:03:05 +03:00
Subject.Start(new[] { "12", "" });
Mocker.GetMock<IInstallUpdateService>().Verify(c => c.Start(@"C:\NzbDrone"), Times.Once());
2011-11-13 23:31:02 +03:00
}
}
}