-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathTextAreaDefinitionWidgetTests.cs
More file actions
57 lines (48 loc) · 1.73 KB
/
TextAreaDefinitionWidgetTests.cs
File metadata and controls
57 lines (48 loc) · 1.73 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
57
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.TextAreaDefinitionWidget;
using Unity.Flex.Worksheets.Definitions;
using Unity.GrantManager;
using Volo.Abp.DependencyInjection;
namespace Unity.Flex.Web.Tests.Components
{
public class TextAreaDefinitionWidgetTests : GrantManagerWebTestBase
{
private readonly IAbpLazyServiceProvider lazyServiceProvider;
public TextAreaDefinitionWidgetTests()
{
lazyServiceProvider = GetRequiredService<IAbpLazyServiceProvider>();
}
[Fact]
public async Task TextAreaDefinitionWidgetReturnsCorrectRowsCount()
{
// Arrange
var viewContext = new ViewContext
{
HttpContext = new DefaultHttpContext()
};
var viewComponentContext = new ViewComponentContext
{
ViewContext = viewContext
};
var viewComponent = new TextAreaDefinitionWidget()
{
ViewComponentContext = viewComponentContext,
LazyServiceProvider = lazyServiceProvider
};
var definition = JsonSerializer.Serialize(new TextAreaDefinition()
{
Rows = 1
});
// Act
var result = await viewComponent.InvokeAsync(definition) as ViewViewComponentResult;
TextAreaDefinitionViewModel? resultModel;
resultModel = result!.ViewData!.Model! as TextAreaDefinitionViewModel;
// Assert
resultModel!.Rows.ToString().ShouldBe("1");
}
}
}