<Rule Id="CA5372" Action="None" /> <!-- Use XmlReader For XPathDocument -->
</Rules>
<Rules AnalyzerId="xunit.analyzers" RuleNamespace="xunit.analyzers">
- <Rule Id="xUnit1010" Action="None" /> <!-- The value is not convertible to the method parameter type -->
<Rule Id="xUnit1019" Action="None" /> <!-- MemberData must reference a member providing a valid data type -->
<Rule Id="xUnit1024" Action="None" /> <!-- Test methods cannot have overloads -->
<Rule Id="xUnit1026" Action="None" /> <!-- Theory methods should use all of their parameters -->
[InlineData(0.01, 37, 100.0, 0, DueDate.BegOfPeriod, -4495.27236141772, -4495.2723614177185)]
[InlineData(-0.0083, 15, 263.0, 0, DueDate.EndOfPeriod, -3723.83765008048, -3723.837650080481)] // rate < 0
[InlineData(0, 15, 263, 0, DueDate.EndOfPeriod, -3945, -3945)] // rate = 0
- [InlineData(0.0083, 15, 263.0, 0, 8, -4217.37334665461, -4217.37334665461)] // type <> 0 and type <> 1
- [InlineData(1e+25, 12, 1797, 0, 1, -1.797e+303, -1.797000000000002e+303)] // overFlow
+ [InlineData(0.0083, 15, 263.0, 0, (DueDate)8, -4217.37334665461, -4217.37334665461)] // type <> 0 and type <> 1
+ [InlineData(1e+25, 12, 1797, 0, (DueDate)1, -1.797e+303, -1.797000000000002e+303)] // overFlow
public void FV(double Rate, double NPer, double Pmt, double PV, DueDate Due, double expectedOld, double expectedNew)
{
AreEqual(expectedOld, expectedNew, Financial.FV(Rate, NPer, Pmt, PV, Due));
[ConditionalTheory(nameof(IsNotArmOrAlpine))] // some tests fail due to precision
[InlineData(0, 1.0, 1.0, 0, 0, DueDate.EndOfPeriod, 0, 0)]
[InlineData(0.1 / 12, 12.0, 48.0, -20000.0, 0, DueDate.BegOfPeriod, 133.00409235109, 133.00409235108953)]
- [InlineData(0.008, 4, 12, 3000, 0, 0, -18.2133959841799, -18.21339598417987)]
- [InlineData(0.012, 15, 79, 2387, 200, 1, -24.7440714828291, -24.74407148282907)]
- [InlineData(0.0096, 54, 123, 4760, 0, 0, -32.2391587542905, -32.23915875429054)]
- [InlineData(-0.008, 4, 12, 3000, 0, 0, 17.7814213334481, 17.781421333448126)] // rate < 0
- [InlineData(0, 4, 12, 3000, 0, 0, 0, 0)] // rate = 0
- [InlineData(0.008, 4, 12, 3000, 0, 7, -18.0688452224006, -18.068845222400633)] // type <> 0 and type <> 1
+ [InlineData(0.008, 4, 12, 3000, 0, (DueDate)0, -18.2133959841799, -18.21339598417987)]
+ [InlineData(0.012, 15, 79, 2387, 200, (DueDate)1, -24.7440714828291, -24.74407148282907)]
+ [InlineData(0.0096, 54, 123, 4760, 0, (DueDate)0, -32.2391587542905, -32.23915875429054)]
+ [InlineData(-0.008, 4, 12, 3000, 0, (DueDate)0, 17.7814213334481, 17.781421333448126)] // rate < 0
+ [InlineData(0, 4, 12, 3000, 0, (DueDate)0, 0, 0)] // rate = 0
+ [InlineData(0.008, 4, 12, 3000, 0, (DueDate)7, -18.0688452224006, -18.068845222400633)] // type <> 0 and type <> 1
public void IPmt(double Rate, double Per, double NPer, double PV, double FV, DueDate Due, double expectedOld, double expectedNew)
{
AreEqual(expectedOld, expectedNew, Financial.IPmt(Rate, Per, NPer, PV, FV, Due));
}
[Theory]
- [InlineData(0.008, -4, 12, 3000, 0, 0)]
- [InlineData(0.008, 4, -12, 3000, 0, 0)]
- [InlineData(0.008, 12, 4, 3000, 0, 0)]
+ [InlineData(0.008, -4, 12, 3000, 0, (DueDate)0)]
+ [InlineData(0.008, 4, -12, 3000, 0, (DueDate)0)]
+ [InlineData(0.008, 12, 4, 3000, 0, (DueDate)0)]
public void IPmt_Invalid(double Rate, double Per, double NPer, double PV, double FV, DueDate Due)
{
Assert.Throws<ArgumentException>(() => Financial.IPmt(Rate, Per, NPer, PV, FV, Due));
[InlineData(0.0096, 1500.0, -70000.0, 10000, DueDate.EndOfPeriod, 55.2706372559078, 55.2706372559078)]
[InlineData(-0.0072, -350.0, 7000.0, 0, DueDate.EndOfPeriod, 18.6174997871788, 18.617499787178836)] // rate < 0
[InlineData(0, -350.0, 7000.0, 0, DueDate.EndOfPeriod, 20, 20)] // rate = 0
- [InlineData(0.0072, -350.0, 7000.0, 0, 7, 21.5052532943763, 21.505253294376303)] // type <> 0 and type <> 1
+ [InlineData(0.0072, -350.0, 7000.0, 0, (DueDate)7, 21.5052532943763, 21.505253294376303)] // type <> 0 and type <> 1
[InlineData(0.0072, -9000.0, 200.0, 0, DueDate.EndOfPeriod, 0.0223039109268324, 0.02230391092683241)] // pmt > pv
public void NPer(double Rate, double Pmt, double PV, double FV, DueDate Due, double expectedOld, double expectedNew)
{
[InlineData(0.0012, 5, 500, 0, DueDate.EndOfPeriod, -100.360287827152, -100.36028782715209)]
[InlineData(-0.007, 25, -3000, 0, DueDate.EndOfPeriod, 109.386677326841, 109.38667732684138)] // rate < 0
[InlineData(0.007, -25, 3000, 0, DueDate.EndOfPeriod, 110.224540233228, 110.22454023322811)] // nper < 0
- [InlineData(0.007, 25, 3000, 0, 7, -130.31235375693, -130.31235375692967)] // type <> 0 and type <> 1
+ [InlineData(0.007, 25, 3000, 0, (DueDate)7, -130.31235375693, -130.31235375692967)] // type <> 0 and type <> 1
[InlineData(0, 25, 3000, 0, DueDate.EndOfPeriod, -120, -120)] // rate = 0
public void Pmt(double Rate, double NPer, double PV, double FV, DueDate Due, double expectedOld, double expectedNew)
{
[InlineData(0.012, 15, 79, 2387, 200, DueDate.BegOfPeriod, -23.1486833595771, -23.14868335957714)]
[InlineData(0.0096, 54, 123, 4760, 0, DueDate.EndOfPeriod, -33.8688007923638, -33.86880079236377)]
[InlineData(-0.008, 4, 12, 3000, 0, DueDate.EndOfPeriod, -254.972824918514, -254.97282491851354)] // rate < 0
- [InlineData(0.008, 4, 12, 3000, 0, 7, -243.03222512529, -243.03222512529004)] // type <> 0 and type <> 1
+ [InlineData(0.008, 4, 12, 3000, 0, (DueDate)7, -243.03222512529, -243.03222512529004)] // type <> 0 and type <> 1
public void PPmt(double Rate, double Per, double NPer, double PV, double FV, DueDate Due, double expectedOld, double expectedNew)
{
AreEqual(expectedOld, expectedNew, Financial.PPmt(Rate, Per, NPer, PV, FV, Due));
}
[Theory]
- [InlineData('\0', "\0")]
- [InlineData('\uffff', "\uffff")]
- [InlineData('a', "a")]
- [InlineData('A', "a")]
- [InlineData('1', "1")]
+ [InlineData('\0', '\0')]
+ [InlineData('\uffff', '\uffff')]
+ [InlineData('a', 'a')]
+ [InlineData('A', 'a')]
+ [InlineData('1', '1')]
public void LCase(char value, char expected)
{
Assert.Equal(expected, Strings.LCase(value));
}
[Theory]
- [InlineData('\0', "\0")]
- [InlineData('\uffff', "\uffff")]
- [InlineData('a', "A")]
- [InlineData('A', "A")]
- [InlineData('1', "1")]
+ [InlineData('\0', '\0')]
+ [InlineData('\uffff', '\uffff')]
+ [InlineData('a', 'A')]
+ [InlineData('A', 'A')]
+ [InlineData('1', '1')]
public void UCase(char value, char expected)
{
Assert.Equal(expected, Strings.UCase(value));
[ActiveIssue(20884, TestPlatforms.AnyUnix)]
[ConditionalTheory(Helpers.IsDrawingSupported)]
- [InlineData(FontStyle.Strikeout | FontStyle.Bold | FontStyle.Italic, true, 255, "@", 700)]
+ [InlineData(FontStyle.Strikeout | FontStyle.Bold | FontStyle.Italic, 255, true, "@", 700)]
[InlineData(FontStyle.Regular, 0, false, "", 400)]
[InlineData(FontStyle.Regular, 10, false, "", 400)]
public void ToLogFont_Invoke_ReturnsExpected(FontStyle fontStyle, byte gdiCharSet, bool gdiVerticalFont, string expectedNamePrefix, int expectedWeight)
[InlineData(999999, PaperKind.Custom)]
[InlineData(int.MaxValue, PaperKind.Custom)]
[InlineData(1 + (int)PaperKind.PrcEnvelopeNumber10Rotated, PaperKind.Custom)]
- public void RawKind_ReturnsExpected(int rawKind, int expectedKind)
+ public void RawKind_ReturnsExpected(int rawKind, PaperKind expectedKind)
{
PaperSize ps = new PaperSize();
ps.RawKind = rawKind;
- Assert.Equal((PaperKind)expectedKind, ps.Kind);
+ Assert.Equal(expectedKind, ps.Kind);
Assert.Equal(rawKind, ps.RawKind);
}
}
[Theory]
- [InlineData(-1)]
- [InlineData(0)]
+ [InlineData((KnownColor)(-1))]
+ [InlineData((KnownColor)0)]
[InlineData(KnownColor.MenuHighlight + 1)]
public void FromOutOfRangeKnownColor(KnownColor known)
{
}
[Theory]
- [InlineData(-1)]
- [InlineData(0)]
+ [InlineData((KnownColor)(-1))]
+ [InlineData((KnownColor)0)]
[InlineData(KnownColor.MenuHighlight + 1)]
public void FromOutOfRangeKnownColorToKnownColor(KnownColor known)
{
}
[Theory]
- [InlineData(-1)]
- [InlineData(0)]
+ [InlineData((KnownColor)(-1))]
+ [InlineData((KnownColor)0)]
[InlineData(KnownColor.MenuHighlight + 1)]
public void IsSystemColorOutOfRangeKnown(KnownColor known)
{
}
[Theory]
- [InlineData(-1)]
- [InlineData(0)]
+ [InlineData((KnownColor)(-1))]
+ [InlineData((KnownColor)0)]
[InlineData(KnownColor.MenuHighlight + 1)]
public void IsKnownColorOutOfRangeKnown(KnownColor known)
{
[Theory]
[InlineData(WatcherChangeTypes.Changed, "C:", "foo.txt")]
[InlineData(WatcherChangeTypes.All, "C:", "foo.txt")]
- [InlineData(0, "", "")]
- [InlineData(0, "", null)]
+ [InlineData((WatcherChangeTypes)0, "", "")]
+ [InlineData((WatcherChangeTypes)0, "", null)]
public static void FileSystemEventArgs_ctor(WatcherChangeTypes changeType, string directory, string name)
{
FileSystemEventArgs args = new FileSystemEventArgs(changeType, directory, name);
Assert.Throws<NullReferenceException>(() => new FileSystemEventArgs((WatcherChangeTypes)0, null, string.Empty));
}
}
-}
\ No newline at end of file
+}
[Theory]
[InlineData(WatcherChangeTypes.Changed, "C:", "foo.txt", "bar.txt")]
[InlineData(WatcherChangeTypes.All, "C:", "foo.txt", "bar.txt")]
- [InlineData(0, "", "", "")]
- [InlineData(0, "", null, null)]
+ [InlineData((WatcherChangeTypes)0, "", "", "")]
+ [InlineData((WatcherChangeTypes)0, "", null, null)]
public static void RenamedEventArgs_ctor(WatcherChangeTypes changeType, string directory, string name, string oldName)
{
RenamedEventArgs args = new RenamedEventArgs(changeType, directory, name, oldName);
[Theory]
[InlineData(WatcherChangeTypes.Changed, "C:", "foo.txt", "bar.txt")]
[InlineData(WatcherChangeTypes.All, "C:", "foo.txt", "bar.txt")]
- [InlineData(0, "", "", "")]
- [InlineData(0, "", null, null)]
+ [InlineData((WatcherChangeTypes)0, "", "", "")]
+ [InlineData((WatcherChangeTypes)0, "", null, null)]
public static void RenamedEventArgs_ctor_OldFullPath(WatcherChangeTypes changeType, string directory, string name, string oldName)
{
RenamedEventArgs args = new RenamedEventArgs(changeType, directory, name, oldName);
Assert.Throws<NullReferenceException>(() => new RenamedEventArgs((WatcherChangeTypes)0, null, string.Empty, string.Empty));
}
}
-}
\ No newline at end of file
+}
[Theory]
[InlineData(~FileAttributes.ReadOnly)]
- [InlineData(-1)]
+ [InlineData((FileAttributes)(-1))]
[PlatformSpecific(TestPlatforms.AnyUnix)] // Unix-invalid file attributes that throw
public void UnixInvalidAttributes_ThrowArgumentException(FileAttributes attr)
{
[Theory]
[InlineData(FileAttributes.Temporary)]
[InlineData(~FileAttributes.ReadOnly)]
- [InlineData(-1)]
+ [InlineData((FileAttributes)(-1))]
[PlatformSpecific(TestPlatforms.Windows)] // Windows-invalid file attributes that throw
public void WindowsInvalidAttributes_ThrowArgumentException(FileAttributes attr)
{
}
[Theory]
- [InlineData(PipeDirection.In, 999)]
- [InlineData(PipeDirection.Out, 999)]
+ [InlineData(PipeDirection.In, (HandleInheritability)999)]
+ [InlineData(PipeDirection.Out, (HandleInheritability)999)]
public static void ServerBadInheritabilityThrows(PipeDirection direction, HandleInheritability inheritability)
{
AssertExtensions.Throws<ArgumentOutOfRangeException>("inheritability", () => new AnonymousPipeServerStream(direction, inheritability));
Assert.Equal(hasEntityBody, request.HasEntityBody);
}
- [Theory]
- [InlineData(100)]
- [InlineData("-100")]
- [InlineData("")]
- [InlineData("abc")]
- [InlineData("9223372036854775808")]
- [ActiveIssue(20294, TargetFrameworkMonikers.Netcoreapp)]
- public async Task ContentLength_ManuallySetInHeaders_ReturnsExpected(string newValue)
- {
- HttpListenerRequest request = await GetRequest("POST", null, new string[] { "Content-Length: 1" }, content: "\r\n");
- Assert.Equal("1", request.Headers["Content-Length"]);
-
- request.Headers.Set("Content-Length", newValue);
- Assert.Equal(newValue, request.Headers["Content-Length"]);
- Assert.Equal(1, request.ContentLength64);
-
- Assert.True(request.HasEntityBody);
- }
-
[Fact]
[ActiveIssue(20294, TargetFrameworkMonikers.Netcoreapp)]
public async Task ContentLength_ManuallyRemovedFromHeaders_DoesNotAffect()
[InlineData(typeof(int))]
[InlineData(typeof(List<>))]
[InlineData(typeof(ModuleTest))]
- public void Assembly(TypeInfo typeInfo)
+ public void Assembly(Type type)
{
+ TypeInfo typeInfo = type.GetTypeInfo();
Module module = typeInfo.Module;
Assert.Equal(typeInfo.Assembly, module.Assembly);
}
[InlineData(AssemblyNameFlags.EnableJITcompileTracking)]
[InlineData(AssemblyNameFlags.PublicKey)]
[InlineData(AssemblyNameFlags.Retargetable)]
- [InlineData(int.MinValue)]
+ [InlineData((AssemblyNameFlags)int.MinValue)]
[InlineData((AssemblyNameFlags)(AssemblyNameFlags.None - 1))]
[InlineData((AssemblyNameFlags)int.MaxValue)]
public void Ctor_AssemblyNameFlags(AssemblyNameFlags assemblyFlags)
[InlineData(
PublicEncodingRules.BER,
typeof(X509KeyUsageCSharpStyle),
- X509KeyUsageCSharpStyle.None,
+ (long)(X509KeyUsageCSharpStyle.None),
"030100")]
[InlineData(
PublicEncodingRules.CER,
typeof(X509KeyUsageCSharpStyle),
- X509KeyUsageCSharpStyle.DecipherOnly | X509KeyUsageCSharpStyle.KeyCertSign,
+ (long)(X509KeyUsageCSharpStyle.DecipherOnly | X509KeyUsageCSharpStyle.KeyCertSign),
"0303070480")]
[InlineData(
PublicEncodingRules.DER,
typeof(X509KeyUsageCSharpStyle),
- X509KeyUsageCSharpStyle.KeyAgreement,
+ (long)(X509KeyUsageCSharpStyle.KeyAgreement),
"03020308")]
[InlineData(
PublicEncodingRules.BER,
typeof(LongFlags),
- LongFlags.Mid | LongFlags.Max,
+ (long)(LongFlags.Mid | LongFlags.Max),
"0309010000000080000002")]
[InlineData(
PublicEncodingRules.CER,
typeof(LongFlags),
- LongFlags.Mid | LongFlags.Min,
+ (long)(LongFlags.Mid | LongFlags.Min),
"0309000000000080000001")]
[InlineData(
PublicEncodingRules.DER,
typeof(LongFlags),
- LongFlags.Min | LongFlags.Max,
+ (long)(LongFlags.Min | LongFlags.Max),
"0309000000000000000003")]
// BER: Unused bits are unmapped, regardless of value.
[InlineData(
PublicEncodingRules.BER,
typeof(X509KeyUsageCSharpStyle),
- X509KeyUsageCSharpStyle.DecipherOnly | X509KeyUsageCSharpStyle.KeyCertSign,
+ (long)(X509KeyUsageCSharpStyle.DecipherOnly | X509KeyUsageCSharpStyle.KeyCertSign),
"030307048F")]
// BER: Trailing zeros are permitted.
[InlineData(
PublicEncodingRules.BER,
typeof(X509KeyUsageCSharpStyle),
- X509KeyUsageCSharpStyle.DecipherOnly | X509KeyUsageCSharpStyle.KeyCertSign | X509KeyUsageCSharpStyle.DataEncipherment,
+ (long)(X509KeyUsageCSharpStyle.DecipherOnly | X509KeyUsageCSharpStyle.KeyCertSign | X509KeyUsageCSharpStyle.DataEncipherment),
"03050014800000")]
// BER: Trailing 0-bits don't have to be declared "unused"
[InlineData(
PublicEncodingRules.BER,
typeof(X509KeyUsageCSharpStyle),
- X509KeyUsageCSharpStyle.DecipherOnly | X509KeyUsageCSharpStyle.KeyCertSign | X509KeyUsageCSharpStyle.DataEncipherment,
+ (long)(X509KeyUsageCSharpStyle.DecipherOnly | X509KeyUsageCSharpStyle.KeyCertSign | X509KeyUsageCSharpStyle.DataEncipherment),
"0303001480")]
public static void VerifyReadNamedBitListEncodings(
PublicEncodingRules ruleSet,
[InlineData(
PublicEncodingRules.BER,
typeof(ULongFlags),
- ULongFlags.Mid | ULongFlags.Max,
+ (ulong)(ULongFlags.Mid | ULongFlags.Max),
"0309000000000080000001")]
[InlineData(
PublicEncodingRules.CER,
typeof(ULongFlags),
- ULongFlags.Min | ULongFlags.Mid,
+ (ulong)(ULongFlags.Min | ULongFlags.Mid),
"0306078000000080")]
[InlineData(
PublicEncodingRules.DER,
typeof(ULongFlags),
- ULongFlags.Min | ULongFlags.Max,
+ (ulong)(ULongFlags.Min | ULongFlags.Max),
"0309008000000000000001")]
public static void VerifyReadNamedBitListEncodings_ULong(
PublicEncodingRules ruleSet,
}
[Theory]
- [InlineData(PublicEncodingRules.BER, 0, "D00100")]
+ [InlineData(PublicEncodingRules.BER, "0", "D00100")]
[InlineData(PublicEncodingRules.BER, "1339673755198158349044581307228491520", "D0100102030405060708090A0B0C0D0E0F00")]
[InlineData(PublicEncodingRules.CER, "320182027492359845421654932427609477120", "D01100F0E0D0C0B0A090807060504030201000")]
[InlineData(PublicEncodingRules.DER, "-1339673755198158349044581307228491520", "D010FEFDFCFBFAF9F8F7F6F5F4F3F2F1F100")]
}
[Theory]
- [InlineData(-1)]
- [InlineData(24)]
+ [InlineData("-1")]
+ [InlineData("24")]
[InlineData("invalid")]
[InlineData("")]
public void SkipHours_GetWithInvalidElementExtension_ThrowsFormatException(string value)
[Theory]
[InlineData(-1)]
- [InlineData(JsonCommentHandling.Allow)]
+ [InlineData((int)JsonCommentHandling.Allow)]
[InlineData(3)]
[InlineData(byte.MaxValue)]
[InlineData(byte.MaxValue + 3)] // Other values, like byte.MaxValue + 1 overflows to 0 (i.e. JsonCommentHandling.Disallow), which is valid.
[Theory]
[InlineData(-1)]
- [InlineData(JsonCommentHandling.Allow)]
+ [InlineData((int)JsonCommentHandling.Allow)]
[InlineData(3)]
[InlineData(byte.MaxValue)]
[InlineData(byte.MaxValue + 3)] // Other values, like byte.MaxValue + 1 overflows to 0 (i.e. JsonCommentHandling.Disallow), which is valid.
[InlineData(10, 20, -1)]
[InlineData(20, 10, 1)]
[InlineData(30, 30, 0)]
- public static void CompareTo(Char8 a, Char8 b, int expectedSign)
+ public static void CompareTo(int a, int b, int expectedSign)
{
- Assert.Equal(expectedSign, Math.Sign(a.CompareTo(b)));
+ Assert.Equal(expectedSign, Math.Sign(((Char8)a).CompareTo((Char8)b)));
}
[Theory]
[InlineData(10, 20, false)]
[InlineData(20, 10, false)]
[InlineData(30, 30, true)]
- public static void OperatorEquals(Char8 a, Char8 b, bool expected)
+ public static void OperatorEquals(int a, int b, bool expected)
{
Assert.Equal(expected, (Char8)a == (Char8)b);
Assert.NotEqual(expected, (Char8)a != (Char8)b);
[InlineData(29, 30, true)]
[InlineData(30, 30, false)]
[InlineData(31, 30, false)]
- public static void OperatorLessThan(Char8 a, Char8 b, bool expected)
+ public static void OperatorLessThan(int a, int b, bool expected)
{
Assert.Equal(expected, (Char8)a < (Char8)b);
Assert.NotEqual(expected, (Char8)a >= (Char8)b);
[InlineData(29, 30, false)]
[InlineData(30, 30, false)]
[InlineData(31, 30, true)]
- public static void OperatorGreaterThan(Char8 a, Char8 b, bool expected)
+ public static void OperatorGreaterThan(int a, int b, bool expected)
{
Assert.Equal(expected, (Char8)a > (Char8)b);
Assert.NotEqual(expected, (Char8)a <= (Char8)b);
[MemberData(nameof(HtmlEncodeData))]
[InlineData(null, null)]
[InlineData(2, "2")]
- public void HtmlEncodeObject(string decoded, string encoded)
+ public void HtmlEncodeObject(object decoded, string encoded)
{
- Assert.Equal(encoded, HttpUtility.HtmlEncode((object)decoded));
+ Assert.Equal(encoded, HttpUtility.HtmlEncode(decoded));
}
[Theory]