public void FormatShouldReturnExpectedDisplayNameFromMethodWithReplacedSpacesAndOperators(string name, string expected) { var formatter = new DisplayNameFormatter(display: Method, displayOptions: ReplaceUnderscoreWithSpace | UseOperatorMonikers); var actual = formatter.Format(name); Assert.Equal(expected, actual); }
public void FormatShouldReturnExpectedDisplayNameFromClassAndMethodWithReplacedSpacesAndEscapeSequences(string name, string expected) { var formatter = new DisplayNameFormatter(display: ClassAndMethod, displayOptions: ReplaceUnderscoreWithSpace | UseEscapeSequences); var actual = formatter.Format(name); Assert.Equal(expected, actual); }
public void FormatShouldReturnExpectedDisplayNameFromMethodWithSpacesInsteadOfUnderscores(string name, string expected) { var formatter = new DisplayNameFormatter(display: Method, displayOptions: ReplaceUnderscoreWithSpace); var actual = formatter.Format(name); Assert.Equal(expected, actual); }
public void FormatShouldReturnExpectedDisplayNameFromMethodWithAllOptions(string name, string expected) { var formatter = new DisplayNameFormatter(display: Method, displayOptions: All); var actual = formatter.Format(name); Assert.Equal(expected, actual); }
public void FormatShouldReturnExpectedDisplayNameFromClassAndMethodWithoutAnyOptions(string name, string expected) { var formatter = new DisplayNameFormatter(display: TestMethodDisplay.ClassAndMethod, displayOptions: TestMethodDisplayOptions.None); var actual = formatter.Format(name); Assert.Equal(expected, actual); }
/// <summary> /// Used for de-serialization. /// </summary> protected TestMethodTestCase( SerializationInfo info, StreamingContext context) { DefaultMethodDisplay = info.GetValue <TestMethodDisplay>("DefaultMethodDisplay"); DefaultMethodDisplayOptions = info.GetValue <TestMethodDisplayOptions>("DefaultMethodDisplayOptions"); displayName = Guard.NotNull("Could not retrieve DisplayName from serialization", info.GetValue <string>("DisplayName")); SkipReason = info.GetValue <string>("SkipReason"); TestMethod = Guard.NotNull("Could not retrieve TestMethod from serialization", info.GetValue <_ITestMethod>("TestMethod")); TestMethodArguments = info.GetValue <object[]>("TestMethodArguments"); Traits = SerializationHelper.DeserializeTraits(info); uniqueID = Guard.NotNull("Could not retrieve UniqueID from serialization", info.GetValue <string>("UniqueID")); formatter = new DisplayNameFormatter(DefaultMethodDisplay, DefaultMethodDisplayOptions); var initResults = Initialize(BaseDisplayName, TestMethod, TestMethodArguments); InitializationException = initResults.initException; Method = initResults.method; MethodGenericTypes = initResults.methodGenericTypes; disposalTracker.AddRange(TestMethodArguments); }
/// <summary> /// Initializes a new instance of the <see cref="TestMethodTestCase"/> class. /// </summary> /// <param name="defaultMethodDisplay">Default method display to use (when not customized).</param> /// <param name="defaultMethodDisplayOptions">Default method display options to use (when not customized).</param> /// <param name="testMethod">The test method this test case belongs to.</param> /// <param name="testMethodArguments">The optional arguments for the test method.</param> /// <param name="skipReason">The optional reason for skipping the test.</param> /// <param name="traits">The optional traits list.</param> /// <param name="uniqueID">The optional unique ID for the test case; if not provided, will be calculated.</param> protected TestMethodTestCase( TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, _ITestMethod testMethod, object?[]?testMethodArguments = null, string?skipReason = null, Dictionary <string, List <string> >?traits = null, string?uniqueID = null) { DefaultMethodDisplay = defaultMethodDisplay; DefaultMethodDisplayOptions = defaultMethodDisplayOptions; SkipReason = skipReason; TestMethod = Guard.ArgumentNotNull(nameof(testMethod), testMethod); TestMethodArguments = testMethodArguments; if (traits != null) { Traits = new Dictionary <string, List <string> >(traits, StringComparer.OrdinalIgnoreCase); } else { Traits = new Dictionary <string, List <string> >(StringComparer.OrdinalIgnoreCase); } formatter = new DisplayNameFormatter(defaultMethodDisplay, defaultMethodDisplayOptions); var initResults = Initialize(BaseDisplayName, testMethod, TestMethodArguments); displayName = initResults.displayName; InitializationException = initResults.initException; Method = initResults.method; MethodGenericTypes = initResults.methodGenericTypes; this.uniqueID = uniqueID ?? UniqueIDGenerator.ForTestCase(TestMethod.UniqueID, MethodGenericTypes, TestMethodArguments); disposalTracker.AddRange(TestMethodArguments); }