-
-
Notifications
You must be signed in to change notification settings - Fork 544
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
72 additions
and
3 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
Tests/FluentAssertions.Specs/Execution/AssertionScope.ContextDataSpecs.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
using System; | ||
using FluentAssertions.Execution; | ||
using Xunit; | ||
using Xunit.Sdk; | ||
|
||
namespace FluentAssertions.Specs.Execution | ||
{ | ||
public class ContextDataSpecs | ||
{ | ||
[Fact] | ||
public void Get_value_when_key_is_present() | ||
{ | ||
// Arrange | ||
var scope = new AssertionScope(); | ||
scope.AddNonReportable("SomeKey", "SomeValue"); | ||
scope.AddNonReportable("SomeOtherKey", "SomeOtherValue"); | ||
|
||
// Act | ||
var value = scope.Get<string>("SomeKey"); | ||
|
||
// Assert | ||
value.Should().Be("SomeValue"); | ||
} | ||
|
||
[Fact] | ||
public void Get_default_value_when_key_is_not_present() | ||
{ | ||
// Arrange | ||
var scope = new AssertionScope(); | ||
|
||
// Act | ||
var value = scope.Get<int>("SomeKey"); | ||
|
||
// Assert | ||
value.Should().Be(0); | ||
} | ||
|
||
[Fact] | ||
public void Get_default_value_when_nullable_value_is_null() | ||
{ | ||
// Arrange | ||
var scope = new AssertionScope(); | ||
scope.AddNonReportable("SomeKey", (int?)null); | ||
|
||
// Act | ||
var value = scope.Get<int>("SomeKey"); | ||
|
||
// Assert | ||
value.Should().Be(0); | ||
} | ||
|
||
[Fact] | ||
public void Value_should_be_of_requested_type() | ||
{ | ||
// Arrange | ||
var scope = new AssertionScope(); | ||
scope.AddNonReportable("SomeKey", "SomeValue"); | ||
|
||
// Act | ||
var value = scope.Get<string>("SomeKey"); | ||
|
||
// Assert | ||
value.Should().BeOfType<string>(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters