Skip to content
This repository has been archived by the owner on Jun 10, 2023. It is now read-only.

Commit

Permalink
Merge pull request #71 from j2ghz/develop
Browse files Browse the repository at this point in the history
Integrate develop
  • Loading branch information
j2ghz authored Jun 4, 2019
2 parents b79b460 + d2151b8 commit c9b37e4
Show file tree
Hide file tree
Showing 48 changed files with 224 additions and 328 deletions.
4 changes: 2 additions & 2 deletions src/ModSink.CLI/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
using Microsoft.Extensions.CommandLineUtils;
using ModSink.Common;
using ModSink.Common.Client;
using ModSink.Common.Models.Group;
using ModSink.Common.Models.Repo;
using ModSink.Common.Models.DTO.Group;
using ModSink.Common.Models.DTO.Repo;
using Serilog;
using Serilog.Formatting.Compact;
using Serilog.Sinks.SystemConsole.Themes;
Expand Down
10 changes: 5 additions & 5 deletions src/ModSink.Common.Tests/Client/ClientServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
using DynamicData;
using FluentAssertions;
using ModSink.Common.Client;
using ModSink.Common.Models.Group;
using ModSink.Common.Models.Repo;
using ModSink.Common.Models.DTO.Group;
using ModSink.Common.Models.DTO.Repo;
using ReactiveUI.Testing;
using Serilog;
using Xunit;
Expand Down Expand Up @@ -117,9 +117,9 @@ public void DownloadRepo()
client.GroupUrls.Items.Should().HaveCount(1);
client.Repos.Items.Should().HaveCount(1);
client.QueuedDownloads.Items.Should().HaveCount(0);
foreach (var r in client.Repos.Items)
foreach (var modpack in r.Modpacks)
modpack.Selected = true;
//foreach (var r in client.Repos.Items)
//foreach (var modpack in r.Modpacks)
// modpack.Selected = true;

client.QueuedDownloads.Items.Should().HaveCount(1);
client.ActiveDownloads.Items.Should().HaveCount(1);
Expand Down
127 changes: 0 additions & 127 deletions src/ModSink.Common.Tests/Client/DynamicDataChainTests.cs

This file was deleted.

4 changes: 2 additions & 2 deletions src/ModSink.Common.Tests/ModSink.Common.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
<PackageReference Include="Bogus" Version="26.0.1" />
<PackageReference Include="FluentAssertions" Version="5.6.0" />
<PackageReference Include="JetBrains.DotMemoryUnit" Version="3.0.20171219.105559" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.1" />
<PackageReference Include="Moq" Version="4.10.1" />
<PackageReference Include="ReactiveUI.Testing" Version="9.11.1" />
<PackageReference Include="ReactiveUI.Testing" Version="9.11.3" />
<PackageReference Include="Serilog.Sinks.Debug" Version="1.0.1" />
<PackageReference Include="System.Reactive" Version="4.2.0-preview.102" />
<PackageReference Include="xunit" Version="2.4.1" />
Expand Down
6 changes: 3 additions & 3 deletions src/ModSink.Common.Tests/Models/Group/GroupTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

namespace ModSink.Common.Tests.Models.Group
{
public class GroupTests : TestWithFaker<Common.Models.Group.Group>
public class GroupTests : TestWithFaker<Common.Models.DTO.Group.Group>
{
public static Faker<Common.Models.Group.Group> GroupFaker = new Faker<Common.Models.Group.Group>()
public static Faker<Common.Models.DTO.Group.Group> GroupFaker = new Faker<Common.Models.DTO.Group.Group>()
.StrictMode(true)
.RuleFor(g => g.BaseUri, f => new Uri(f.Internet.UrlWithPath()))
.RuleFor(g => g.RepoInfos, _ => RepoInfoTests.RepoInfoFaker.Generate(3));

public override Faker<Common.Models.Group.Group> Faker { get; } = GroupFaker;
public override Faker<Common.Models.DTO.Group.Group> Faker { get; } = GroupFaker;
}
}
2 changes: 1 addition & 1 deletion src/ModSink.Common.Tests/Models/Group/RepoInfoTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using Bogus;
using ModSink.Common.Models.Group;
using ModSink.Common.Models.DTO.Group;

