Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion FwLiteOnly.slnf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"backend\\FwLite\\FwDataMiniLcmBridge.Tests\\FwDataMiniLcmBridge.Tests.csproj",
"backend\\FwLite\\FwDataMiniLcmBridge\\FwDataMiniLcmBridge.csproj",
"backend\\FwLite\\FwLiteMaui\\FwLiteMaui.csproj",
"backend\\FwLite\\FwLiteMaui.Tests\\FwLiteMaui.Tests.csproj",
"backend\\FwLite\\FwLiteProjectSync.Tests\\FwLiteProjectSync.Tests.csproj",
"backend\\FwLite\\FwLiteProjectSync\\FwLiteProjectSync.csproj",
"backend\\FwLite\\FwLiteShared\\FwLiteShared.csproj",
Expand All @@ -18,4 +19,4 @@
"backend\\harmony\\src\\SIL.Harmony\\SIL.Harmony.csproj"
]
}
}
}
14 changes: 11 additions & 3 deletions LexBox.sln
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@


Microsoft Visual Studio Solution File, Format Version 12.00
#
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SyncReverseProxy", "backend\SyncReverseProxy\SyncReverseProxy.csproj", "{5C589976-854A-4CE8-A661-A2E256AC2FC4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LexBoxApi", "backend\LexBoxApi\LexBoxApi.csproj", "{A95FC2AC-2B31-4B40-B4DA-6B951ECE3E28}"
Expand All @@ -21,8 +22,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testing", "backend\Testing\
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FixFwData", "backend\FixFwData\FixFwData.csproj", "{D7FC8B93-15A1-4D0B-9EAB-45596DB147F4}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "FwLite", "FwLite", "{7B6E21C4-5AF4-4505-B7D9-59A3886C5090}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "FwLite", "FwLite", "{7B6E21C4-5AF4-4505-B7D9-59A3886C5090}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LfClassicData", "backend\LfClassicData\LfClassicData.csproj", "{E8BB768B-C3DC-4BE6-9B9F-82319E05AF86}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MiniLcm", "backend\FwLite\MiniLcm\MiniLcm.csproj", "{6D4062DC-1B1A-4A24-9C61-0F6A18A39882}"
Expand Down Expand Up @@ -57,6 +58,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FwLiteShared", "backend\FwL
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebServiceDefaults", "backend\WebServiceDefaults\WebServiceDefaults.csproj", "{9B71BEF9-6017-4E30-81E0-EB8126B2CF02}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FwLiteMaui.Tests", "backend\FwLite\FwLiteMaui.Tests\FwLiteMaui.Tests.csproj", "{5A277FCE-454F-4956-8C33-7D9726C4E409}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -157,6 +160,10 @@ Global
{9B71BEF9-6017-4E30-81E0-EB8126B2CF02}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9B71BEF9-6017-4E30-81E0-EB8126B2CF02}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9B71BEF9-6017-4E30-81E0-EB8126B2CF02}.Release|Any CPU.Build.0 = Release|Any CPU
{5A277FCE-454F-4956-8C33-7D9726C4E409}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5A277FCE-454F-4956-8C33-7D9726C4E409}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5A277FCE-454F-4956-8C33-7D9726C4E409}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5A277FCE-454F-4956-8C33-7D9726C4E409}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -178,6 +185,7 @@ Global
{00AE5440-0E36-4488-935B-5B11301BA57D} = {7B6E21C4-5AF4-4505-B7D9-59A3886C5090}
{ECBA46AB-AF87-4D4D-9716-FD77264B817F} = {7B6E21C4-5AF4-4505-B7D9-59A3886C5090}
{73DC604C-C501-410D-B56B-0544AD6EF1C2} = {7B6E21C4-5AF4-4505-B7D9-59A3886C5090}
{5A277FCE-454F-4956-8C33-7D9726C4E409} = {7B6E21C4-5AF4-4505-B7D9-59A3886C5090}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {440AE83C-6DB0-4F18-B2C1-BCD33F0645B6}
Expand Down
36 changes: 36 additions & 0 deletions backend/FwLite/FwLiteMaui.Tests/AutoUpdateTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Moq;

