Skip to content

Instantly share code, notes, and snippets.

@richarth
Created October 29, 2019 16:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save richarth/d9d556289ede1582f705030747595f65 to your computer and use it in GitHub Desktop.
Save richarth/d9d556289ede1582f705030747595f65 to your computer and use it in GitHub Desktop.
An example xUnit test where dispose is not called when running multiple tests at once.
using ApprovalTests;
using ApprovalTests.Namers;
using ApprovalTests.Reporters;
using ApprovalTests.Reporters.TestFrameworks;
using Moq;
using RazorGenerator.Testing;
using Umbraco.Core.Composing;
using Xunit;
using Xunit.Abstractions;
namespace Website.Tests
{
[UseReporter(typeof(XUnit2Reporter))]
public class BannerTests : TestBase
{
private static BannersController controller;
private static ASP._Views_Partials_Banners_HomepageBannerListing_cshtml homepageBannersView;
public BannerTests(ITestOutputHelper output)
: base(output)
{
Current.Factory = new Mock<IFactory>().Object;
homepageBannersView = new ASP._Views_Partials_Banners_HomepageBannerListing_cshtml();
}
public override void Dispose()
{
Current.Reset();
}
[Fact]
[UseApprovalSubdirectory("ApprovedHtml")]
public void VerifyHomepageListingHandlesNullBanners()
{
var renderedView = homepageBannersView.Render(null);
Approvals.VerifyHtml(renderedView);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment