-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add WithSeleniumReporting extension method (#33)
Closes #32
- Loading branch information
Showing
6 changed files
with
366 additions
and
28 deletions.
There are no files selected for viewing
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
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
82 changes: 82 additions & 0 deletions
82
src/Tranquire.Selenium.Tests/Extensions/SeleniumReporterTests.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,82 @@ | ||
using AutoFixture.Idioms; | ||
using FluentAssertions; | ||
using Moq; | ||
using System; | ||
using Tranquire.Reporting; | ||
using Tranquire.Selenium.Extensions; | ||
using Tranquire.Tests; | ||
using Xunit; | ||
|
||
namespace Tranquire.Selenium.Tests.Extensions | ||
{ | ||
public class SeleniumReporterTests | ||
{ | ||
[Theory, DomainAutoData] | ||
public void Sut_VerifyGuardClause(GuardClauseAssertion assertion) | ||
{ | ||
assertion.Verify(typeof(SeleniumReporter)); | ||
} | ||
|
||
[Theory, DomainAutoData] | ||
public void Sut_VerifyConstructorInitializedMembers(ConstructorInitializedMemberAssertion assertion) | ||
{ | ||
assertion.Verify<SeleniumReporter>(r => r.ScreenshotInfoObserver); | ||
assertion.Verify<SeleniumReporter>(r => r.XmlDocumentObserver); | ||
} | ||
|
||
[Theory, DomainAutoData] | ||
public void Sut_IsSeleniumReporter(SeleniumReporter sut) | ||
{ | ||
sut.Should().BeAssignableTo<ISeleniumReporter>(); | ||
} | ||
|
||
[Theory, DomainAutoData] | ||
public void GetXmlDocument_ShouldReturnCorrectValue( | ||
SeleniumReporter sut, | ||
XmlDocumentObserver expectedDocumentObserver, | ||
INamed named) | ||
{ | ||
// arrange | ||
SetupObserver(expectedDocumentObserver, named); | ||
SetupObserver(sut.XmlDocumentObserver, named); | ||
var expected = expectedDocumentObserver.GetXmlDocument(); | ||
// act | ||
var actual = sut.GetXmlDocument(); | ||
// assert | ||
actual.ToString().Should().Be(expected.ToString()); | ||
} | ||
|
||
[Theory, DomainAutoData] | ||
public void GetHtmlDocument_ShouldReturnCorrectValue( | ||
SeleniumReporter sut, | ||
XmlDocumentObserver expectedDocumentObserver, | ||
INamed named) | ||
{ | ||
// arrange | ||
SetupObserver(expectedDocumentObserver, named); | ||
SetupObserver(sut.XmlDocumentObserver, named); | ||
var expected = expectedDocumentObserver.GetHtmlDocument(); | ||
// act | ||
var actual = sut.GetHtmlDocument(); | ||
// assert | ||
actual.Should().Be(expected); | ||
} | ||
|
||
private static void SetupObserver(XmlDocumentObserver expectedDocumentObserver, INamed named) | ||
{ | ||
expectedDocumentObserver.OnNext(new ActionNotification(named, 0, new BeforeActionNotificationContent(DateTimeOffset.MinValue, CommandType.Action))); | ||
expectedDocumentObserver.OnNext(new ActionNotification(named, 0, new AfterActionNotificationContent(TimeSpan.FromSeconds(1)))); | ||
} | ||
|
||
[Theory, DomainAutoData] | ||
public void SaveScreenshots_ShouldCallOnCompleted( | ||
SeleniumReporter sut) | ||
{ | ||
// arrange | ||
// act | ||
sut.SaveScreenshots(); | ||
// assert | ||
Mock.Get(sut.ScreenshotInfoObserver).Verify(s => s.OnCompleted()); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.