Skip to content

Commit

Permalink
Merge pull request #21 from Goose-Bomb/dev
Browse files Browse the repository at this point in the history
The sound of a pigeon
  • Loading branch information
Nullkooland authored Feb 10, 2020
2 parents 4fb8e65 + afc2cd0 commit 6e3134b
Show file tree
Hide file tree
Showing 169 changed files with 3,449 additions and 2,034 deletions.
15 changes: 11 additions & 4 deletions GBCLV3.Tests/AssetTest.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
using System.Diagnostics;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Linq;
using GBCLV3.Models.Authentication;
using GBCLV3.Models.Download;
using GBCLV3.Services;
using GBCLV3.Services.Download;
using GBCLV3.Services.Launch;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Stylet;

namespace GBCLV3.Tests
{
[TestClass]
public class AssetTest
{
private const string GAME_ROOT_DIR = "G:/Minecraft/1.12.2/.minecraft";
private const string ID = "1.6.4";
private const string GAME_ROOT_DIR = @"D:\Games\Minecraft\.minecraft";
private const string ID = "1.14.4";

private readonly ConfigService _configService;
private readonly VersionService _versionService;
Expand All @@ -22,7 +29,7 @@ public AssetTest()
_configService.Entries.SelectedVersion = ID;

var gamePathService = new GamePathService(_configService);
var urlServie = new UrlService(_configService);
var urlServie = new DownloadUrlService(_configService);

_versionService = new VersionService(gamePathService, urlServie);
_assetService = new AssetService(gamePathService, urlServie);
Expand Down
38 changes: 38 additions & 0 deletions GBCLV3.Tests/DownloadTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using GBCLV3.Models.Download;
using GBCLV3.Services.Download;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Collections.Generic;
using System.Diagnostics;

namespace GBCLV3.Tests
{
[TestClass]
class DownloadTest
{
[TestMethod]
public void TestSingleDownload()
{
var items = new List<DownloadItem>() {
new DownloadItem
{
Url = "https://github.com/Goose-Bomb/GBCLV3/releases/download/3.0.7.59/GBCL.exe",
Path = "./downloads/gbcl.exe",
Size = 1569294,
IsCompleted = false,
}
};

var downloadService = new DownloadService(items);
downloadService.ProgressChanged += e =>
{
Debug.WriteLine("---------------------------------------------------------------");
Debug.WriteLine($"Progress: {e.DownloadedBytes} Bytes");
Debug.WriteLine($"Speed: {e.Speed} Bytes/sec");
};

bool isSccessful = downloadService.StartAsync().Result;

Assert.IsTrue(isSccessful);
}
}
}
81 changes: 20 additions & 61 deletions GBCLV3.Tests/GBCLV3.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,69 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{EC2B8F3E-4270-4D6A-AFFD-1677BB36F256}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>GBCLV3.Tests</RootNamespace>
<AssemblyName>GBCLV3.Tests</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">15.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
<IsCodedUITest>False</IsCodedUITest>
<TestProjectType>UnitTest</TestProjectType>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<TargetFramework>netcoreapp3.1</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="PresentationCore" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Net.Http" />
</ItemGroup>


<ItemGroup>
<Compile Include="AssetTest.cs" />
<Compile Include="LibraryTest.cs" />
<Compile Include="LaunchTest.cs" />
<Compile Include="ModTest.cs" />
<Compile Include="ResourcePackTest.cs" />
<Compile Include="InstallTest.cs" />
<Compile Include="UpdateTest.cs" />
<Compile Include="TestUtils.cs" />
<Compile Include="VersionTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.1.0" />
<PackageReference Include="MSTest.TestFramework" Version="2.1.0" />
<PackageReference Include="coverlet.collector" Version="1.2.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<PackageReference Include="MSTest.TestAdapter">
<Version>2.0.0</Version>
</PackageReference>
<PackageReference Include="MSTest.TestFramework">
<Version>2.0.0</Version>
</PackageReference>
<ProjectReference Include="..\GBCLV3\GBCLV3.csproj" />
</ItemGroup>
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

</Project>
8 changes: 6 additions & 2 deletions GBCLV3.Tests/InstallTest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
using System.Diagnostics;
using System.Linq;
using GBCLV3.Services;
using GBCLV3.Services.Download;
using GBCLV3.Services.Installation;
using GBCLV3.Services.Launch;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace GBCLV3.Tests
Expand All @@ -25,11 +29,11 @@ public InstallTest()
_configService.Entries.JavaDebugMode = false;

var gamePathService = new GamePathService(_configService);
var urlServie = new UrlService(_configService);
var urlServie = new DownloadUrlService(_configService);

_versionService = new VersionService(gamePathService, urlServie);
_forgeInstallService = new ForgeInstallService(gamePathService, urlServie, _versionService);
_fabricInstallService = new FabricInstallService(gamePathService, _versionService);
_fabricInstallService = new FabricInstallService(gamePathService, urlServie, _versionService);
}

[TestMethod]
Expand Down
18 changes: 14 additions & 4 deletions GBCLV3.Tests/LaunchTest.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
using System.Diagnostics;
using System.Linq;
using GBCLV3.Models.Launch;
using GBCLV3.Services;
using GBCLV3.Services.Authentication;
using GBCLV3.Services.Download;
using GBCLV3.Services.Launch;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace GBCLV3.Tests
{
[TestClass]
public class LaunchTest
{
private const string GAME_ROOT_DIR = "G:/Minecraft/1.12.2/.minecraft";
private const string ID = "1.12.2-forge1.12.2-14.23.5.2838";
private const string GAME_ROOT_DIR = "D:/Minecraft/.minecraft";
private const string ID = "1.14.4";

private readonly ConfigService _configService;
private readonly VersionService _versionService;
private readonly LibraryService _libraryService;
private readonly AuthService _authService;
private readonly AccountService _accountService;
private readonly LaunchService _launchService;

public LaunchTest()
Expand All @@ -25,11 +32,13 @@ public LaunchTest()
_configService.Entries.JavaDebugMode = false;

var gamePathService = new GamePathService(_configService);
var urlServie = new UrlService(_configService);
var urlServie = new DownloadUrlService(_configService);

_versionService = new VersionService(gamePathService, urlServie);
_libraryService = new LibraryService(gamePathService, urlServie);

_authService = new AuthService();
_accountService = new AccountService(_configService, null);
_launchService = new LaunchService(gamePathService);

_versionService.LoadAll();
Expand Down Expand Up @@ -65,7 +74,8 @@ public void LaunchGameTest()

_libraryService.ExtractNatives(version.Libraries.Where(lib => lib.Type == LibraryType.Native));

var authResult = AuthService.GetOfflineProfile("goose_bomb");
var account = _accountService.GetSelected();
var authResult = _authService.LoginAsync(account).Result;

var proile = new LaunchProfile
{
Expand Down
7 changes: 6 additions & 1 deletion GBCLV3.Tests/LibraryTest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
using System.Diagnostics;
using System.Linq;
using GBCLV3.Models.Download;
using GBCLV3.Models.Launch;
using GBCLV3.Services;
using GBCLV3.Services.Download;
using GBCLV3.Services.Launch;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace GBCLV3.Tests
Expand All @@ -22,7 +27,7 @@ public LibraryTest()
_configService.Entries.SelectedVersion = ID;

var gamePathService = new GamePathService(_configService);
var urlServie = new UrlService(_configService);
var urlServie = new DownloadUrlService(_configService);

_versionService = new VersionService(gamePathService, urlServie);
_libraryService = new LibraryService(gamePathService, urlServie);
Expand Down
3 changes: 3 additions & 0 deletions GBCLV3.Tests/ModTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using System.Diagnostics;
using GBCLV3.Services;
using GBCLV3.Services.Auxiliary;
using GBCLV3.Services.Launch;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace GBCLV3.Tests
Expand Down
19 changes: 0 additions & 19 deletions GBCLV3.Tests/Properties/AssemblyInfo.cs

This file was deleted.

3 changes: 3 additions & 0 deletions GBCLV3.Tests/ResourcePackTest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using System.Diagnostics;
using System.Linq;
using GBCLV3.Services;
using GBCLV3.Services.Auxiliary;
using GBCLV3.Services.Launch;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace GBCLV3.Tests
Expand Down
8 changes: 3 additions & 5 deletions GBCLV3.Tests/TestUtils.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Net;
using GBCLV3.Models.Download;
using System.Net.Http;

namespace GBCLV3.Tests
Expand All @@ -9,10 +9,8 @@ static class TestUtils

public static bool IsDownloadable(DownloadItem item)
{
using (var response = _client.GetAsync(item.Url).Result)
{
return (response.StatusCode == HttpStatusCode.OK);
}
using var response = _client.GetAsync(item.Url).Result;
return response.IsSuccessStatusCode;
}
}
}
6 changes: 4 additions & 2 deletions GBCLV3.Tests/UpdateTest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System.Diagnostics;
using System.Linq;
using GBCLV3.Services;
using GBCLV3.Services.Download;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace GBCLV3.Tests
Expand All @@ -20,7 +22,7 @@ public UpdateTest()
[TestMethod]
public void GetUpdateInfoTest()
{
var info = _updateService.Check().Result;
var info = _updateService.CheckAsync().Result;

if (info == null)
{
Expand All @@ -36,7 +38,7 @@ public void GetUpdateInfoTest()
Debug.WriteLine($"PreRelease: {info.PreRelease}");
Debug.WriteLine($"ReleaseTime: {info.Description}");

var changelog = _updateService.GetChangelog(info).Result;
var changelog = _updateService.GetChangelogAsync(info).Result;

Debug.WriteLine("[Changelog]");
Debug.WriteLine($"Title: {changelog.Title}");
Expand Down
10 changes: 7 additions & 3 deletions GBCLV3.Tests/VersionTest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
using System.Diagnostics;
using System.Linq;
using GBCLV3.Models.Download;
using GBCLV3.Services;
using GBCLV3.Services.Download;
using GBCLV3.Services.Launch;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace GBCLV3.Tests
Expand All @@ -20,14 +24,14 @@ public VersionTest()
_configService.Entries.GameDir = GAME_ROOT_DIR;

var gamePathService = new GamePathService(_configService);
var urlServie = new UrlService(_configService);
var urlServie = new DownloadUrlService(_configService);

_versionService = new VersionService(gamePathService, urlServie);

_versionService.LoadAll();
Assert.IsTrue(_versionService.Any(), "No available versions!");

foreach (var version in _versionService.GetAvailable())
foreach (var version in _versionService.GetAll())
{
Debug.WriteLine(version.ID);
//Debug.WriteLine();
Expand All @@ -37,7 +41,7 @@ public VersionTest()
[TestMethod]
public void GetDownloadsTest()
{
var downloads = _versionService.GetAvailable()
var downloads = _versionService.GetAll()
.Select(version => _versionService.GetDownload(version))
.Aggregate((prev, current) => prev.Concat(current));

Expand Down
Loading

0 comments on commit 6e3134b

Please sign in to comment.