mirror of
https://github.com/immense/Remotely.git
synced 2025-10-26 11:27:15 +00:00
Add Test to make sure installer is installing the correct .NET Core runtime version.
This commit is contained in:
parent
13639962ed
commit
ee2118556d
@ -23,6 +23,7 @@ namespace Remotely.Agent.Installer.Win.Services
|
||||
public event EventHandler<string> ProgressMessageChanged;
|
||||
public event EventHandler<int> ProgressValueChanged;
|
||||
|
||||
public static string CoreRuntimeVersion => "3.1.2";
|
||||
private string InstallPath => Path.Combine(Path.GetPathRoot(Environment.SystemDirectory), "Program Files", "Remotely");
|
||||
private string Platform => Environment.Is64BitOperatingSystem ? "x64" : "x86";
|
||||
private JavaScriptSerializer Serializer { get; } = new JavaScriptSerializer();
|
||||
@ -304,7 +305,7 @@ namespace Remotely.Agent.Installer.Win.Services
|
||||
foreach (var subkeyName in GetRegistryBaseKey().OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\", false).GetSubKeyNames())
|
||||
{
|
||||
var subkey = GetRegistryBaseKey().OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" + subkeyName, false);
|
||||
if (subkey?.GetValue("DisplayName")?.ToString()?.Contains("Microsoft Windows Desktop Runtime - 3.1.2") == true)
|
||||
if (subkey?.GetValue("DisplayName")?.ToString()?.Contains($"Microsoft Windows Desktop Runtime - {CoreRuntimeVersion}") == true)
|
||||
{
|
||||
runtimeInstalled = true;
|
||||
break;
|
||||
|
||||
14
Remotely.sln
14
Remotely.sln
@ -47,6 +47,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Desktop.Win", "Desktop.Win\
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Agent.Installer.Win", "Agent.Installer.Win\Agent.Installer.Win.csproj", "{A3D0368C-0850-4614-B5B5-41B9D5135AA9}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{48D9D0E6-5781-44A9-84C0-56F56C2A1193}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -165,6 +167,18 @@ Global
|
||||
{A3D0368C-0850-4614-B5B5-41B9D5135AA9}.Release|x64.Build.0 = Release|Any CPU
|
||||
{A3D0368C-0850-4614-B5B5-41B9D5135AA9}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{A3D0368C-0850-4614-B5B5-41B9D5135AA9}.Release|x86.Build.0 = Release|Any CPU
|
||||
{48D9D0E6-5781-44A9-84C0-56F56C2A1193}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{48D9D0E6-5781-44A9-84C0-56F56C2A1193}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{48D9D0E6-5781-44A9-84C0-56F56C2A1193}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{48D9D0E6-5781-44A9-84C0-56F56C2A1193}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{48D9D0E6-5781-44A9-84C0-56F56C2A1193}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{48D9D0E6-5781-44A9-84C0-56F56C2A1193}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{48D9D0E6-5781-44A9-84C0-56F56C2A1193}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{48D9D0E6-5781-44A9-84C0-56F56C2A1193}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{48D9D0E6-5781-44A9-84C0-56F56C2A1193}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{48D9D0E6-5781-44A9-84C0-56F56C2A1193}.Release|x64.Build.0 = Release|Any CPU
|
||||
{48D9D0E6-5781-44A9-84C0-56F56C2A1193}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{48D9D0E6-5781-44A9-84C0-56F56C2A1193}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@ -26,6 +26,9 @@ namespace Remotely.Server.Areas.Identity.Pages.Account.Manage
|
||||
}
|
||||
public List<SelectListItem> DeviceGroups { get; } = new List<SelectListItem>();
|
||||
|
||||
[BindProperty]
|
||||
public InputModel Input { get; set; } = new InputModel();
|
||||
|
||||
[Display(Name = "Invites")]
|
||||
public List<Invite> Invites { get; set; }
|
||||
|
||||
@ -33,57 +36,23 @@ namespace Remotely.Server.Areas.Identity.Pages.Account.Manage
|
||||
[StringLength(25)]
|
||||
public string OrganizationName { get; set; }
|
||||
|
||||
[Display(Name = "Users")]
|
||||
public List<OrganizationUser> Users { get; set; }
|
||||
|
||||
public class InputModel
|
||||
{
|
||||
public bool IsAdmin { get; set; }
|
||||
|
||||
[EmailAddress]
|
||||
public string UserEmail { get; set; }
|
||||
}
|
||||
|
||||
[BindProperty]
|
||||
public InputModel Input { get; set; } = new InputModel();
|
||||
|
||||
[TempData]
|
||||
public string StatusMessage { get; set; }
|
||||
|
||||
[Display(Name = "Users")]
|
||||
public List<OrganizationUser> Users { get; set; }
|
||||
|
||||
private DataService DataService { get; }
|
||||
|
||||
private UserManager<RemotelyUser> UserManager { get; }
|
||||
private IEmailSender EmailSender { get; }
|
||||
|
||||
private UserManager<RemotelyUser> UserManager { get; }
|
||||
|
||||
public void OnGet()
|
||||
{
|
||||
PopulateViewModel();
|
||||
}
|
||||
|
||||
private void PopulateViewModel()
|
||||
{
|
||||
OrganizationName = DataService.GetOrganizationName(User.Identity.Name);
|
||||
|
||||
var groups = DataService.GetDeviceGroupsForUserName(User.Identity.Name);
|
||||
DeviceGroups.AddRange(groups.Select(x => new SelectListItem(x.Name, x.ID)));
|
||||
|
||||
Users = DataService.GetAllUsers(User.Identity.Name)
|
||||
.Select(x => new OrganizationUser()
|
||||
{
|
||||
ID = x.Id,
|
||||
IsAdmin = x.IsAdministrator,
|
||||
UserName = x.UserName
|
||||
}).ToList();
|
||||
|
||||
Invites = DataService.GetAllInviteLinks(User.Identity.Name).Select(x => new Invite()
|
||||
{
|
||||
ID = x.ID,
|
||||
InvitedUser = x.InvitedUser,
|
||||
IsAdmin = x.IsAdmin,
|
||||
DateSent = x.DateSent
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostSendInviteAsync()
|
||||
{
|
||||
var currentUser = await UserManager.FindByEmailAsync(User.Identity.Name);
|
||||
@ -122,7 +91,7 @@ namespace Remotely.Server.Areas.Identity.Pages.Account.Manage
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
var invite = new Invite()
|
||||
{
|
||||
InvitedUser = Input.UserEmail,
|
||||
@ -147,6 +116,38 @@ namespace Remotely.Server.Areas.Identity.Pages.Account.Manage
|
||||
}
|
||||
return Page();
|
||||
}
|
||||
|
||||
private void PopulateViewModel()
|
||||
{
|
||||
OrganizationName = DataService.GetOrganizationName(User.Identity.Name);
|
||||
|
||||
var groups = DataService.GetDeviceGroupsForUserName(User.Identity.Name);
|
||||
DeviceGroups.AddRange(groups.Select(x => new SelectListItem(x.Name, x.ID)));
|
||||
|
||||
Users = DataService.GetAllUsers(User.Identity.Name)
|
||||
.Select(x => new OrganizationUser()
|
||||
{
|
||||
ID = x.Id,
|
||||
IsAdmin = x.IsAdministrator,
|
||||
UserName = x.UserName
|
||||
}).ToList();
|
||||
|
||||
Invites = DataService.GetAllInviteLinks(User.Identity.Name).Select(x => new Invite()
|
||||
{
|
||||
ID = x.ID,
|
||||
InvitedUser = x.InvitedUser,
|
||||
IsAdmin = x.IsAdmin,
|
||||
DateSent = x.DateSent
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
public class InputModel
|
||||
{
|
||||
public bool IsAdmin { get; set; }
|
||||
|
||||
[EmailAddress]
|
||||
public string UserEmail { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
19
Tests/InstallerTests.cs
Normal file
19
Tests/InstallerTests.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Remotely.Agent.Installer.Win.Services;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Tests
|
||||
{
|
||||
[TestClass]
|
||||
public class InstallerTests
|
||||
{
|
||||
[TestMethod]
|
||||
public void CoreVersionTest()
|
||||
{
|
||||
var description = RuntimeInformation.FrameworkDescription;
|
||||
var version = description.Split().Last();
|
||||
Assert.AreEqual(InstallerService.CoreRuntimeVersion, version);
|
||||
}
|
||||
}
|
||||
}
|
||||
20
Tests/Tests.csproj
Normal file
20
Tests/Tests.csproj
Normal file
@ -0,0 +1,20 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.0.0" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="2.0.0" />
|
||||
<PackageReference Include="coverlet.collector" Version="1.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Agent.Installer.Win\Agent.Installer.Win.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Loading…
Reference in New Issue
Block a user