namespace ModSink.Common.Tests.Models.Group
{
Expand Down
5 changes: 2 additions & 3 deletions src/ModSink.Common.Tests/Models/Repo/FileSignatureTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Bogus;
using FluentAssertions;
using FluentAssertions.Primitives;
using ModSink.Common.Models.Repo;
using ModSink.Common.Models.DTO.Repo;
using Xunit;

namespace ModSink.Common.Tests.Models.Repo
Expand All @@ -22,8 +22,7 @@ public void SameEqual()
{
var a = new FileSignature(new HashValue(new byte[] {0x99, 0xE9, 0xD8, 0x51, 0x37, 0xDB, 0x46, 0xEF}), 355);
var b = new FileSignature(new HashValue(new byte[] {0x99, 0xE9, 0xD8, 0x51, 0x37, 0xDB, 0x46, 0xEF}), 355);
a.Equals(b).Should().BeTrue("FileSignature with same properties should be equal")
;
a.Equals(b).Should().BeTrue("FileSignature with same properties should be equal");
}
}
}
2 changes: 1 addition & 1 deletion src/ModSink.Common.Tests/Models/Repo/HashValueTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Bogus;
using FluentAssertions;
using FluentAssertions.Primitives;
using ModSink.Common.Models.Repo;
using ModSink.Common.Models.DTO.Repo;
using Xunit;

namespace ModSink.Common.Tests.Models.Repo
Expand Down
2 changes: 1 addition & 1 deletion src/ModSink.Common.Tests/Models/Repo/ModEntryTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Bogus;
using ModSink.Common.Models.Repo;
using ModSink.Common.Models.DTO.Repo;

