-
-
Notifications
You must be signed in to change notification settings - Fork 382
Expand file tree
/
Copy pathThemeProviderTest.cs
More file actions
35 lines (31 loc) · 1.22 KB
/
ThemeProviderTest.cs
File metadata and controls
35 lines (31 loc) · 1.22 KB
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
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the Apache 2.0 License
// See the LICENSE file in the project root for more information.
// Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone
namespace UnitTest.Services;
public class ThemeProviderTest : BootstrapBlazorTestBase
{
[Fact]
public async Task SetTheme_Ok()
{
var themeName = "";
var themeProviderService = Context.Services.GetRequiredService<IThemeProvider>();
themeProviderService.TriggerThemeChanged("light");
themeProviderService.ThemeChangedAsync = async theme =>
{
themeName = theme;
await Task.CompletedTask;
};
await themeProviderService.SetThemeAsync("light");
themeProviderService.TriggerThemeChanged("light");
Assert.Equal("light", themeName);
}
[Fact]
public async Task GetTheme_Ok()
{
Context.JSInterop.Setup<string>("getTheme").SetResult("light");
var themeProviderService = Context.Services.GetRequiredService<IThemeProvider>();
var theme = await themeProviderService.GetThemeAsync();
Assert.Equal("light", theme);
}
}