forked from microsoft/vstest
-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
TestCaseFilterArgumentProcessorTests.cs
109 lines (89 loc) · 4.53 KB
/
TestCaseFilterArgumentProcessorTests.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors
{
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TestPlatform.CommandLine.Processors;
[TestClass]
public class TestCaseFilterArgumentProcessorTests
{
[TestMethod]
public void GetMetadataShouldReturnTestCaseFilterArgumentProcessorCapabilities()
{
TestCaseFilterArgumentProcessor processor = new TestCaseFilterArgumentProcessor();
Assert.IsTrue(processor.Metadata.Value is TestCaseFilterArgumentProcessorCapabilities);
}
[TestMethod]
public void GetExecutorShouldReturnTestCaseFilterArgumentProcessorCapabilities()
{
TestCaseFilterArgumentProcessor processor = new TestCaseFilterArgumentProcessor();
Assert.IsTrue(processor.Executor.Value is TestCaseFilterArgumentExecutor);
}
#region TestCaseFilterArgumentProcessorCapabilitiesTests
[TestMethod]
public void CapabilitiesShouldAppropriateProperties()
{
TestCaseFilterArgumentProcessorCapabilities capabilities = new TestCaseFilterArgumentProcessorCapabilities();
Assert.AreEqual("/TestCaseFilter", capabilities.CommandName);
StringAssert.Contains(capabilities.HelpContentResourceName, "/TestCaseFilter:<Expression>" + Environment.NewLine + " Run tests that match the given expression." + Environment.NewLine + " <Expression> is of the format <property>Operator<value>[|&<Expression>]");
Assert.AreEqual(HelpContentPriority.TestCaseFilterArgumentProcessorHelpPriority, capabilities.HelpPriority);
Assert.IsFalse(capabilities.IsAction);
Assert.AreEqual(ArgumentProcessorPriority.Normal, capabilities.Priority);
Assert.IsFalse(capabilities.AllowMultiple);
Assert.IsFalse(capabilities.AlwaysExecute);
Assert.IsFalse(capabilities.IsSpecialCommand);
}
#endregion
[TestMethod]
public void ExecutorInitializeWithNullOrEmptyTestCaseFilterShouldThrowCommandLineException()
{
var options = CommandLineOptions.Instance;
TestCaseFilterArgumentExecutor executor = new TestCaseFilterArgumentExecutor(options);
try
{
executor.Initialize(null);
}
catch (Exception ex)
{
Assert.IsTrue(ex is CommandLineException);
StringAssert.Contains(ex.Message, @"The /TestCaseFilter argument requires the filter value.");
}
}
[TestMethod]
public void ExecutorInitializeWithNullOrEmptyTestCaseFilterShouldNotThrowWhenTestFilterWasSpecifiedByPreviousStep()
{
var options = CommandLineOptions.Instance;
options.TestCaseFilterValue = "Test=FilterFromPreviousStep";
TestCaseFilterArgumentExecutor executor = new TestCaseFilterArgumentExecutor(options);
executor.Initialize(null);
}
[TestMethod]
public void ExecutorInitializeWithTestCaseFilterShouldOverwriteTheValueProvidedByPreviousStep()
{
var options = CommandLineOptions.Instance;
var defaultValue = "Test=FilterFromPreviousStep";
options.TestCaseFilterValue = defaultValue;
Assert.AreEqual(defaultValue, options.TestCaseFilterValue);
TestCaseFilterArgumentExecutor executor = new TestCaseFilterArgumentExecutor(options);
var value = "Test=NewFilter";
executor.Initialize(value);
Assert.AreEqual(value, options.TestCaseFilterValue);
}
[TestMethod]
public void ExecutorInitializeWithValidTestCaseFilterShouldAddTestCaseFilterToCommandLineOptions()
{
var options = CommandLineOptions.Instance;
TestCaseFilterArgumentExecutor executor = new TestCaseFilterArgumentExecutor(options);
executor.Initialize("Debug");
Assert.AreEqual("Debug", options.TestCaseFilterValue);
}
[TestMethod]
public void ExecutorExecutoreturnArgumentProcessorResultSuccess()
{
var executor = new TestCaseFilterArgumentExecutor(CommandLineOptions.Instance);
var result = executor.Execute();
Assert.AreEqual(ArgumentProcessorResult.Success, result);
}
}
}