Skip to content

Commit

Permalink
Code cleanup and fix test running
Browse files Browse the repository at this point in the history
  • Loading branch information
halgari committed Oct 23, 2021
1 parent 2b5662a commit f99f4a7
Show file tree
Hide file tree
Showing 577 changed files with 25,066 additions and 25,646 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Test
run: dotnet test --no-restore --filter "Category=!FlakeyNetwork"
run: dotnet test --no-restore --filter "Category!=FlakeyNetwork"

publish:
name: Publish Projects
Expand Down
2 changes: 1 addition & 1 deletion Wabbajack.App.Test/Extensions.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Threading.Tasks;
using Avalonia.Threading;
using ReactiveUI;
using Wabbajack.App.Models;

namespace Wabbajack.App.Test;
Expand All @@ -28,6 +27,7 @@ public static async Task WaitForLock(this LoadingLock l)
await Task.Delay(100);
}
}

public static async Task WaitForUnlock(this LoadingLock l)
{
Dispatcher.UIThread.RunJobs();
Expand Down
21 changes: 9 additions & 12 deletions Wabbajack.App.Test/GalleryItemTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using Wabbajack.App.Controls;
Expand All @@ -15,23 +14,21 @@ namespace Wabbajack.App.Test;

public class GalleryItemTests
{
private readonly BrowseViewModel _gallery;
private readonly Configuration _config;
private readonly BrowseViewModel _gallery;

public GalleryItemTests(BrowseViewModel bvm, Configuration config)
{
_config = config;
_gallery = bvm;
}

[Fact]
public async Task CanDownloadGalleryItem()
{
foreach (var file in _config.ModListsDownloadLocation.EnumerateFiles().Where(f => f.Extension == Ext.Wabbajack))
{
file.Delete();
}


using var _ = _gallery.Activator.Activate();
await _gallery.LoadingLock.WaitForLock();
await _gallery.LoadingLock.WaitForUnlock();
Expand All @@ -44,7 +41,7 @@ public async Task CanDownloadGalleryItem()
Assert.True(item.ModListLocation.FileExists());
else
Assert.False(item.ModListLocation.FileExists());

Assert.Equal(Percent.Zero, item.Progress);
}

Expand All @@ -58,18 +55,18 @@ await modList.WaitUntil(x => x.State != ModListState.Downloading, () =>
Assert.True(modList.Progress >= progress);
progress = modList.Progress;
});

Assert.Equal(Percent.Zero, modList.Progress);
Assert.Equal(ModListState.Downloaded, modList.State);
Assert.Equal(ModListState.Downloaded, modList.State);


modList.ExecuteCommand.Execute().Subscribe().Dispose();

var msgs = ((SimpleMessageBus) MessageBus.Instance).Messages.TakeLast(2).ToArray();

var configure = msgs.OfType<StartInstallConfiguration>().First();
Assert.Equal(modList.ModListLocation, configure.ModList);

var navigate = msgs.OfType<NavigateTo>().First();
Assert.Equal(typeof(InstallConfigurationViewModel), navigate.ViewModel);
}
Expand Down
38 changes: 17 additions & 21 deletions Wabbajack.App.Test/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,35 +1,31 @@
using System.Collections.Generic;
using Avalonia.Threading;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Wabbajack.App;
using Wabbajack.Networking.WabbajackClientApi;
using Wabbajack.Services.OSIntegrated;
using Xunit.DependencyInjection;
using Xunit.DependencyInjection.Logging;

namespace Wabbajack.App.Test
namespace Wabbajack.App.Test;

public class Startup
{
public class Startup
public void ConfigureServices(IServiceCollection service)
{
public void ConfigureServices(IServiceCollection service)
{
service.AddAppServices();
}
service.AddAppServices();
}

public void Configure(ILoggerFactory loggerFactory, ITestOutputHelperAccessor accessor)
{
loggerFactory.AddProvider(new XunitTestOutputLoggerProvider(accessor, delegate { return true; }));
MessageBus.Instance = new SimpleMessageBus();
}
public void Configure(ILoggerFactory loggerFactory, ITestOutputHelperAccessor accessor)
{
loggerFactory.AddProvider(new XunitTestOutputLoggerProvider(accessor, delegate { return true; }));
MessageBus.Instance = new SimpleMessageBus();
}
}

