Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,32 @@ jobs:
condition: succeeded()
workingDirectory: '$(System.DefaultWorkingDirectory)/tools/DependencyUpdater'

- task: DotNetCoreCLI@2
condition: succeeded()
displayName: 'Running Unit Tests'
inputs:
command: 'test'
projects: |
**/*Tests.csproj
!**/obj/**
!**/bin/**/ref/**
arguments: '--configuration Release --collect "XPlat Code coverage"'
testRunTitle: 'Unit Tests'

# First install the tool on the machine, then run it
- script: |
dotnet tool install -g dotnet-reportgenerator-globaltool
reportgenerator -reports:$(Agent.WorkFolder)/**/coverage.cobertura.xml -targetdir:$(Build.SourcesDirectory)/CodeCoverage "-reporttypes:HtmlInline_AzurePipelines;Cobertura"
displayName: 'Create code coverage report'
condition: always()

- task: PublishCodeCoverageResults@1
displayName: 'Publish code coverage results'
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(Build.SourcesDirectory)/CodeCoverage/Cobertura.xml'
condition: always()

- task: CopyFiles@1
condition: succeeded()
displayName: Collecting deployable artifacts
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0"/>
<PackageReference Include="MSTest.TestAdapter" Version="2.2.8"/>
<PackageReference Include="MSTest.TestFramework" Version="2.2.8"/>
<PackageReference Include="coverlet.collector" Version="3.1.2"/>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\DependencyUpdater.csproj" />
</ItemGroup>

</Project>
32 changes: 32 additions & 0 deletions tools/DependencyUpdater/DependencyUpdater.Tests/ProgramTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// Copyright (c) .NET Foundation and Contributors
// See LICENSE file in the project root for full license information.
//

namespace DependencyUpdater.Tests;

[TestClass]
public class ProgramTests
{
[DataTestMethod]
[DataRow("origin https://github.com/torbacz/nf-tools.git (fetch) origin https://github.com/torbacz/nf-tools.git (push)", "nf-tools")]
[DataRow("origin https://github.com/nanoframework/nf-tools.git (fetch) origin https://github.com/nanoframework/nf-tools.git (push)", "nf-tools")]
public void GetLibNameFromGitString_Should_ReturnValidData(string inputData, string expectedResult)
{
var result = nanoFramework.Tools.DependencyUpdater.Program.GetRepoNameFromInputString(inputData);
Assert.IsTrue(result.Success);

var libName = nanoFramework.Tools.DependencyUpdater.Program.GetLibNameFromRegexMatch(result);
Assert.AreEqual(expectedResult, libName);
}

[DataTestMethod]
[DataRow("origin https://github.com/torbacz/nf-tools.git (fetch) origin https://github.com/torbacz/nf-tools.git (push)", "torbacz")]
[DataRow("origin https://github.com/nanoframework/nf-tools.git (fetch) origin https://github.com/nanoframework/nf-tools.git (push)", "nanoframework")]
[DataRow("origin https://github.com/nanoframework-test/nf-tools.git (fetch) origin https://github.com/nanoframework/nf-tools.git (push)", "nanoframework-test")]
public void GetRepoOwnerFromInputString_Should_ReturnValidData(string inputData, string expectedResult)
{
var result = nanoFramework.Tools.DependencyUpdater.Program.GetRepoOwnerFromInputString(inputData);
Assert.AreEqual(expectedResult, result);
}
}
1 change: 1 addition & 0 deletions tools/DependencyUpdater/DependencyUpdater.Tests/Usings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
global using Microsoft.VisualStudio.TestTools.UnitTesting;
15 changes: 15 additions & 0 deletions tools/DependencyUpdater/DependencyUpdater.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<Pack>True</Pack>
<PackagePath></PackagePath>
</None>
<None Remove="DependencyUpdater.Tests\**" />
</ItemGroup>

<ItemGroup>
Expand All @@ -56,5 +57,19 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>

<ItemGroup>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute">
<_Parameter1>DependencyUpdater.Tests</_Parameter1>
</AssemblyAttribute>
</ItemGroup>

<ItemGroup>
<Compile Remove="DependencyUpdater.Tests\**" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Remove="DependencyUpdater.Tests\**" />
</ItemGroup>

</Project>
6 changes: 6 additions & 0 deletions tools/DependencyUpdater/DependencyUpdater.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ VisualStudioVersion = 17.0.32014.148
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DependencyUpdater", "DependencyUpdater.csproj", "{96810A57-0356-4ED3-91DB-9811A4A553A1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DependencyUpdater.Tests", "DependencyUpdater.Tests\DependencyUpdater.Tests.csproj", "{DFCC960B-6B6E-4A11-B5ED-DA9D1A682CDD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -15,6 +17,10 @@ Global
{96810A57-0356-4ED3-91DB-9811A4A553A1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{96810A57-0356-4ED3-91DB-9811A4A553A1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{96810A57-0356-4ED3-91DB-9811A4A553A1}.Release|Any CPU.Build.0 = Release|Any CPU
{DFCC960B-6B6E-4A11-B5ED-DA9D1A682CDD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DFCC960B-6B6E-4A11-B5ED-DA9D1A682CDD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DFCC960B-6B6E-4A11-B5ED-DA9D1A682CDD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DFCC960B-6B6E-4A11-B5ED-DA9D1A682CDD}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Loading