Lidarr/src/NzbDrone.Update.Test/ProgramFixture.cs

45 lines
1.3 KiB
C#
Raw Normal View History

2017-09-27 02:06:05 +00:00
using System;
2011-11-13 20:31:02 +00:00
using Moq;
using NUnit.Framework;
using NzbDrone.Common.Model;
using NzbDrone.Common.Processes;
2011-11-13 20:31:02 +00:00
using NzbDrone.Test.Common;
2013-05-21 04:03:05 +00:00
using NzbDrone.Update.UpdateEngine;
2011-11-13 20:31:02 +00:00
namespace NzbDrone.Update.Test
{
[TestFixture]
public class ProgramFixture : TestBase<UpdateApp>
2011-11-13 20:31:02 +00:00
{
[Test]
public void should_throw_if_null_passed_in()
{
2013-05-21 04:03:05 +00:00
Assert.Throws<ArgumentOutOfRangeException>(() => Subject.Start(null));
2011-11-13 20:31:02 +00: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 04:03:05 +00:00
Assert.Throws<ArgumentOutOfRangeException>(() => Subject.Start(new[] { arg1, arg2 }));
2011-11-13 20:31:02 +00:00
}
[Test]
public void should_call_update_with_correct_path()
2011-11-13 20:31:02 +00:00
{
var processPath = @"C:\Lidarr\lidarr.exe".AsOsAgnostic();
2011-11-13 20:31:02 +00:00
2013-05-10 23:53:50 +00:00
Mocker.GetMock<IProcessProvider>().Setup(c => c.GetProcessById(12))
.Returns(new ProcessInfo() { StartPath = processPath });
2013-05-21 04:03:05 +00:00
Subject.Start(new[] { "12", "", processPath });
2013-05-21 04:03:05 +00:00
2017-09-27 02:06:05 +00:00
Mocker.GetMock<IInstallUpdateService>().Verify(c => c.Start(@"C:\Lidarr".AsOsAgnostic(), 12), Times.Once());
2011-11-13 20:31:02 +00:00
}
}
}