Skip to content

Commit

Permalink
Upgrade NUnit to 3.8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
atifaziz committed Nov 28, 2017
1 parent ad57df8 commit e10341d
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 65 deletions.
4 changes: 2 additions & 2 deletions src/Fizzler.Tests/ElementSelector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ public void Basic_Positive_Precedence_Within_Form()
Assert.AreEqual(1, SelectList("form input").Count);
}

[Test,ExpectedException(typeof(FormatException))]
[Test]
public void Type_Star()
{
SelectList("a*");
Assert.Throws<FormatException>(() => SelectList("a*"));
}
}
}
2 changes: 1 addition & 1 deletion src/Fizzler.Tests/Fizzler.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="HtmlAgilityPack" Version="1.5.1" />
<PackageReference Include="NUnit" Version="2.6.2" />
<PackageReference Include="NUnit" Version="3.8.1" />
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
Expand Down
5 changes: 3 additions & 2 deletions src/Fizzler.Tests/HumanReadableSelectorGeneratorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ public class TestHumanReadableSelectorGenerator : HumanReadableSelectorGenerator
}
}

[Test, ExpectedException(typeof(ArgumentNullException))]
[Test]
public void Null_Selector()
{
var generator = new TestHumanReadableSelectorGenerator();
generator.Add(null);
var e = Assert.Throws<ArgumentNullException>(() => generator.Add(null));
Assert.That(e.ParamName, Is.EqualTo("selector"));
}

[Test]
Expand Down
54 changes: 36 additions & 18 deletions src/Fizzler.Tests/ReaderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,20 @@ namespace Fizzler.Tests
[TestFixture]
public class ReaderTests
{
[Test, ExpectedException(typeof(ArgumentNullException))]
[Test]
public void NullEnumeratorInitialization()
{
new Reader<int>((IEnumerator<int>)null);
var e = Assert.Throws<ArgumentNullException>(() =>
new Reader<int>((IEnumerator<int>)null));
Assert.That(e.ParamName, Is.EqualTo("e"));
}

[Test, ExpectedException(typeof(ArgumentNullException))]
[Test]
public void NullEnumerableInitialization()
{
new Reader<int>((IEnumerable<int>)null);
var e = Assert.Throws<ArgumentNullException>(() =>
new Reader<int>((IEnumerable<int>)null));
Assert.That(e.ParamName, Is.EqualTo("e"));
}

[Test]
Expand All @@ -57,10 +61,11 @@ public void HasMoreWhenNotEmpty()
Assert.IsTrue(new Reader<int>(new int[1]).HasMore);
}

[Test, ExpectedException(typeof(InvalidOperationException))]
[Test]
public void ReadEmpty()
{
new Reader<int>(new int[0]).Read();
Assert.Throws<InvalidOperationException>(() =>
new Reader<int>(new int[0]).Read());
}

[Test]
Expand All @@ -77,10 +82,11 @@ public void Unreading()
Assert.AreEqual(910, reader.Read());
}

[Test, ExpectedException(typeof(InvalidOperationException))]
[Test]
public void PeekEmpty()
{
new Reader<int>(new int[0]).Peek();
Assert.Throws<InvalidOperationException>(() =>
new Reader<int>(new int[0]).Peek());
}

[Test]
Expand Down Expand Up @@ -151,34 +157,46 @@ public void DisposeDisposesOnce()
Assert.AreEqual(1, e.DisposeCallCount);
}

[Test, ExpectedException(typeof(ObjectDisposedException))]
[Test]
public void HasMoreDisposed()
{
var unused = CreateDisposedReader<int>().HasMore;
var e = Assert.Throws<ObjectDisposedException>(() =>
{
var unused = CreateDisposedReader<int>().HasMore;
});
Assert.That(e.ObjectName, Is.EqualTo(typeof(Reader<>).Name));
}

[Test, ExpectedException(typeof(ObjectDisposedException))]
[Test]
public void ReadDisposed()
{
CreateDisposedReader<int>().Read();
var e = Assert.Throws<ObjectDisposedException>(() =>
CreateDisposedReader<int>().Read());
Assert.That(e.ObjectName, Is.EqualTo(typeof(Reader<>).Name));
}

