From 2128814db1bea8679b18469c58d85f44cc591f62 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Wed, 20 Apr 2022 17:31:16 +0100 Subject: [PATCH] [ci skip] Use explicit type in tests --- X10D.Tests/src/Core/BooleanTests.cs | 9 ++++++--- X10D.Tests/src/Core/CharTests.cs | 2 +- X10D.Tests/src/Core/IsPrimeTests.cs | 18 +++++++++--------- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/X10D.Tests/src/Core/BooleanTests.cs b/X10D.Tests/src/Core/BooleanTests.cs index df2a850..7f01f63 100644 --- a/X10D.Tests/src/Core/BooleanTests.cs +++ b/X10D.Tests/src/Core/BooleanTests.cs @@ -1,4 +1,4 @@ -using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.VisualStudio.TestTools.UnitTesting; namespace X10D.Tests.Core { @@ -20,8 +20,11 @@ namespace X10D.Tests.Core var trueBytes = new byte[] { 0x01 }; var falseBytes = new byte[] { 0x00 }; - var trueResult = trueValue.GetBytes(); - var falseResult = falseValue.GetBytes(); + byte[] trueResult = trueValue.GetBytes(); + byte[] falseResult = falseValue.GetBytes(); + + Assert.AreEqual(1, trueResult.Length); + Assert.AreEqual(1, trueResult.Length); CollectionAssert.AreEqual(trueBytes, trueResult); CollectionAssert.AreEqual(falseBytes, falseResult); diff --git a/X10D.Tests/src/Core/CharTests.cs b/X10D.Tests/src/Core/CharTests.cs index e973ceb..c2a8360 100644 --- a/X10D.Tests/src/Core/CharTests.cs +++ b/X10D.Tests/src/Core/CharTests.cs @@ -15,7 +15,7 @@ namespace X10D.Tests.Core const int repeatCount = 10; const string repeated = "aaaaaaaaaa"; - var result = character.Repeat(repeatCount); + string result = character.Repeat(repeatCount); Assert.AreEqual(repeated, result); Assert.ThrowsException(() => character.Repeat(-1)); diff --git a/X10D.Tests/src/Core/IsPrimeTests.cs b/X10D.Tests/src/Core/IsPrimeTests.cs index dfe4dab..cbba572 100644 --- a/X10D.Tests/src/Core/IsPrimeTests.cs +++ b/X10D.Tests/src/Core/IsPrimeTests.cs @@ -35,8 +35,8 @@ namespace X10D.Tests.Core { for (var index = 0; index < _primeNumbers.Count; index++) { - var value = _primeNumbers[index]; - var result = value.IsPrime(); + int value = _primeNumbers[index]; + bool result = value.IsPrime(); Assert.IsTrue(result, value.ToString("N0", CultureInfo.InvariantCulture)); } } @@ -49,7 +49,7 @@ namespace X10D.Tests.Core { for (var value = short.MinValue; value < 0; value++) { - var result = value.IsPrime(); + bool result = value.IsPrime(); Assert.IsFalse(result, value.ToString("N0", CultureInfo.InvariantCulture)); } } @@ -62,7 +62,7 @@ namespace X10D.Tests.Core { for (var value = 0; value < 2; value++) { - var result = value.IsPrime(); + bool result = value.IsPrime(); Assert.IsFalse(result, value.ToString("N0", CultureInfo.InvariantCulture)); } } @@ -75,8 +75,8 @@ namespace X10D.Tests.Core { for (var value = 0; value < 7920; value++) { - var expected = _primeNumbers.Contains(value); - var actual = value.IsPrime(); + bool expected = _primeNumbers.Contains(value); + bool actual = value.IsPrime(); Assert.AreEqual(expected, actual, value.ToString("N0", CultureInfo.InvariantCulture)); } @@ -90,8 +90,8 @@ namespace X10D.Tests.Core { for (byte value = 0; value < byte.MaxValue; value++) { - var expected = _primeNumbers.Contains(value); - var actual = value.IsPrime(); + bool expected = _primeNumbers.Contains(value); + bool actual = value.IsPrime(); Assert.AreEqual(expected, actual, value.ToString("N0", CultureInfo.InvariantCulture)); } @@ -107,7 +107,7 @@ namespace X10D.Tests.Core while (reader.ReadLine() is { } line) { - if (int.TryParse(line, out var prime)) + if (int.TryParse(line, out int prime)) { primes.Add(prime); }