public class SimpleMessageBus : IMessageBus
{
public List<object> Messages { get; } = new();

public class SimpleMessageBus : IMessageBus
public void Send<T>(T message)
{
public List<object> Messages { get; } = new();
public void Send<T>(T message)
{
Messages.Add(message);
}
Messages.Add(message);
}
}
10 changes: 5 additions & 5 deletions Wabbajack.App.Test/Wabbajack.App.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0"/>
<PackageReference Include="xunit" Version="2.4.1"/>
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Xunit.DependencyInjection" Version="7.7.0" />
<PackageReference Include="Xunit.DependencyInjection.Logging" Version="7.5.1" />
<PackageReference Include="Xunit.DependencyInjection" Version="7.7.0"/>
<PackageReference Include="Xunit.DependencyInjection.Logging" Version="7.5.1"/>
<PackageReference Include="coverlet.collector" Version="3.1.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Wabbajack.App\Wabbajack.App.csproj" />
<ProjectReference Include="..\Wabbajack.App\Wabbajack.App.csproj"/>
</ItemGroup>

</Project>
23 changes: 11 additions & 12 deletions Wabbajack.App/App.axaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Wabbajack.App"
xmlns:i="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
x:Class="Wabbajack.App.App">
<Application.DataTemplates>
<local:ViewLocator/>
<local:ViewLocator />
</Application.DataTemplates>

<Application.Styles>
<StyleInclude Source="avares://Material.Icons.Avalonia/App.xaml"></StyleInclude>
<FluentTheme Mode="Dark"/>
<StyleInclude Source="avares://Wabbajack.App/Assets/Wabbajack.axaml"></StyleInclude>
<StyleInclude Source="avares://Material.Icons.Avalonia/App.xaml" />
<FluentTheme Mode="Dark" />
<StyleInclude Source="avares://Wabbajack.App/Assets/Wabbajack.axaml" />
<Style Selector="Button:not(:pointerover) /template/ ContentPresenter">
<Setter Property="Background" Value="Transparent"></Setter>
<Setter Property="Background" Value="Transparent" />
</Style>


<Style Selector="Button:pointerover /template/ ContentPresenter">
<Setter Property="Background" Value="Transparent"></Setter>
<Setter Property="BorderBrush" Value="LightGray"></Setter>
<Setter Property="CornerRadius" Value="5"></Setter>
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="LightGray" />
<Setter Property="CornerRadius" Value="5" />
</Style>
</Application.Styles>
</Application>
</Application>
98 changes: 42 additions & 56 deletions Wabbajack.App/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,80 +3,66 @@
using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
using CefNet;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using ReactiveUI;
using Splat;
using Wabbajack.App.Controls;
using Wabbajack.App.Converters;
using Wabbajack.App.Interfaces;
using Wabbajack.App.Models;
using Wabbajack.App.Utilities;
using Wabbajack.App.ViewModels;
using Wabbajack.App.Views;
using Wabbajack.DTOs.JsonConverters;
using Wabbajack.Networking.NexusApi;
using Wabbajack.Services.OSIntegrated;

namespace Wabbajack.App
namespace Wabbajack.App;

