Skip to content

Commit 737542f

Browse files
committed
detach unneeded dependencies from Web project - add extension methods instead
1 parent 4e5e187 commit 737542f

File tree

12 files changed

+70
-25
lines changed

12 files changed

+70
-25
lines changed

src/Bellatrix.Mobile/Bellatrix.Mobile.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@
1616
</ItemGroup>
1717

1818
<ItemGroup>
19+
<ProjectReference Include="..\..\Bellatrix.LLM\Bellatrix.LLM.csproj" />
1920
<ProjectReference Include="..\Bellatrix.Allure\Bellatrix.Results.Allure.csproj" />
21+
<ProjectReference Include="..\Bellatrix.AWS\Bellatrix.AWS.csproj" />
22+
<ProjectReference Include="..\Bellatrix.CognitiveServices\Bellatrix.CognitiveServices.csproj" />
2023
<ProjectReference Include="..\Bellatrix.Core\Bellatrix.Core.csproj" />
2124
<ProjectReference Include="..\Bellatrix.DynamicTestCases\Bellatrix.DynamicTestCases.csproj" />
2225
<ProjectReference Include="..\Bellatrix.Layout\Bellatrix.Layout.csproj" />

src/Bellatrix.Web/Bellatrix.Web.csproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,8 @@
3030
<ProjectReference Include="..\..\Bellatrix.LLM\Bellatrix.LLM.csproj" />
3131
<ProjectReference Include="..\Bellatrix.Allure\Bellatrix.Results.Allure.csproj" />
3232
<ProjectReference Include="..\Bellatrix.Api\Bellatrix.API.csproj" />
33-
<ProjectReference Include="..\Bellatrix.AWS\Bellatrix.AWS.csproj" />
3433
<ProjectReference Include="..\Bellatrix.CognitiveServices\Bellatrix.CognitiveServices.csproj" />
3534
<ProjectReference Include="..\Bellatrix.Core\Bellatrix.Core.csproj" />
36-
<ProjectReference Include="..\Bellatrix.DynamicTestCases\Bellatrix.DynamicTestCases.csproj" />
37-
<ProjectReference Include="..\Bellatrix.ImageRecognition\Bellatrix.ImageRecognition.csproj" />
3835
<ProjectReference Include="..\Bellatrix.KeyVault\Bellatrix.KeyVault.csproj" />
3936
<ProjectReference Include="..\Bellatrix.Layout\Bellatrix.Layout.csproj" />
4037
<ProjectReference Include="..\Bellatrix.Plugins.Screenshots\Bellatrix.Plugins.Screenshots.csproj" />

src/Bellatrix.Web/WebPluginsConfiguration.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
// <site>https://bellatrix.solutions/</site>
1414
using System;
1515
using System.Collections.Generic;
16+
using Bellatrix.DynamicTestCases.core;
17+
using Bellatrix.DynamicTestCases.core.componentHandlers;
1618
using Bellatrix.GoogleLighthouse.MSTest;
1719
using Bellatrix.GoogleLighthouse.NUnit;
1820
using Bellatrix.Layout;

src/Bellatrix.Web/eventhandlers/DynamicTestCases/DynamicTestCasesCheckboxEventHandlers.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@
1111
// </copyright>
1212
// <author>Anton Angelov</author>
1313
// <site>https://bellatrix.solutions/</site>
14+
1415
using Bellatrix.Web.Controls.EventHandlers;
1516
using Bellatrix.Web.Events;
17+
using Bellatrix.Web.Extensions;
1618

17-
namespace Bellatrix.Web.Extensions.Controls.Controls.EventHandlers;
19+
namespace Bellatrix.DynamicTestCases.core.componentHandlers;
1820