[Test, ExpectedException(typeof(ObjectDisposedException))]
[Test]
public void UnreadDisposed()
{
CreateDisposedReader<int>().Unread(42);
var e = Assert.Throws<ObjectDisposedException>(() =>
CreateDisposedReader<int>().Unread(42));
Assert.That(e.ObjectName, Is.EqualTo(typeof(Reader<>).Name));
}

[Test, ExpectedException(typeof(ObjectDisposedException))]
[Test]
public void PeekDisposed()
{
CreateDisposedReader<int>().Peek();
var e = Assert.Throws<ObjectDisposedException>(() =>
CreateDisposedReader<int>().Peek());
Assert.That(e.ObjectName, Is.EqualTo(typeof(Reader<>).Name));
}

[Test, ExpectedException(typeof(ObjectDisposedException))]
[Test]
public void EnumerateDisposed()
{
CreateDisposedReader<int>().GetEnumerator();
var e = Assert.Throws<ObjectDisposedException>(() =>
CreateDisposedReader<int>().GetEnumerator());
Assert.That(e.ObjectName, Is.EqualTo(typeof(Reader<>).Name));
}

private static Reader<T> CreateDisposedReader<T>()
Expand Down
16 changes: 8 additions & 8 deletions src/Fizzler.Tests/SelectorGeneratorTeeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,20 @@ public void Setup()
tee = new SelectorGeneratorTee(primary, secondary);
}

[Test, ExpectedException(typeof(ArgumentNullException))]
[Test]
public void NullPrimary()
{
new SelectorGeneratorTee(
null, new FakeSelectorGenerator()
);
var e = Assert.Throws<ArgumentNullException>(() =>
new SelectorGeneratorTee(null, new FakeSelectorGenerator()));
Assert.That(e.ParamName, Is.EqualTo("primary"));
}

[Test, ExpectedException(typeof(ArgumentNullException))]
[Test]
public void NullSecondary()
{
new SelectorGeneratorTee(
new FakeSelectorGenerator(), null
);
var e = Assert.Throws<ArgumentNullException>(() =>
new SelectorGeneratorTee(new FakeSelectorGenerator(), null));
Assert.That(e.ParamName, Is.EqualTo("secondary"));
}

[Test]
Expand Down
48 changes: 28 additions & 20 deletions src/Fizzler.Tests/TokenTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,18 @@ public void Ident()
AssertToken(TokenKind.Ident, "foo", Token.Ident("foo"));
}

[Test,ExpectedException(typeof(ArgumentNullException))]
[Test]
public void IdentNullText()
{
Token.Ident(null);
var e = Assert.Throws<ArgumentNullException>(() => Token.Ident(null));
Assert.That(e.ParamName, Is.EqualTo("text"));
}

[Test, ExpectedException(typeof(ArgumentException))]
[Test]
public void IdentEmptyText()
{
Token.Ident(string.Empty);
var e = Assert.Throws<ArgumentException>(() => Token.Ident(string.Empty));
Assert.That(e.ParamName, Is.EqualTo("text"));
}

[Test]
Expand All @@ -142,16 +144,18 @@ public void Hash()
AssertToken(TokenKind.Hash, "foo", Token.Hash("foo"));
}

[Test, ExpectedException(typeof(ArgumentNullException))]
[Test]
public void HashNullText()
{
Token.Hash(null);
var e = Assert.Throws<ArgumentNullException>(() => Token.Hash(null));
Assert.That(e.ParamName, Is.EqualTo("text"));
}

[Test, ExpectedException(typeof(ArgumentException))]
[Test]
public void HashEmptyText()
{
Token.Hash(string.Empty);
var e = Assert.Throws<ArgumentException>(() => Token.Hash(string.Empty));
Assert.That(e.ParamName, Is.EqualTo("text"));
}

[Test]
Expand All @@ -177,50 +181,54 @@ public void Function()
AssertToken(TokenKind.Function, "foo", Token.Function("foo"));
}

[Test, ExpectedException(typeof(ArgumentNullException))]
[Test]
public void FunctionNullText()
{
Token.Function(null);
var e = Assert.Throws<ArgumentNullException>(() => Token.Function(null));
Assert.That(e.ParamName, Is.EqualTo("text"));
}

[Test, ExpectedException(typeof(ArgumentException))]
[Test]
public void FunctionEmptyText()
{
Token.Function(string.Empty);
var e = Assert.Throws<ArgumentException>(() => Token.Function(string.Empty));
Assert.That(e.ParamName, Is.EqualTo("text"));
}

