-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathCurrencyDefinitionWidgetTests.cs
More file actions
53 lines (46 loc) · 1.8 KB
/
CurrencyDefinitionWidgetTests.cs
File metadata and controls
53 lines (46 loc) · 1.8 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.AspNetCore.Mvc.ViewComponents;
using Shouldly;
using System.Text.Json;
using Unity.Flex.Web.Views.Shared.Components.CurrencyDefinitionWidget;
using Unity.Flex.Worksheets.Definitions;
using Unity.GrantManager;
using Volo.Abp.DependencyInjection;
namespace Unity.Flex.Web.Tests.Components
{
public class CurrencyDefinitionWidgetTests : GrantManagerWebTestBase
{
private readonly IAbpLazyServiceProvider lazyServiceProvider;
public CurrencyDefinitionWidgetTests()
{
// Lazily resolve services needed by the ViewComponent
lazyServiceProvider = GetRequiredService<IAbpLazyServiceProvider>();
}
[Fact]
public async Task CurrencyDefinitionWidgetReturnsCorrectLimits()
{
// Arrange
var viewContext = new ViewContext
{
HttpContext = new DefaultHttpContext()
};
var viewComponentContext = new ViewComponentContext
{
ViewContext = viewContext
};
var viewComponent = new CurrencyDefinitionWidget
{
ViewComponentContext = viewComponentContext,
LazyServiceProvider = lazyServiceProvider
};
// Act
var result = await viewComponent.InvokeAsync(JsonSerializer.Serialize(new CurrencyDefinition())) as ViewViewComponentResult;
CurrencyDefinitionViewModel? resultModel;
resultModel = result!.ViewData!.Model! as CurrencyDefinitionViewModel;
// Assert
resultModel!.Min.ToString().ShouldBe(decimal.MinValue.ToString());
resultModel!.Max.ToString().ShouldBe(decimal.MaxValue.ToString());
}
}
}