1921
public class DynamicTestCasesCheckboxEventHandlers : CheckboxEventHandlers
2022
{

src/Bellatrix.Web/eventhandlers/DynamicTestCases/DynamicTestCasesTextFieldEventHandlers.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@
1111
// </copyright>
1212
// <author>Anton Angelov</author>
1313
// <site>https://bellatrix.solutions/</site>
14+
1415
using Bellatrix.Web.Controls.EventHandlers;
1516
using Bellatrix.Web.Events;
17+
using Bellatrix.Web.Extensions;
1618

17-
namespace Bellatrix.Web.Extensions.Controls.Controls.EventHandlers;
19+
namespace Bellatrix.DynamicTestCases.core;
1820

1921
public class DynamicTestCasesTextFieldEventHandlers : TextFieldEventHandlers
2022
{

src/Bellatrix.Web/infrastructure/App.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
using Bellatrix.Api;
1919
using Bellatrix.Api.Configuration;
2020
using Bellatrix.Assertions;
21-
using Bellatrix.AWS;
22-
using Bellatrix.CognitiveServices;
2321
using Bellatrix.DynamicTestCases;
2422
using Bellatrix.LLM;
2523
using Bellatrix.Plugins;
@@ -51,14 +49,9 @@ public App()
5149
public CookiesService Cookies => ServicesCollection.Current.Resolve<CookiesService>();
5250
public ComponentCreateService Components => ServicesCollection.Current.Resolve<ComponentCreateService>();
5351
public DynamicTestCasesService TestCases => ServicesCollection.Current.Resolve<DynamicTestCasesService>();
54-
public LighthouseService Lighthouse => ServicesCollection.Current.Resolve<LighthouseService>();
55-
public ComputerVision ComputerVision => ServicesCollection.Current.Resolve<ComputerVision>();
56-
public FormRecognizer FormRecognizer => ServicesCollection.Current.Resolve<FormRecognizer>();
5752
public IAssert Assert => ServicesCollection.Current.Resolve<IAssert>();
5853
public ProxyService Proxy => ServicesCollection.Current.Resolve<ProxyService>();
5954

60-
public AWSServicesFactory AWS => ServicesCollection.Current.Resolve<AWSServicesFactory>();
61-
6255
public ApiClientService ApiClient
6356
{
6457
get => _apiClientService;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using Bellatrix.CognitiveServices;
2+
3+
namespace Bellatrix.Web.GettingStarted;
4+
5+
public static partial class AppExtensions
6+
{
7+
extension(App _)
8+
{
9+
public static FormRecognizer FormRecognizer()
10+
{
11+
return ServicesCollection.Current.Resolve<FormRecognizer>();
12+
}
13+
14+
public static ComputerVision ComputerVision()
15+
{
16+
return ServicesCollection.Current.Resolve<ComputerVision>();
17+
}
18+
}
19+
}

templates/Bellatrix.Web.GettingStarted/37. Computer Vision/TextVerificationPDF.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class TextVerificationPDF : NUnit.WebTest
1111
[Ignore("API example purposes only. No need to run.")]
1212
public void MakeTextExtractionFromPDF()
1313
{
14-
var textSnippets = App.ComputerVision.ExtractOCRTextFromLocalFile("sampleinvoice.pdf");
14+
var textSnippets = App.ComputerVision().ExtractOCRTextFromLocalFile("sampleinvoice.pdf");
1515
textSnippets.ForEach(Console.WriteLine);
1616

1717
List<string> expectedTextSnippets = new List<string>()
@@ -23,14 +23,14 @@ public void MakeTextExtractionFromPDF()
2323
"$136.00",
2424
};
2525

26-
App.ComputerVision.ValidateText("sampleinvoice.pdf", "en", expectedTextSnippets);
26+
App.ComputerVision().ValidateText("sampleinvoice.pdf", "en", expectedTextSnippets);
2727
}
2828

2929
[Test]
3030
[Ignore("API example purposes only. No need to run.")]
3131
public void ExtractTextFromGraph()
3232
{
33-
var textSnippets = App.ComputerVision.ExtractOCRTextFromLocalFile("devPortalGraph1.PNG");
33+
var textSnippets = App.ComputerVision().ExtractOCRTextFromLocalFile("devPortalGraph1.PNG");
3434
textSnippets.ForEach(Console.WriteLine);
3535

3636
List<string> expectedTextSnippets = new List<string>()
@@ -39,23 +39,23 @@ public void ExtractTextFromGraph()
3939
"Apr 13 00:00",
4040
};
4141

42-
App.ComputerVision.ValidateText("devPortalGraph1.PNG", "en", expectedTextSnippets);
42+
App.ComputerVision().ValidateText("devPortalGraph1.PNG", "en", expectedTextSnippets);
4343
}
4444

4545
[Test]
4646
[Ignore("API example purposes only. No need to run.")]
4747
public void AssertPdfLayoutBasedOnTemplate()
4848
{
49-
App.FormRecognizer.SaveAnalyzedFileToJson("sampleinvoice.pdf", "analizedFileOutput.json");
49+
App.FormRecognizer().SaveAnalyzedFileToJson("sampleinvoice.pdf", "analizedFileOutput.json");
5050

51-
App.FormRecognizer.ValidateFormLayout("sampleinvoice.pdf", "sampleinvoice1.pdf");
51+
App.FormRecognizer().ValidateFormLayout("sampleinvoice.pdf", "sampleinvoice1.pdf");
5252
}
5353

5454
[Test]
5555
[Ignore("API example purposes only. No need to run.")]
5656
public void AssertCellsText()
5757
{
58-
var analyzedPdf = App.FormRecognizer.Analyze("sampleinvoice.pdf");
58+
var analyzedPdf = App.FormRecognizer().Analyze("sampleinvoice.pdf");
5959
analyzedPdf.AssertLinesCount(48);
6060

6161
analyzedPdf.GetTable().GetCell(0, 3).AssertTextEquals("OF355548 24/1/2014");
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using Bellatrix.CognitiveServices;
2+
3+
namespace Bellatrix.Web.GettingStarted;
4+
5+
public static partial class AppExtensions
6+
{
7+
public static LighthouseService Lighthouse(this App app)
8+
{
9+
return ServicesCollection.Current.Resolve<LighthouseService>();
10+
}
11+
}

templates/Bellatrix.Web.GettingStarted/38. Google Lighthouse/GoogleLighthouseAnalysisTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,18 @@ public void LighthouseAnalysisLogin()
4444
// In the testFrameworkSettings.json file, there is a section called lighthouseSettings.
4545
// There, you can enable/disable the integration + you can set default CLI arguments.
4646
// In the PerformLighthouseAnalysis method, you can add additional arguments merged with the default ones or override them completely.
47-
App.Lighthouse.PerformLighthouseAnalysis();
47+
App.Lighthouse().PerformLighthouseAnalysis();
4848

4949
// BELLATRIX exposes a few assertion methods for most essential metrics.
50-
App.Lighthouse.AssertFirstMeaningfulPaintScoreMoreThan(0.5);
50+
App.Lighthouse().AssertFirstMeaningfulPaintScoreMoreThan(0.5);
5151

5252
// Since there are thousands of possible values that you might be interested in validating, we give you the AssertMetric method.
5353
// Through it, you can use lambda syntax to pick the value that you want to assert. Through Fluent Builder API afterward you need to pick
5454
// what type of assertion you want to perform - equal, greaterThan, lessThan, and so on + the expected value.
5555
// Of course, don't forget to call the Perform method, which will do the actual assertion. The API works pretty much the same as Selenium Actions.
56-
App.Lighthouse.AssertMetric(r => r.Categories.Pwa.Score).LessThan(2.3).Perform();
57-
App.Lighthouse.AssertMetric(r => r.Categories.Performance.Score).GreaterThan(0.5).Perform();
58-
App.Lighthouse.AssertMetric(r => r.Categories.Performance.Score).GreaterThanOrEqual(0.5).Perform();
56+
App.Lighthouse().AssertMetric(r => r.Categories.Pwa.Score).LessThan(2.3).Perform();
57+
App.Lighthouse().AssertMetric(r => r.Categories.Performance.Score).GreaterThan(0.5).Perform();
58+
App.Lighthouse().AssertMetric(r => r.Categories.Performance.Score).GreaterThanOrEqual(0.5).Perform();
5959

6060
Anchor logoutLink = App.Components.CreateByInnerTextContaining<Anchor>("Log out");
6161

0 commit comments

Comments
 (0)