namespace FwLiteMaui.Tests;

using FwLiteMaui;
#if WINDOWS
public class AutoUpdateTests
{
private readonly AppUpdateService _appUpdateService;

public AutoUpdateTests()
{
var services = new ServiceCollection()
.AddFwLiteMauiServices(new ConfigurationManager(), Mock.Of<ILoggingBuilder>())
.AddSingleton(Mock.Of<IPreferences>())
.AddSingleton(Mock.Of<IConnectivity>())
.AddSingleton<AppUpdateService>()
.BuildServiceProvider();
_appUpdateService = services.GetRequiredService<AppUpdateService>();
}

[Theory]
[InlineData(1, false)]
[InlineData(15, false)]
[InlineData(22, true)]
[InlineData(26, true)]
[InlineData(36, true)]
[InlineData(46, true)]
public void ShouldCheckForUpdateAfterThreshold(int hoursInThefuture, bool shouldCheckForUpdate)
{

}
}
#endif
41 changes: 41 additions & 0 deletions backend/FwLite/FwLiteMaui.Tests/FwLiteMaui.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
<!-- override the target framework set in Directory.Build.props, we will use what is defined in TargetFrameworks below instead-->
<TargetFramework/>
<TargetFrameworks>net9.0-android;net9.0-ios;net9.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net9.0-windows10.0.19041.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk"/>
<PackageReference Include="FluentAssertions"/>
<PackageReference Include="Moq" />
<PackageReference Include="xunit"/>
<PackageReference Include="xunit.runner.visualstudio">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="GitHubActionsTestLogger">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.DependencyInjection"/>
</ItemGroup>

<ItemGroup>
<Using Include="Xunit"/>
<Using Include="FluentAssertions"/>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\FwLiteMaui\FwLiteMaui.csproj"/>
</ItemGroup>

</Project>
5 changes: 5 additions & 0 deletions backend/FwLite/FwLiteMaui/FwLiteMaui.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,9 @@
<ProjectReference Include="..\FwDataMiniLcmBridge\FwDataMiniLcmBridge.csproj" />
<ProjectReference Include="..\FwLiteProjectSync\FwLiteProjectSync.csproj" />
</ItemGroup>

<ItemGroup>
<InternalsVisibleTo Include="../FwLiteMaui.Tests/FwLiteMaui.Tests.csproj"/>
</ItemGroup>

</Project>
11 changes: 7 additions & 4 deletions backend/FwLite/FwLiteMaui/FwLiteMauiKernel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace FwLiteMaui;

public static class FwLiteMauiKernel
{
public static void AddFwLiteMauiServices(this IServiceCollection services,
public static IServiceCollection AddFwLiteMauiServices(this IServiceCollection services,
ConfigurationManager configuration,
ILoggingBuilder logging)
{
Expand Down Expand Up @@ -116,14 +116,17 @@ public static void AddFwLiteMauiServices(this IServiceCollection services,
});

logging.AddFile(fwLiteMauiConfig.AppLogFilePath);
services.AddSingleton<IPreferences>(Preferences.Default);
services.AddSingleton<IVersionTracking>(VersionTracking.Default);
services.AddSingleton<IConnectivity>(Connectivity.Current);
//using callback otherwise tests try to evaluate the default/current property during setup.
//by using a callback, we can delay the evaluation until after the test setup, which lets us mock the service
services.AddSingleton<IPreferences>(_ => Preferences.Default);
services.AddSingleton<IVersionTracking>(_ => VersionTracking.Default);
services.AddSingleton<IConnectivity>(_ => Connectivity.Current);
services.AddSingleton<ITroubleshootingService, MauiTroubleshootingService>();
logging.AddConsole();
#if DEBUG
logging.AddDebug();
#endif
return services;
}

#if WINDOWS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ private async Task<ShouldUpdateResponse> ShouldUpdate()
}
}

private bool ShouldCheckForUpdate()
internal bool ShouldCheckForUpdate()
{
if (ValidPositiveEnvVarValues.Contains(Environment.GetEnvironmentVariable(ForceUpdateCheckEnvVar) ?? ""))
{
Expand Down
Loading