Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
coenm committed Aug 14, 2023
1 parent 7e08d95 commit c434011
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 75 deletions.
11 changes: 10 additions & 1 deletion src/RepoM.Api/Ordering/Az/AlphabetComparerConfigurationV1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ namespace RepoM.Api.Ordering.Az;

using RepoM.Core.Plugin.RepositoryOrdering.Configuration;

/// <summary>
/// Compares two repositories by a given property.
/// </summary>
public class AlphabetComparerConfigurationV1 : IRepositoriesComparerConfiguration
{
public const string TYPE_VALUE = "az-comparer@1";
Expand All @@ -12,7 +15,13 @@ public string Type
set => _ = value;
}

/// <summary>
/// Repository property. Currently, only `Name`, and `Location` are supported.
/// </summary>
public string? Property { get; set; }


/// <summary>
/// The weight of this comparer. The higher the weight, the higher the priority.
/// </summary>
public int Weight { get; set; }
}
34 changes: 22 additions & 12 deletions tests/RepoM.Plugin.Misc.Tests/Configuration/DocsAppSettingsTests.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
namespace RepoM.Plugin.Misc.Tests.Configuration;

using System.Collections.Generic;
using System.IO.Abstractions.TestingHelpers;
using System.Text;
using System.Threading.Tasks;
using FakeItEasy;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using NuDoq;
using RepoM.Api.Common;
Expand All @@ -14,24 +14,34 @@ namespace RepoM.Plugin.Misc.Tests.Configuration;
using VerifyXunit;
using Xunit;

internal static class MockFileSystemFactory
{
public static MockFileSystem CreateDefaultFileSystem()
{
return new MockFileSystem(new Dictionary<string, MockFileData>()
{
{ "C:\\tmp\\x.tmp", new MockFileData("x") }, // make sure path exists.
});
}

public static IAppDataPathProvider CreateDefaultAppDataProvider()
{
IAppDataPathProvider appDataPathProvider = A.Fake<IAppDataPathProvider>();
A.CallTo(() => appDataPathProvider.AppDataPath).Returns("C:\\tmp\\");
return appDataPathProvider;
}
}