public void WhiteSpace()
{
AssertToken(TokenKind.WhiteSpace, " \n ", Token.WhiteSpace("foo"));
}

[Test, ExpectedException(typeof(ArgumentNullException))]
[Test]
public void WhiteSpaceNullText()
{
Token.WhiteSpace(null);
Assert.Throws<ArgumentNullException>(() => Token.WhiteSpace(null));
}

[Test, ExpectedException(typeof(ArgumentException))]
[Test]
public void WhiteSpaceEmptyText()
{
Token.WhiteSpace(string.Empty);
Assert.Throws<ArgumentException>(() => Token.WhiteSpace(string.Empty));
}

public void Integer()
{
AssertToken(TokenKind.Integer, "123", Token.Integer("123"));
}

[Test, ExpectedException(typeof(ArgumentNullException))]
[Test]
public void IntegerNullText()
{
Token.Integer(null);
var e = Assert.Throws<ArgumentNullException>(() => Token.Integer(null));
Assert.That(e.ParamName, Is.EqualTo("text"));
}

[Test, ExpectedException(typeof(ArgumentException))]
[Test]
public void IntegerEmptyText()
{
Token.Integer(string.Empty);
var e = Assert.Throws<ArgumentException>(() => Token.Integer(string.Empty));
Assert.That(e.ParamName, Is.EqualTo("text"));
}

private static void AssertToken(TokenKind kindExpected, Token token)
Expand Down
36 changes: 22 additions & 14 deletions src/Fizzler.Tests/TokenerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,11 @@ public void IdentifierUsingVendorExtensionSyntax()
Assert.AreEqual(Token.Ident("-foo-BAR-42"), Tokener.Tokenize("-foo-BAR-42").First());
}

[Test, ExpectedException(typeof(FormatException))]
[Test]
public void IdentifierUsingVendorExtensionSyntaxCannotBeginWithDigit()
{
Tokener.Tokenize("-42").ToArray();
Assert.Throws<FormatException>(() =>
Tokener.Tokenize("-42").ToArray());
}

[Test]
Expand Down Expand Up @@ -236,10 +237,11 @@ public void BracketedIdent()
Assert.IsFalse(token.MoveNext());
}

[Test, ExpectedException(typeof(FormatException))]
[Test]
public void BadHash()
{
Tokener.Tokenize("#").ToArray();
Assert.Throws<FormatException>(() =>
Tokener.Tokenize("#").ToArray());
}

[Test]
Expand Down Expand Up @@ -316,28 +318,33 @@ public void TildeWhitespacePrepended()
Assert.AreEqual(TokenKind.Tilde, Tokener.Tokenize(" ~").First().Kind);
}

[Test,ExpectedException(typeof(FormatException))]
[Test]
public void StringSingleQuoteUnterminated()
{
Tokener.Tokenize("'foo").ToArray();
Assert.Throws<FormatException>(() =>
Tokener.Tokenize("'foo").ToArray());
}

[Test, ExpectedException(typeof(FormatException))]
[Test]
public void StringDoubleQuoteUnterminated()
{
Tokener.Tokenize("\"foo").ToArray();
Assert.Throws<FormatException>(() =>
Tokener.Tokenize("\"foo").ToArray());
}

[Test, ExpectedException(typeof(FormatException))]
[Test]
public void StringInvalidEscaping()
{
Tokener.Tokenize(@"'f\oo").ToArray();
Assert.Throws<FormatException>(() =>
Tokener.Tokenize(@"'f\oo").ToArray());
}

[Test, ExpectedException(typeof(ArgumentNullException))]
[Test]
public void NullReader()
{
Tokener.Tokenize((TextReader) null);
var e = Assert.Throws<ArgumentNullException>(() =>
Tokener.Tokenize((TextReader) null));
Assert.That(e.ParamName, Is.EqualTo("reader"));
}

[Test]
Expand All @@ -347,10 +354,11 @@ public void StringReader()
Tokener.Tokenize(new StringReader("123,*")).ToArray());
}

[Test, ExpectedException(typeof(FormatException))]
[Test]
public void InvalidChar()
{
Tokener.Tokenize("what?").ToArray();
Assert.Throws<FormatException>(() =>
Tokener.Tokenize("what?").ToArray());
}
}
}

0 comments on commit e10341d

Please sign in to comment.