File tree Expand file tree Collapse file tree 8 files changed +154
-0
lines changed
src/Tests/integrationtests
Views/TestOnActionExecuted Expand file tree Collapse file tree 8 files changed +154
-0
lines changed Original file line number Diff line number Diff line change
1
+ namespace Tests . Integration . Mvc . Controllers
2
+ {
3
+ using System . Collections . Generic ;
4
+ using System . Linq ;
5
+ using System . Web . Mvc ;
6
+ using JQDT . Models ;
7
+
8
+ public class TestOnActionExecutedController : Controller
9
+ {
10
+ public ActionResult Index ( )
11
+ {
12
+ return View ( ) ;
13
+ }
14
+
15
+ [ CustomOnActionExecuted ]
16
+ public ActionResult GetData ( )
17
+ {
18
+ var data = new List < OnActionExecutedTestModel > ( ) ;
19
+ for ( int i = 1 ; i <= 5 ; i ++ )
20
+ {
21
+ data . Add ( new OnActionExecutedTestModel { Number = i } ) ;
22
+ }
23
+
24
+ return this . View ( data . AsQueryable ( ) ) ;
25
+ }
26
+ }
27
+
28
+ public class OnActionExecutedTestModel
29
+ {
30
+ public int Number { get ; set ; }
31
+ }
32
+
33
+ public class CustomOnActionExecutedAttribute : JQDT . MVC . JQDataTableAttribute
34
+ {
35
+ public override void OnDataProcessed ( ref object data , RequestInfoModel requestInfoModel )
36
+ {
37
+ var list = ( ( IQueryable < OnActionExecutedTestModel > ) data ) . ToList ( ) ;
38
+ for ( int i = 6 ; i <= 10 ; i ++ )
39
+ {
40
+ list . Add ( new OnActionExecutedTestModel { Number = i } ) ;
41
+ }
42
+
43
+ data = list . AsQueryable ( ) ;
44
+ }
45
+ }
46
+ }
Original file line number Diff line number Diff line change 152
152
<Compile Include =" App_Start\RouteConfig.cs" />
153
153
<Compile Include =" Configuration\SettingsProvider.cs" />
154
154
<Compile Include =" Controllers\HomeController.cs" />
155
+ <Compile Include =" Controllers\TestOnActionExecutedController.cs" />
155
156
<Compile Include =" EntityFrameworkClasses\AppContext.cs" />
156
157
<Compile Include =" Global.asax.cs" >
157
158
<DependentUpon >Global.asax</DependentUpon >
213
214
<Content Include =" Scripts\jquery-3.2.1.slim.min.map" />
214
215
<Content Include =" Scripts\jquery-3.2.1.min.map" />
215
216
<None Include =" Views\Home\AllTypesData.cshtml" />
217
+ <Content Include =" Views\TestOnActionExecuted\Index.cshtml" />
216
218
</ItemGroup >
217
219
<ItemGroup >
218
220
<Folder Include =" App_Data\" />
226
228
<Project >{d845ab6d-1887-4597-9256-148ad0a11459}</Project >
227
229
<Name >JQDT.MVC</Name >
228
230
</ProjectReference >
231
+ <ProjectReference Include =" ..\..\..\JQDT\JQDT.csproj" >
232
+ <Project >{C82E4675-88AB-4B78-8475-F1521BDAE330}</Project >
233
+ <Name >JQDT</Name >
234
+ </ProjectReference >
229
235
<ProjectReference Include =" ..\..\TestData.Data\TestData.Data.csproj" >
230
236
<Project >{F7F12DE8-F3C3-42A4-BBE4-1868D287D388}</Project >
231
237
<Name >TestData.Data</Name >
Original file line number Diff line number Diff line change
1
+
2
+ @{
3
+ ViewBag .Title = " Index" ;
4
+ Layout = " ~/Views/Shared/_Layout.cshtml" ;
5
+ }
6
+
7
+
8
+ @{
9
+ ViewBag .Title = " Index" ;
10
+ Layout = " ~/Views/Shared/_Layout.cshtml" ;
11
+ }
12
+
13
+ <table class =" display" cellspacing =" 0" width =" 100%" >
14
+ <thead >
15
+ <tr >
16
+ <th >Test</th >
17
+ </tr >
18
+ </thead >
19
+
20
+ <tfoot >
21
+ <tr >
22
+ <th >Test</th >
23
+ </tr >
24
+ </tfoot >
25
+ </table >
26
+
27
+ @section Scripts {
28
+ <script >
29
+ var table = $ (' table' ).DataTable ({
30
+ " proccessing" : true ,
31
+ " serverSide" : true ,
32
+ " ajax" : {
33
+ url: " @Url.Action(" GetData" , " TestOnActionExecuted" )" ,
34
+ type: ' POST'
35
+ },
36
+ " columns" : [
37
+ { " data" : " Number" },
38
+ ]
39
+ });
40
+ </script >
41
+ }
42
+
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ public class GlobalConstants
4
4
{
5
5
public const string ServerBaseUrl = "http://localhost:54390/" ;
6
6
public const string AllTypesDataPageRelativeUrl = "Home/AllTypesData/" ;
7
+ public const string OnDataProcessedTestPageRelativeUrl = "TestOnActionExecuted/" ;
7
8
public const int GlobalThreadSleep = 1000 ;
8
9
public const string NotCompletedTest = "Not completed test" ;
9
10
public const string AllTypesModelFullDataUrl = "home/GetFullData" ;
Original file line number Diff line number Diff line change @@ -16,5 +16,10 @@ public IWebPage AllTypesDataPage()
16
16
{
17
17
return new AllTypesDataPage ( this . driver ) ;
18
18
}
19
+
20
+ public IWebPage OnDataExecutedEventTestsPage ( )
21
+ {
22
+ return new OnDataProcessedTestsPage ( this . driver ) ;
23
+ }
19
24
}
20
25
}
Original file line number Diff line number Diff line change
1
+ namespace Tests . SeleniumTests . Pages
2
+ {
3
+ using Common ;
4
+ using OpenQA . Selenium ;
5
+
6
+ public class OnDataProcessedTestsPage : IWebPage
7
+ {
8
+ private readonly IWebDriver driver ;
9
+
10
+ public OnDataProcessedTestsPage ( IWebDriver driver )
11
+ {
12
+ this . driver = driver ;
13
+ }
14
+
15
+ public void GoTo ( string queryString = null )
16
+ {
17
+ this . driver . Navigate ( ) . GoToUrl ( GlobalConstants . ServerBaseUrl + GlobalConstants . OnDataProcessedTestPageRelativeUrl + queryString ) ;
18
+ }
19
+ }
20
+ }
Original file line number Diff line number Diff line change 88
88
<Compile Include =" ExtensionMethods\EnumerableExtensionMethods.cs" />
89
89
<Compile Include =" ExtensionMethods\SearchContextExtensionMethods.cs" />
90
90
<Compile Include =" Models\MinMaxRandomModel.cs" />
91
+ <Compile Include =" Pages\OnDataProcessedTestsPage.cs" />
91
92
<Compile Include =" TestsSetupClass.cs" />
92
93
<Compile Include =" Pages\AllTypesDataPage.cs" />
93
94
<Compile Include =" Pages\IWebPage.cs" />
94
95
<Compile Include =" Properties\AssemblyInfo.cs" />
95
96
<Compile Include =" Tests\ColumnFiltersIntegrationTests.cs" />
96
97
<Compile Include =" Tests\CustomFiltersIntegrationTests.cs" />
98
+ <Compile Include =" Tests\OnActionExecutedIntegrationTests.cs" />
97
99
<Compile Include =" Tests\SearchIntegrationTests.cs" />
98
100
<Compile Include =" Tests\SortDataIntegrationTests.cs" />
99
101
</ItemGroup >
Original file line number Diff line number Diff line change
1
+ using System . Linq ;
2
+ using NUnit . Framework ;
3
+ using OpenQA . Selenium ;
4
+ using Tests . SeleniumTests . Common ;
5
+
6
+ namespace Tests . SeleniumTests . Tests
7
+ {
8
+ public class OnActionExecutedIntegrationTests
9
+ {
10
+ private IWebDriver driver ;
11
+
12
+ private Navigator navigator ;
13
+
14
+ [ SetUp ]
15
+ public void SetUp ( )
16
+ {
17
+ this . driver = DriverSingletonProvider . GetDriver ( ) ;
18
+ this . navigator = new Navigator ( driver ) ;
19
+ }
20
+
21
+ [ Test ]
22
+ public void ExpectToAddAdditionalDataFromOnActionExecutedEvent ( )
23
+ {
24
+ navigator . OnDataExecutedEventTestsPage ( ) . GoTo ( ) ;
25
+ var table = new TableElement ( "table" , this . driver ) ;
26
+ var actualValues = table . GetColumnRowValuesUntilAny ( "Test" ) ;
27
+
28
+ var expectedValues = Enumerable . Range ( 1 , 10 ) . Select ( x => x . ToString ( ) ) ;
29
+ Assert . IsTrue ( expectedValues . SequenceEqual ( actualValues ) ) ;
30
+ }
31
+ }
32
+ }
You can’t perform that action at this time.
0 commit comments