From 97f6b54256c2d31d60a84758273e5373377f5576 Mon Sep 17 00:00:00 2001 From: Bratchikov Igor Date: Wed, 25 Nov 2020 18:44:06 +0500 Subject: [PATCH 1/2] Add stopwatch in tests for 3s elapsed time --- .../BaseODataServiceIntegratedTest.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseODataServiceIntegratedTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseODataServiceIntegratedTest.cs index f66fc426..6b0a3f88 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseODataServiceIntegratedTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseODataServiceIntegratedTest.cs @@ -1,6 +1,7 @@ namespace NewPlatform.Flexberry.ORM.ODataService.Tests { using System; + using System.Diagnostics; using System.IO; using System.Net; using System.Net.Http; @@ -115,7 +116,11 @@ public virtual void ActODataService(Action action) token.Events.CallbackAfterInternalServerError = AfterInternalServerError; var args = new TestArgs { UnityContainer = container, DataService = dataService, HttpClient = client, Token = token }; ExternalLangDef.LanguageDef.DataService = dataService; + Stopwatch stopwatch = new Stopwatch(); + stopwatch.Start(); action(args); + stopwatch.Stop(); + Assert.True(stopwatch.ElapsedMilliseconds < 3000); } } } From 0f9edd803a78af3a2709735b688023a718bac8d7 Mon Sep 17 00:00:00 2001 From: Ilya Naydanov Date: Thu, 6 Apr 2023 17:23:28 +0500 Subject: [PATCH 2/2] improve test message Better assert message. NetCoreApp target is also tested. --- .../BaseODataServiceIntegratedTest.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseODataServiceIntegratedTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseODataServiceIntegratedTest.cs index 75a36db3..a6d31727 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseODataServiceIntegratedTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseODataServiceIntegratedTest.cs @@ -32,6 +32,7 @@ #if NETCOREAPP using NewPlatform.Flexberry.ORM.ODataService.Routing; using ODataServiceSample.AspNetCore; + using System.Runtime.CompilerServices; #endif /// @@ -40,7 +41,7 @@ public class BaseODataServiceIntegratedTest : BaseIntegratedTest { protected IDataObjectEdmModelBuilder _builder; - + public class TestArgs { public IUnityContainer UnityContainer { get; set; } @@ -151,7 +152,7 @@ public virtual void ActODataService(Action action) stopwatch.Start(); action(args); stopwatch.Stop(); - Assert.True(stopwatch.ElapsedMilliseconds < 3000); + Assert.True(stopwatch.ElapsedMilliseconds < 3000, $"Operation took longer than 3000ms ({stopwatch.ElapsedMilliseconds}ms). Probably a performance issue."); } } } @@ -186,7 +187,12 @@ public virtual void ActODataService(Action action) var args = new TestArgs { UnityContainer = container, DataService = dataService, HttpClient = client, Token = token }; ExternalLangDef.LanguageDef.DataService = dataService; + + Stopwatch stopwatch = new Stopwatch(); + stopwatch.Start(); action(args); + stopwatch.Stop(); + Assert.True(stopwatch.ElapsedMilliseconds < 3000, $"Operation took longer than 3000ms ({stopwatch.ElapsedMilliseconds}ms). Probably a performance issue."); } } #endif