public class App : Application
{
public class App : Application
{

public static event EventHandler FrameworkInitialized;
public static event EventHandler FrameworkShutdown;
public static IServiceProvider Services { get; private set; } = null!;
public static Window? MainWindow { get; set; }
public override void Initialize()
{
AvaloniaXamlLoader.Load(this);
}
public static IServiceProvider Services { get; private set; } = null!;
public static Window? MainWindow { get; set; }

public override void OnFrameworkInitializationCompleted()
{
var host = Host.CreateDefaultBuilder(Array.Empty<string>())
.ConfigureLogging(c =>
{
c.ClearProviders();
})
.ConfigureServices((host, services) =>
{
services.AddAppServices();
}).Build();
Services = host.Services;
public static event EventHandler FrameworkInitialized;
public static event EventHandler FrameworkShutdown;

SetupConverters();
public override void Initialize()
{
AvaloniaXamlLoader.Load(this);
}

// Need to startup the message bus;
Services.GetService<MessageBus>();
var app = Services.GetService<CefAppImpl>();
public override void OnFrameworkInitializationCompleted()
{
var host = Host.CreateDefaultBuilder(Array.Empty<string>())
.ConfigureLogging(c => { c.ClearProviders(); })
.ConfigureServices((host, services) => { services.AddAppServices(); }).Build();
Services = host.Services;

if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
desktop.MainWindow = new MainWindow();
desktop.Startup += Startup;
desktop.Exit += Exit;
MainWindow = desktop.MainWindow;
}
SetupConverters();

base.OnFrameworkInitializationCompleted();
}

private void Startup(object sender, ControlledApplicationLifetimeStartupEventArgs e)
{
FrameworkInitialized?.Invoke(this, EventArgs.Empty);
}
// Need to startup the message bus;
Services.GetService<MessageBus>();
var app = Services.GetService<CefAppImpl>();

private void Exit(object sender, ControlledApplicationLifetimeExitEventArgs e)
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
FrameworkShutdown?.Invoke(this, EventArgs.Empty);
desktop.MainWindow = new MainWindow();
desktop.Startup += Startup;
desktop.Exit += Exit;
MainWindow = desktop.MainWindow;
}

private void SetupConverters()
{
Locator.CurrentMutable.RegisterConstant<IBindingTypeConverter>(new AbsoultePathBindingConverter());
}
base.OnFrameworkInitializationCompleted();
}

private void Startup(object sender, ControlledApplicationLifetimeStartupEventArgs e)
{
FrameworkInitialized?.Invoke(this, EventArgs.Empty);
}

private void Exit(object sender, ControlledApplicationLifetimeExitEventArgs e)
{
FrameworkShutdown?.Invoke(this, EventArgs.Empty);
}

private void SetupConverters()
{
Locator.CurrentMutable.RegisterConstant<IBindingTypeConverter>(new AbsoultePathBindingConverter());
}
}
35 changes: 16 additions & 19 deletions Wabbajack.App/Assets/Wabbajack.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,33 @@
</Border>
</Design.PreviewWith>


<Style Selector="controls|TagView Border">
<Setter Property="BorderThickness" Value="1"></Setter>
<Setter Property="BorderBrush" Value="#121212"></Setter>
<Setter Property="CornerRadius" Value="5"></Setter>
<Setter Property="BorderThickness" Value="1" />
<Setter Property="BorderBrush" Value="#121212" />
<Setter Property="CornerRadius" Value="5" />
</Style>


<Style Selector="controls|TagView.ModList Border">
<Setter Property="Background" Value="#868CFC"></Setter>
<Setter Property="Background" Value="#868CFC" />
</Style>

<Style Selector="controls|TagView.Game Border">
<Setter Property="Background" Value="#F686FC"></Setter>
<Setter Property="Background" Value="#F686FC" />
</Style>

<Style Selector="controls|TagView.GameNotInstalled Border">
<Setter Property="Background" Value="#FCBB86"></Setter>
<Setter Property="Background" Value="#FCBB86" />
</Style>

<Style Selector="controls|TagView.GameNotInstalled Border">
<Setter Property="Background" Value="#FCBB86"></Setter>
<Setter Property="Background" Value="#FCBB86" />
</Style>

<Style Selector="controls|TagView TextBlock">
<Setter Property="Foreground" Value="#121212"></Setter>
<Setter Property="Foreground" Value="#121212" />
</Style>





</Styles>

</Styles>
7 changes: 6 additions & 1 deletion Wabbajack.App/Assets/cloud-download-alt-solid.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit f99f4a7

Please sign in to comment.