MockerBlazorTestBase<(Of <(<'T>)>)> Class
Class MockerBlazorTestBase.
Implements the TestContext
Implements the IMockerBlazorTestHelpers<(Of <(<'T>)>)>
Namespace:
FastMoq.Web.BlazorAssembly: FastMoq.Web (in FastMoq.Web.dll)
Syntax
public abstract class MockerBlazorTestBase<T> : TestContext, IMockerBlazorTestHelpers<T> where T : ComponentBase
Public MustInherit Class MockerBlazorTestBase(Of T As ComponentBase) _ Inherits TestContext _ Implements IMockerBlazorTestHelpers(Of T)
generic<typename T> where T : ComponentBase public ref class MockerBlazorTestBase abstract : public TestContext, IMockerBlazorTestHelpers<T>
Type Parameters
- T
Examples
C#
public class IndexTests : MockerBlazorTestBase<Index> { [Fact] public void Create() => Component.Should().NotBeNull(); }
Examples
C#
protected override Action<TestServiceProvider, IConfiguration, Mocker> ConfigureServices => (services, c, m) => services.AddSingleton<IWeatherForecastService, WeatherForecastService>();
Examples
C#
protected override MockerObservableCollection<string> AuthorizedRoles => new MockerObservableCollection<string>() { "Role1", "Role2"}
Examples
C#
protected override Action<Mocker> SetupComponent => mocker => mocker.SetupHttpMessage(() => new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent("ContextGoesHere")});
Examples
C#
protected override Action<Mocker> SetupComponent => mocker => { mocker.GetMock<IFile>().Setup(f => f.Exists(It.IsAny<string>())).Returns(true); // Add setup to mock. mocker.Initialize<IDirectory>(mock => mock.Setup(d => d.Exists(It.IsAny<string>())).Returns(true)); // Clears existing mocks and set new mock. mocker.GetMock<IDirectory>().Setup(d=>d.Exists("C:\\testfile.txt")).Returns(false); // add setup to existing mock. };
Examples
C#
NavigationManager.History.Count.Should().Be(0); ClickButton("button", () => NavigationManager.History.Count == 1); NavigationManager.History.Count.Should().Be(1); ClickButton("button[id='testbutton']", () => NavigationManager.History.Count == 2); NavigationManager.History.Count.Should().Be(2); ClickButton(FindAllByTag("button").First(x => x.Id == "testbutton"), () => NavigationManager.History.Count == 3); NavigationManager.History.Count.Should().Be(3); ClickButton(FindById("testbutton"), () => NavigationManager.History.Count == 4); NavigationManager.History.Count.Should().Be(4); ClickButton("button", () => NavigationManager.History.Count == 5, Component, TimeSpan.FromSeconds(5)); NavigationManager.History.Count.Should().Be(5); ClickButton(e => e.Id == "testbutton", () => NavigationManager.History.Count == 6); NavigationManager.History.Count.Should().Be(6);
Inheritance Hierarchy
TestContextBase
TestContext
FastMoq.Web.Blazor..::..MockerBlazorTestBase<(Of <(<'T>)>)>