namespace ModSink.Common.Tests.Models.Repo
{
Expand Down
2 changes: 1 addition & 1 deletion src/ModSink.Common.Tests/Models/Repo/ModTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.IO;
using System.Linq;
using Bogus;
using ModSink.Common.Models.Repo;
using ModSink.Common.Models.DTO.Repo;

namespace ModSink.Common.Tests.Models.Repo
{
Expand Down
5 changes: 2 additions & 3 deletions src/ModSink.Common.Tests/Models/Repo/ModpackTests.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
using Bogus;
using ModSink.Common.Models.Repo;
using ModSink.Common.Models.DTO.Repo;

namespace ModSink.Common.Tests.Models.Repo
{
public class ModpackTests : TestWithFaker<Modpack>
{
public static readonly Faker<Modpack> ModpackFaker = new Faker<Modpack>().StrictMode(true)
.RuleFor(m => m.Name, f => f.Company.CompanyName())
.RuleFor(m => m.Mods, ModEntryTests.ModEntryFaker.Generate(3))
.RuleFor(m => m.Selected, f => f.Random.Bool());
.RuleFor(m => m.Mods, ModEntryTests.ModEntryFaker.Generate(3));

public override Faker<Modpack> Faker { get; } = ModpackFaker;
}
Expand Down
8 changes: 4 additions & 4 deletions src/ModSink.Common.Tests/Models/Repo/RepoTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@

namespace ModSink.Common.Tests.Models.Repo
{
public class RepoTests : TestWithFaker<Common.Models.Repo.Repo>
public class RepoTests : TestWithFaker<Common.Models.DTO.Repo.Repo>
{
public static readonly Faker<Common.Models.Repo.Repo> RepoFaker =
new Faker<Common.Models.Repo.Repo>().StrictMode(true)
public static readonly Faker<Common.Models.DTO.Repo.Repo> RepoFaker =
new Faker<Common.Models.DTO.Repo.Repo>().StrictMode(true)
.RuleFor(r => r.BaseUri, f => new Uri(f.Internet.UrlWithPath()))
.RuleFor(r => r.Modpacks, f => ModpackTests.ModpackFaker.Generate(3))
.RuleFor(r => r.Files,
f => f.Make(3, () => FileSignatureTests.FileSignature)
.ToDictionary(fs => fs, fs => new Uri(f.Internet.UrlWithPath())));

public override Faker<Common.Models.Repo.Repo> Faker { get; } = RepoFaker;
public override Faker<Common.Models.DTO.Repo.Repo> Faker { get; } = RepoFaker;

[Fact(Skip = "Test breaks, but it works")]
public override void IsSerializeable()
Expand Down
2 changes: 1 addition & 1 deletion src/ModSink.Common.Tests/XXHash64Tests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using ModSink.Common.Models.Repo;
using ModSink.Common.Models.DTO.Repo;
using Xunit;

namespace ModSink.Common.Tests
Expand Down
42 changes: 6 additions & 36 deletions src/ModSink.Common/Client/ClientService.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reactive.Disposables;
Expand All @@ -8,12 +7,13 @@
using System.Threading.Tasks;
using Anotar.Serilog;
using DynamicData;
using DynamicData.Kernel;
using Humanizer;
using ModSink.Common.Models;
using ModSink.Common.Models.Client;
using ModSink.Common.Models.Group;
using ModSink.Common.Models.Repo;
using ModSink.Common.Models.DTO.Repo;
using Group = ModSink.Common.Models.DTO.Group.Group;
using Modpack = ModSink.Common.Models.Client.Modpack;
using Repo = ModSink.Common.Models.DTO.Repo.Repo;

namespace ModSink.Common.Client
{
Expand Down Expand Up @@ -48,39 +48,9 @@ public ClientService(IDownloader downloader, IFormatter serializationFormatter,
repo => repo.Files.Select(kvp => new OnlineFile(kvp.Key, repo.CombineBaseUri(kvp.Value))),
of => of.FileSignature).AsObservableCache();
d.Add(OnlineFiles);
Modpacks = DynamicDataChain.GetModpacksFromRepos(Repos.Connect()).AsObservableCache();
Modpacks = Repos.Connect()
.TransformMany(r => r.Modpacks.Select(m => new Modpack(m)), m => m.Id).AsObservableCache();
d.Add(Modpacks);
QueuedDownloads = DynamicDataChain.GetDownloadsFromModpacks(Modpacks.Connect())
.LeftJoin(filesAvailable.Connect(), f => f,
(required, available) => !available.HasValue
? Optional<FileSignature>.Create(required)
: Optional<FileSignature>.None)
.Filter(opt => opt.HasValue)
.Transform(opt => opt.Value)
.InnerJoin(OnlineFiles.Connect(), of => of.FileSignature,
(fs, of) => new QueuedDownload(fs, of.Uri))
.AsObservableCache();
d.Add(QueuedDownloads);
ActiveDownloads = QueuedDownloads.Connect()
.Sort(Comparer<QueuedDownload>.Create((_, __) => 0))
.Top(5)
.LogVerbose("activeDownloadsSimple")
.Transform(qd =>
{
var destination = new Lazy<Stream>(() => GetTemporaryFileStream(qd.FileSignature));
return new ActiveDownload(
downloader.Download(qd.Source, destination,
qd.FileSignature.Length),
() =>
{
destination.Value.Dispose();
LogTo.Verbose("ActiveDownload {name} finished", qd.FileSignature.Hash);
AddNewFile(qd.FileSignature);
}, qd.FileSignature.ToString());
})
.LogVerbose("activeDownloads")
.AsObservableCache();
d.Add(ActiveDownloads);
}

public IObservableCache<ActiveDownload, FileSignature> ActiveDownloads { get; }
Expand Down
31 changes: 0 additions & 31 deletions src/ModSink.Common/Client/DynamicDataChain.cs

This file was deleted.

Loading

0 comments on commit c9b37e4

Please sign in to comment.