-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathCheckboxWidgetTests.cs
More file actions
56 lines (48 loc) · 1.78 KB
/
CheckboxWidgetTests.cs
File metadata and controls
56 lines (48 loc) · 1.78 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
54
55
56
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.AspNetCore.Mvc.ViewComponents;
using Microsoft.Extensions.DependencyInjection;
using Shouldly;
using Unity.Flex.Web.Views.Shared.Components.CheckboxWidget;
using Unity.Flex.Web.Views.Shared.Components.WorksheetInstanceWidget.ViewModels;
using Volo.Abp.DependencyInjection;
namespace Unity.Flex.Web.Tests.Components
{
[Collection(ComponentTestCollection.Name)]
public class CheckboxWidgetTests
{
private readonly IAbpLazyServiceProvider lazyServiceProvider;
public CheckboxWidgetTests(ComponentTestFixture fixture)
{
lazyServiceProvider = fixture.Services.GetRequiredService<IAbpLazyServiceProvider>();
}
[Fact]
public async Task CheckboxWidgetReturnsCorrectType()
{
// Arrange
var viewContext = new ViewContext
{
HttpContext = new DefaultHttpContext()
};
var viewComponentContext = new ViewComponentContext
{
ViewContext = viewContext
};
var viewComponent = new CheckboxWidget()
{
ViewComponentContext = viewComponentContext,
LazyServiceProvider = lazyServiceProvider
};
// Act
var result = await viewComponent.InvokeAsync(new WorksheetFieldViewModel()
{
Type = Worksheets.CustomFieldType.Checkbox
}
, string.Empty) as ViewViewComponentResult;
CheckboxViewModel? resultModel;
resultModel = result!.ViewData!.Model! as CheckboxViewModel;
// Assert
resultModel!.Field?.Type.ShouldBe(Worksheets.CustomFieldType.Checkbox);
}
}
}