-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPageFactoryTests.cs
More file actions
29 lines (24 loc) · 860 Bytes
/
Copy pathPageFactoryTests.cs
File metadata and controls
29 lines (24 loc) · 860 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
namespace OrchardCoreContrib.Testing.UI.PageObjects.Tests;
public class PageFactoryTests
{
[Fact]
public async Task CreatePage()
{
// Arrange
var baseUrl = "https://localhost:8080";
var browserMock = new Mock<IBrowser>();
browserMock.Setup(b => b.OpenPageAsync(It.IsAny<string>()))
.ReturnsAsync(() => new Page(new PlaywrightPageAccessor(Mock.Of<Microsoft.Playwright.IPage>()), browserMock.Object));
await PageFactory.InitializeAsync(browserMock.Object, baseUrl);
// Act
var page = await PageFactory.CreateAsync<MyPage>();
// Assert
Assert.NotNull(page.Page);
Assert.Equal(baseUrl, page.BaseUrl);
Assert.Equal("/my-page", page.Slug);
}
public class MyPage : PageBase
{
public override string Slug => "/my-page";
}
}