Skip to content

Commit

Permalink
[Refactor] using System.CommandLine and DI
Browse files Browse the repository at this point in the history
  • Loading branch information
sam.gerene committed Nov 13, 2022
1 parent 5508407 commit 1f8ff63
Show file tree
Hide file tree
Showing 21 changed files with 586 additions and 146 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<Company>RHEA System S.A.</Company>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// -------------------------------------------------------------------------------------------------
// <copyright file="ResourcesTestFixture.cs" company="RHEA System S.A.">
// <copyright file="ResourceLoaderTestFixture.cs" company="RHEA System S.A.">
//
// Copyright 2022 RHEA System S.A.
//
Expand All @@ -20,34 +20,19 @@

namespace NetProjectPackageExtractor.Tests.Resources
{
using System;
using System.Resources;

using NetProjectPackageExtractor.Resources;

using NUnit.Framework;

[TestFixture]
public class ResourcesTestFixture
public class ResourceLoaderTestFixture
{
[SetUp]
public void Setup()
{
this.path = "NetProjectPackageExtractor.Resources.ascii-art.txt";
this.resourceLoader = new ResourceLoader();
}

private string path;
private ResourceLoader resourceLoader;


[Test]
public void LoadEmbeddedResource()
{
var resource = this.resourceLoader.LoadEmbeddedResource(this.path);
Assert.IsNotNull(resource);
Assert.IsNotEmpty(resource);
Assert.Throws<ArgumentNullException>(() => this.resourceLoader.LoadEmbeddedResource(null));
Assert.Throws<MissingManifestResourceException>(() => this.resourceLoader.LoadEmbeddedResource("thispathdoesnotexist"));
Assert.That(ResourceLoader.QueryLogo(), Is.Not.Empty);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@
// </copyright>
// ------------------------------------------------------------------------------------------------

namespace NetProjectPackageExtractor.Tests
namespace NetProjectPackageExtractor.Tests.Services
{
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

using NetProjectPackageExtractor;
using NetProjectPackageExtractor.Services;

using NUnit.Framework;

Expand All @@ -39,23 +37,23 @@ public class NuGetReaderTestFixture

[SetUp]
public void SetUp()
{
this.nuGetReader = new NuGetReader();
{
nuGetReader = new NuGetReader();
}

[Test]
[Category("NugetCache")]
public void Verify_that_nusepc_details_can_be_read_and_packages_are_update()
{
var package = new Package
{
var package = new Package
{
Name = "Microsoft.NET.Test.Sdk",
Version = "17.4.0"
};

var packages = new List<Package>() { package };

this.nuGetReader.Update(packages);
nuGetReader.Update(packages);

Assert.That(package.LicenseUrl, Is.EqualTo("https://aka.ms/deprecateLicenseUrl"));
}
Expand All @@ -72,7 +70,7 @@ public void Verify_that_nusepc_details_can_be_read_and_packages_are_update_2()

var packages = new List<Package>() { package };

this.nuGetReader.Update(packages);
nuGetReader.Update(packages);

Assert.That(package.LicenseUrl, Is.EqualTo("https://licenses.nuget.org/MIT"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
// </copyright>
// ------------------------------------------------------------------------------------------------

namespace NetProjectPackageExtractor.Tests
namespace NetProjectPackageExtractor.Tests.Services
{
using System.IO;
using System.Linq;

using NetProjectPackageExtractor;

using NetProjectPackageExtractor.Services;
using NUnit.Framework;

/// <summary>
Expand All @@ -35,22 +35,22 @@ public class ProjectFileExtractorTestFixture
{
private ProjectFileExtractor projectFileExtractor;

private string rootFolder;
private DirectoryInfo rootFolder;

[SetUp]
public void Setup()
{
this.projectFileExtractor = new ProjectFileExtractor();

this.rootFolder = Path.Combine(TestContext.CurrentContext.TestDirectory, "Root");
rootFolder = new DirectoryInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, "Root"));
}

[Test]
public void Verify_that_The_project_files_are_found()
{
var files = this.projectFileExtractor.QueryProjectFiles(this.rootFolder);
var files = projectFileExtractor.QueryProjectFiles(rootFolder);

Assert.That(files.Count(), Is.EqualTo(3));
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
// </copyright>
// ------------------------------------------------------------------------------------------------

namespace NetProjectPackageExtractor.Tests
namespace NetProjectPackageExtractor.Tests.Services
{
using System.Collections.Generic;
using System.IO;
using System.Linq;

using NetProjectPackageExtractor;
using NetProjectPackageExtractor.Services;

using NUnit.Framework;

Expand All @@ -43,15 +43,15 @@ public void Setup()
{
var projectFile = Path.Combine(TestContext.CurrentContext.TestDirectory, "Root", "root.csproj");

this.projectFiles = new List<FileInfo>() { new FileInfo(projectFile) };
this.projectFileParser = new ProjectFileParser();
projectFiles = new List<FileInfo>() { new FileInfo(projectFile) };

projectFileParser = new ProjectFileParser();
}

[Test]
public void Verify_that_Parser_returns_pacakages()
public void Verify_that_Parser_returns_packages()
{
var package = this.projectFileParser.RunParser(this.projectFiles).Single();
var package = projectFileParser.Parse(projectFiles).Single();

Assert.That(package.ProjectTitle, Is.EqualTo("Root project"));
Assert.That(package.ProjectVersion, Is.EqualTo("0.0.1"));
Expand Down
3 changes: 3 additions & 0 deletions NetProjectPackageExtractor.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String></wpf:ResourceDictionary>
Loading

0 comments on commit 1f8ff63

Please sign in to comment.