-
Notifications
You must be signed in to change notification settings - Fork 154
/
Copy pathBadFileTests.cs
52 lines (43 loc) · 1.73 KB
/
BadFileTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright (c) Charlie Poole, Rob Prouse and Contributors. MIT License - see LICENSE.txt
using System.IO;
using System.Text;
using NUnit.ConsoleRunner.Options;
using NUnit.Engine;
using NUnit.Engine.Runners;
using NUnit.Engine.Services;
using NUnit.Framework;
using NUnit.TextDisplay;
namespace NUnit.ConsoleRunner
{
[Ignore("Temporarily ignoring this fixture")]
public class BadFileTests : ITestEventListener
{
[TestCase("junk.dll", "File not found")]
[TestCase("ConsoleTests.nunit", "File type is not supported")]
public void MissingFileTest(string filename, string message)
{
var fullname = Path.Combine(TestContext.CurrentContext.TestDirectory, filename);
var services = new ServiceContext();
services.Add(new TestRunnerFactory());
services.Add(new ExtensionService());
#if NETFRAMEWORK
services.Add(new RuntimeFrameworkService());
services.Add(new TestAgency());
#endif
var package = new TestPackage(fullname);
package.AddSetting("ProcessModel", "InProcess");
var runner = new MasterTestRunner(services, package);
var result = runner.Run(this, TestFilter.Empty);
var sb = new StringBuilder();
var writer = new ExtendedTextWrapper(new StringWriter(sb));
var reporter = new ResultReporter(result, writer, ConsoleMocks.Options());
reporter.WriteErrorsFailuresAndWarningsReport();
var report = sb.ToString();
Assert.That(report, Contains.Substring($"1) Invalid : {fullname}"));
Assert.That(report, Contains.Substring(message));
}
public void OnTestEvent(string report)
{
}
}
}