[UsesVerify]
public class DocsAppSettingsTests
{
private readonly IAppDataPathProvider _appDataPathProvider;
private FileAppSettingsService _fileBasedPackageConfiguration;
private MockFileSystem _fileSystem;
private ILogger _logger;
private readonly MockFileSystem _fileSystem;

public DocsAppSettingsTests()
{
_appDataPathProvider = A.Fake<IAppDataPathProvider>();
A.CallTo(() => _appDataPathProvider.AppDataPath).Returns("C:\\tmp\\");
_fileSystem = new MockFileSystem(new J2N.Collections.Generic.Dictionary<string, MockFileData>()
{
{ "C:\\tmp\\x.tmp", new MockFileData("x") }, // make sure path exists.
});
_logger = NullLogger.Instance;
_fileBasedPackageConfiguration = new FileAppSettingsService(_appDataPathProvider, _fileSystem, _logger);
_fileSystem = MockFileSystemFactory.CreateDefaultFileSystem();
_fileBasedPackageConfiguration = new FileAppSettingsService(MockFileSystemFactory.CreateDefaultAppDataProvider(), _fileSystem, NullLogger.Instance);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@ namespace RepoM.Plugin.Misc.Tests.Configuration;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using FakeItEasy;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using NuDoq;
using RepoM.Api.Plugins;
using RepoM.Core.Plugin;
using RepoM.Core.Plugin.Common;
using RepoM.Plugin.Misc.Tests.TestFramework.NuDoc;
using VerifyTests;
using VerifyXunit;
Expand All @@ -22,21 +19,13 @@ namespace RepoM.Plugin.Misc.Tests.Configuration;
[UsesVerify]
public class DocsModuleSettingsTests
{
private readonly IAppDataPathProvider _appDataPathProvider;
private FileBasedPackageConfiguration _fileBasedPackageConfiguration;
private MockFileSystem _fileSystem;
private ILogger _logger;
private readonly MockFileSystem _fileSystem;

public DocsModuleSettingsTests()
{
_appDataPathProvider = A.Fake<IAppDataPathProvider>();
A.CallTo(() => _appDataPathProvider.AppDataPath).Returns("C:\\tmp\\");
_fileSystem = new MockFileSystem(new J2N.Collections.Generic.Dictionary<string, MockFileData>()
{
{ "C:\\tmp\\x.tmp", new MockFileData("x") }, // make sure path exists.
});
_logger = NullLogger.Instance;
_fileBasedPackageConfiguration = new FileBasedPackageConfiguration(_appDataPathProvider, _fileSystem, _logger, "dummy");
_fileSystem = MockFileSystemFactory.CreateDefaultFileSystem();
_fileBasedPackageConfiguration = new FileBasedPackageConfiguration(MockFileSystemFactory.CreateDefaultAppDataProvider(), _fileSystem, NullLogger.Instance, "dummy");
}

public static IEnumerable<object[]> PackagesTestData => PluginStore.Packages.Select(package => new object[] { package, }).ToArray();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,12 @@ namespace RepoM.Plugin.Misc.Tests.Configuration;

using System;
using System.Collections.Generic;
using System.IO.Abstractions.TestingHelpers;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using FakeItEasy;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using NuDoq;
using RepoM.Api.IO.ModuleBasedRepositoryActionProvider.Data;
using RepoM.Api.Plugins;
using RepoM.Core.Plugin.Common;
using RepoM.Plugin.Misc.Tests.TestFramework.AssemblyAndTypeHelpers;
using RepoM.Plugin.Misc.Tests.TestFramework.NuDoc;
using VerifyTests;
Expand All @@ -23,23 +17,6 @@ namespace RepoM.Plugin.Misc.Tests.Configuration;
[UsesVerify]
public class DocsRepositoryActionsTests
{
private readonly IAppDataPathProvider _appDataPathProvider;
private FileBasedPackageConfiguration _fileBasedPackageConfiguration;
private MockFileSystem _fileSystem;
private ILogger _logger;

public DocsRepositoryActionsTests()
{
_appDataPathProvider = A.Fake<IAppDataPathProvider>();
A.CallTo(() => _appDataPathProvider.AppDataPath).Returns("C:\\tmp\\");
_fileSystem = new MockFileSystem(new J2N.Collections.Generic.Dictionary<string, MockFileData>()
{
{ "C:\\tmp\\x.tmp", new MockFileData("x") }, // make sure path exists.
});
_logger = NullLogger.Instance;
_fileBasedPackageConfiguration = new FileBasedPackageConfiguration(_appDataPathProvider, _fileSystem, _logger, "dummy");
}

public static IEnumerable<object[]> AssemblyTestData => PluginStore.Assemblies.Select(assembly => new object[] { assembly, }).ToArray();

public static IEnumerable<object[]> RepositoryActionsTestData
Expand Down Expand Up @@ -98,24 +75,6 @@ public async Task VerifyChanges()
await Verifier.Verify(results, settings);
}

public class RepositoryTestData
{
public RepositoryTestData(Assembly assembly, Type type)
{
Assembly = assembly;
Type = type;
}

public Assembly Assembly { get; }

public Type Type { get; }

public override string ToString()
{
return Assembly.GetName().Name + "-" + Type.Name;
}
}

[Fact]
public async Task RepositoryActionBaseDocumentationGeneration()
{
Expand Down Expand Up @@ -213,4 +172,22 @@ public async Task DocsRepositoryActionsSettings(RepositoryTestData repositoryAct
Assert.True(true); // this test should only be run in Debug mode.
#endif
}
}

public class RepositoryTestData
{
public RepositoryTestData(Assembly assembly, Type type)
{
Assembly = assembly;
Type = type;
}

public Assembly Assembly { get; }

public Type Type { get; }

public override string ToString()
{
return Assembly.GetName().Name + "-" + Type.Name;
}
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit c434011

Please sign in to comment.