mirror of
https://github.com/Radarr/Radarr.git
synced 2026-04-23 22:25:14 -04:00
7cfa0531dc
* First fixing of tests. * Updated more tests. * Fix some tests * Fix all prioritization tests. And add new for preferred words. * Updated CompletedDownloadservice tests * Fixed a lot of tests * Fixed all indexer requests. We should add more for the indexers we added. To lazy for that though ¯\_(ツ)_/¯ * Fixed organizer tests. Should probably be also updated to incorporate our newly added tags. * Fix notification tests. * Fixed update test for osx * Fixed a few more tests. * Fixed some more tests. * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update activity.less * Update appveyor.yml * Update appveyor.yml * Update CommonVersionInfo.cs * Update build-appveyor.cake Let's hope this works. * Update CommonVersionInfo.cs Just to kickstart appveyor * Fixed a few tests * Just ignore those tests. * Fixed more tests. * First steps in fixing Core.Test.Download.DownloadApprovedFixture * Fix most DownloadApprovedFixture tests * Fixed something. * Fixed a few more tests. * Fixed pending release tests. * All Core tests are now fixed. * Fixed the last tests :) * Fixed Download Station Tests. * Fixed Vuze and Transmission default settings which caused the tests to fail. * Fix most tests. * Fix RootFolder tests. * Fixed last tests
117 lines
3.3 KiB
C#
117 lines
3.3 KiB
C#
using System;
|
|
using System.ComponentModel;
|
|
using System.Diagnostics;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using FluentAssertions;
|
|
using NUnit.Framework;
|
|
using NzbDrone.Common.Model;
|
|
using NzbDrone.Common.Processes;
|
|
using NzbDrone.Test.Common;
|
|
using NzbDrone.Test.Dummy;
|
|
using System.Reflection;
|
|
|
|
namespace NzbDrone.Common.Test
|
|
{
|
|
[TestFixture]
|
|
public class ProcessProviderTests : TestBase<ProcessProvider>
|
|
{
|
|
|
|
[SetUp]
|
|
public void Setup()
|
|
{
|
|
Process.GetProcessesByName(DummyApp.DUMMY_PROCCESS_NAME).ToList().ForEach(c =>
|
|
{
|
|
c.Kill();
|
|
c.WaitForExit();
|
|
});
|
|
|
|
Process.GetProcessesByName(DummyApp.DUMMY_PROCCESS_NAME).Should().BeEmpty();
|
|
}
|
|
|
|
[TearDown]
|
|
public void TearDown()
|
|
{
|
|
Process.GetProcessesByName(DummyApp.DUMMY_PROCCESS_NAME).ToList().ForEach(c =>
|
|
{
|
|
try
|
|
{
|
|
c.Kill();
|
|
}
|
|
catch (Win32Exception ex)
|
|
{
|
|
TestLogger.Warn(ex, "{0} when killing process", ex.Message);
|
|
}
|
|
|
|
});
|
|
}
|
|
|
|
[Test]
|
|
public void GetById_should_return_null_if_process_doesnt_exist()
|
|
{
|
|
Subject.GetProcessById(1234567).Should().BeNull();
|
|
|
|
ExceptionVerification.ExpectedWarns(1);
|
|
}
|
|
|
|
[TestCase(0)]
|
|
[TestCase(-1)]
|
|
[TestCase(9999)]
|
|
public void GetProcessById_should_return_null_for_invalid_process(int processId)
|
|
{
|
|
Subject.GetProcessById(processId).Should().BeNull();
|
|
|
|
ExceptionVerification.ExpectedWarns(1);
|
|
}
|
|
|
|
[Test]
|
|
[Ignore("Shit appveyor")]
|
|
public void Should_be_able_to_start_process()
|
|
{
|
|
string codeBase = Assembly.GetExecutingAssembly().CodeBase;
|
|
UriBuilder uri = new UriBuilder(codeBase);
|
|
string path = Uri.UnescapeDataString(uri.Path);
|
|
var rPath = Path.GetDirectoryName(path);
|
|
|
|
var root = Directory.GetParent(rPath).Parent.Parent.Parent;
|
|
var DummyAppDir = Path.Combine(root.FullName, "NzbDrone.Test.Dummy", "bin", "Release");
|
|
|
|
var process = Subject.Start(Path.Combine(DummyAppDir, DummyApp.DUMMY_PROCCESS_NAME + ".exe"));
|
|
|
|
Subject.Exists(DummyApp.DUMMY_PROCCESS_NAME).Should()
|
|
.BeTrue("excepted one dummy process to be already running");
|
|
|
|
process.Kill();
|
|
process.WaitForExit();
|
|
|
|
Subject.Exists(DummyApp.DUMMY_PROCCESS_NAME).Should().BeFalse();
|
|
}
|
|
|
|
|
|
[Test]
|
|
[Ignore("Shit appveyor")]
|
|
public void kill_all_should_kill_all_process_with_name()
|
|
{
|
|
var dummy1 = StartDummyProcess();
|
|
var dummy2 = StartDummyProcess();
|
|
|
|
Subject.KillAll(DummyApp.DUMMY_PROCCESS_NAME);
|
|
|
|
dummy1.HasExited.Should().BeTrue();
|
|
dummy2.HasExited.Should().BeTrue();
|
|
}
|
|
|
|
private Process StartDummyProcess()
|
|
{
|
|
return Subject.Start(DummyApp.DUMMY_PROCCESS_NAME + ".exe");
|
|
}
|
|
|
|
[Test]
|
|
public void ToString_on_new_processInfo()
|
|
{
|
|
Console.WriteLine(new ProcessInfo().ToString());
|
|
ExceptionVerification.MarkInconclusive(typeof(Win32Exception));
|
|
}
|
|
}
|
|
}
|