-
Notifications
You must be signed in to change notification settings - Fork 6
/
DatabaseSnapshotTests.cs
42 lines (36 loc) · 1.72 KB
/
DatabaseSnapshotTests.cs
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
30
31
32
33
34
35
36
37
38
39
40
41
42
using Lombiq.Tests.UI.BasicOrchardFeaturesTesting;
using Lombiq.Tests.UI.Extensions;
using Lombiq.Tests.UI.Samples.Constants;
using System.IO;
using System.Threading.Tasks;
using Xunit;
using Xunit.Abstractions;
namespace Lombiq.Tests.UI.Samples.Tests;
// We can execute tests on already existing databases. To demo this, we will take a snapshot of the running application,
// and use that, because we don't have a pre-beaked database. Normally this feature is used to run tests when there is
// an already existing database, so you don't need to take a snapshot before using the
// "ExecuteTestFromExistingDBAsync()" method.
public class DatabaseSnapshotTests : UITestBase
{
public DatabaseSnapshotTests(ITestOutputHelper testOutputHelper)
: base(testOutputHelper)
{
}
// Here, we set up the application, then we take a snapshot of it, then we use the
// "ExecuteTestFromExistingDBAsync()" to run the test on that. Finally, we test the basic Orchard features to check
// that the application was set up correctly.
[Fact]
public async Task BasicOrchardFeaturesShouldWorkWithExistingDatabase()
{
var appForDatabaseTestFolder = Path.Combine("Temp", "AppForDatabaseTest");
await ExecuteTestAsync(
async context =>
{
await context.GoToSetupPageAndSetupOrchardCoreAsync(RecipeIds.BasicOrchardFeaturesTests);
await context.Application.TakeSnapshotAsync(appForDatabaseTestFolder);
});
await ExecuteTestFromExistingDBAsync(context => context.TestBasicOrchardFeaturesExceptSetupAsync(), appForDatabaseTestFolder);
}
}
// END OF TRAINING SECTION: Database snapshot tests.
// NEXT STATION: Head over to Tests/MultiBrowserTests.cs.