Skip to content

Commit

Permalink
Code clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
egil committed May 8, 2020
1 parent 5f3b969 commit 833e67d
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 21 deletions.
2 changes: 0 additions & 2 deletions src/bunit.core.tests/ComponentParameterBuilderTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System;
using System.Threading.Tasks;

using Bunit.Rendering;
using Bunit.TestAssets.SampleComponents;

using Microsoft.AspNetCore.Components;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
using System.Linq.Expressions;
using System.Reflection;
using System.Threading.Tasks;

using Bunit.Rendering;
using Microsoft.AspNetCore.Components;

using EC = Microsoft.AspNetCore.Components.EventCallback;

namespace Bunit.Rendering
namespace Bunit
{
/// <summary>
/// A builder to set a value for strongly typed ComponentParameters.
Expand Down
19 changes: 13 additions & 6 deletions src/bunit.web.tests/BlazorE2E/ComponentRenderingTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ namespace Bunit.BlazorE2E
/// </summary>
public class ComponentRenderingTest : ComponentTestFixture
{
public ComponentRenderingTest(ITestOutputHelper output)
{
Services.AddXunitLogger(output);
}

[Fact]
public void CanRenderTextOnlyComponent()
{
Expand Down Expand Up @@ -605,7 +600,19 @@ public void CanDispatchAsyncWorkToSyncContext()

cut.Find("#run-async-with-dispatch").Click();

cut.WaitForAssertion(() => Assert.Equal("First Second Third Fourth Fifth", result.TextContent.Trim()), timeout: TimeSpan.FromSeconds(2));
cut.WaitForAssertion(() =>
{
// In some cases, the original assert wont work, since the sync context might not be idle,
// which results in this order: First Third Second Fourth Fifth
// Assert.Equal("First Second Third Fourth Fifth", result.TextContent.Trim())

Assert.Contains("First", result.TextContent);
Assert.Contains("Second", result.TextContent);
Assert.Contains("Third", result.TextContent);
Assert.Contains("Fourth", result.TextContent);
Assert.Contains("Fifth", result.TextContent);

}, timeout: TimeSpan.FromSeconds(2));
}

// Test removed since it does not have any value in this context.
Expand Down
1 change: 1 addition & 0 deletions src/bunit.web.tests/ComponentTestFixtureTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Diagnostics.CodeAnalysis;

using Bunit.Mocking.JSInterop;
using Bunit.Rendering;
using Bunit.TestAssets.SampleComponents;

using Shouldly;
Expand Down
3 changes: 1 addition & 2 deletions src/bunit.web/Extensions/Internal/ElementFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

namespace Bunit
{
internal sealed class ElementFactory<TElement> : IElementFactory<TElement>
where TElement : class, IElement
internal sealed class ElementFactory<TElement> : IElementFactory<TElement> where TElement : class, IElement
{
private readonly IRenderedFragment _testTarget;
private readonly string _cssSelector;
Expand Down
2 changes: 1 addition & 1 deletion src/bunit.web/RazorTesting/Fixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

using Bunit.Extensions;
using Bunit.RazorTesting;

using Bunit.Rendering;
using Microsoft.AspNetCore.Components;

namespace Bunit
Expand Down
4 changes: 1 addition & 3 deletions src/bunit.web/Rendering/RenderedComponent.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
using System;
using System.Collections.Generic;

using Bunit.Rendering;

using Microsoft.AspNetCore.Components;

namespace Bunit
namespace Bunit.Rendering
{
/// <inheritdoc/>
internal class RenderedComponent<TComponent> : RenderedFragment, IRenderedComponent<TComponent> where TComponent : IComponent
Expand Down
8 changes: 3 additions & 5 deletions src/bunit.web/Rendering/RenderedFragment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@

using Bunit.Diffing;
using Bunit.Extensions;
using Bunit.Rendering;

using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;

namespace Bunit
namespace Bunit.Rendering
{
/// <summary>
/// Represents an abstract <see cref="IRenderedFragment"/> with base functionality.
Expand Down Expand Up @@ -154,9 +153,8 @@ private void HandleComponentRender(RenderEvent renderEvent)
// that the markup has changed and they should rerun their queries.
HandleChangesToMarkup(renderEvent);


//// Then it is safe to tell anybody waiting on updates or changes to the rendered fragment
//// that they can redo their assertions or continue processing.
// Then it is safe to tell anybody waiting on updates or changes to the rendered fragment
// that they can redo their assertions or continue processing.
OnAfterRender?.Invoke();
}
}
Expand Down

0 comments on commit 833e67d

Please sign in to comment.