From 80d2427fca6617ec594bc0daaf8933af7b87fcbd Mon Sep 17 00:00:00 2001 From: Frans van Dorsselaer <17404029+dorssel@users.noreply.github.com> Date: Thu, 21 Nov 2024 21:00:53 +0100 Subject: [PATCH] Add unit tests --- Directory.Build.props | 2 -- UnitTests/TaskTests.cs | 39 +++++++++++++++++++++++++++++++++++++ UnitTests/Test1.cs | 14 ------------- UnitTests/UnitTests.csproj | 13 +++++++++++++ strongname.snk | Bin 0 -> 1748 bytes strongname.snk.license | 3 +++ 6 files changed, 55 insertions(+), 16 deletions(-) create mode 100644 UnitTests/TaskTests.cs delete mode 100644 UnitTests/Test1.cs create mode 100644 strongname.snk create mode 100644 strongname.snk.license diff --git a/Directory.Build.props b/Directory.Build.props index 4557eab..600219d 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -33,9 +33,7 @@ SPDX-License-Identifier: MIT false false true - true CS1591 diff --git a/UnitTests/TaskTests.cs b/UnitTests/TaskTests.cs new file mode 100644 index 0000000..75cf9b3 --- /dev/null +++ b/UnitTests/TaskTests.cs @@ -0,0 +1,39 @@ +// SPDX-FileCopyrightText: 2024 Frans van Dorsselaer +// +// SPDX-License-Identifier: MIT + +using System.Reflection; + +namespace UnitTests; + +[TestClass] +sealed class TaskTests +{ + public required TestContext TestContext { get; set; } + + static string GetVersionFile() + { + for (var directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + directory is not null; directory = Path.GetDirectoryName(directory)) + { + var file = Path.Combine(directory, "obj", "gitversion.json"); + if (File.Exists(file)) + { + return file; + } + } + throw new FileNotFoundException("gitversion.json"); + } + + [TestMethod] + public void GenerateGitVersionInformation_WithIntermediateOutputPath() + { + var task = new Dorssel.GitVersion.MsBuild.GenerateGitVersionInformation + { + VersionFile = GetVersionFile(), + IntermediateOutputPath = TestContext.TestRunDirectory! + }; + var result = task.Execute(); + Assert.IsTrue(result); + } +} diff --git a/UnitTests/Test1.cs b/UnitTests/Test1.cs deleted file mode 100644 index 982e8f6..0000000 --- a/UnitTests/Test1.cs +++ /dev/null @@ -1,14 +0,0 @@ -// SPDX-FileCopyrightText: 2024 Frans van Dorsselaer -// -// SPDX-License-Identifier: MIT - -namespace UnitTests; - -[TestClass] -sealed class Test1 -{ - [TestMethod] - public void TestMethod1() - { - } -} diff --git a/UnitTests/UnitTests.csproj b/UnitTests/UnitTests.csproj index d2ca74d..deb72ea 100644 --- a/UnitTests/UnitTests.csproj +++ b/UnitTests/UnitTests.csproj @@ -8,6 +8,19 @@ SPDX-License-Identifier: MIT $(MainTargetFramework) + + + true + + true + + + + + + + + diff --git a/strongname.snk b/strongname.snk new file mode 100644 index 0000000000000000000000000000000000000000..416d13303c704844d6c9d9d482121ff9ff345465 GIT binary patch literal 1748 zcmV;_1}pgo0ssI2Bme+XQ$aES3;+ND0098;$q8{J`6gf_BQ@AH^6#<(1NyISQM7az9l^WiM_Kwk3{50^FH(9C+liXES?#BE!hvkOa)8i`3^YTm85uh zg+*50y$gjvA{^59g6Aj^k*{i0W6m_e%J4cs(XzsA-*J7pF}FrDxezObR+-x=n=Fn@ z7ZC2^DtXgj{FOe3EmtDlI8mj{%~qGe0_0Um7?8mK9zYER3QcbM`;KDeo%bW3+Dit7 zZaTXc*s~=t#6K$k{9T2|nUk19$g|=-KexhYv-V{(&+QX$(J=f)n*oA)a zOpP>2RKT|uU0y*0u<%fd3m2}Bk6)K{K+g@j37_pn25{9>ST~Te#*X0D8v*6zK0u2f zEK~2mMHlxC>AFjsHH@_?1BFK0-h%|FZwTZ1WBj@}L5*UwYJrw&?s~wK-J=wlx4frT za)@Yi4gTYL>_;C^8IB8eDIVb~pxWB+WBtI-AmK<|Cdp{McW#!*#~GB*RiLPBIW79j z3P>sdmN1SgpOw015s!mI7jSF}uKhs*T+}E>3+6VHNe74}I08c6 zl-Y(0OUavkrUE%Wk{S>}xs#!ju>Z+XIP%?zP#cWy=#Azz&{_Bv*edO@lUDo{%QX=+ozX(tOT`*Oydc`e& z>TiC^FTspnHWS1x|QE!w?bBGST>Sc5dV5wWr_UsLpaHd$WSJo+&T-$GwXKxe!{BJvT;*|o+ zVmC8GQjo)Z1Zff*u%-4SDp49vxu&~Xw2#I|xGsR@h#>3wv=Ol%G;-&-s&bd;iAv|B z6Uo_%v4(Q6-`6DOT<>q52>$uZZ;p3`4?W*B}B8M<}?TaRv{|Dfxgy-j$<@q zXEAp2(5tT#4s8Q@6smn`u2Y4J#*s_apGd0Rs>HF)aA$>2*lP|#JQ{IZrYM0Y5iKh{~$tHl?=Kgx+ z4QqueF&jRt3M0%gE(s^CTx{z!!vt8pOEnP7QFg}1gqbaM9uN0)#!j z3vcO`_QL5Ntg6jBUhO73h2(yRSmR+@qNe|bA)SXtMd5)bz{&On!hR%;4jTt&N{`7c zKUygZMEDClD(w5~N_;LqD`Lt4!m*H%`GH{r6L+}LxiNCH{Ba*9XKnhW!Kqm9jTuGb z8=h4!`xFy)x~tH04Y!iy2IM7XTCvH^8h|r@E_R|5Poo}TGj;-11Ry} zkVtv;KEpIHxueqYx<%WOd*^dgHd)(%v8#nN0XGS9y+Gh? z8Zn~a=ZW))aUT4R=fG1>3L!yA#Kb<%$UW5s)pT_f3?rp9aCT_nNvY<<`R@!u0Ct@KK?ODzBvv#D= z@=>v`$kVXDZBS)zi@e`kAY(i&#qn2cAmK%Uvx7>-3{oC#!c)%xO|;?Lg# qHmy27oZ+xVwOKqgwkq7K7wz&m>6`bg`wk7((+;jl1L|ls49>NX^jN?E literal 0 HcmV?d00001 diff --git a/strongname.snk.license b/strongname.snk.license new file mode 100644 index 0000000..a454b11 --- /dev/null +++ b/strongname.snk.license @@ -0,0 +1,3 @@ +SPDX-FileCopyrightText: 2024 Frans van Dorsselaer + +SPDX-License-Identifier: MIT