From 22a7e9aeeaa634ce016f265e0c53cef2fac61da5 Mon Sep 17 00:00:00 2001 From: Aleksandr Petrovskiy Date: Fri, 17 Nov 2023 16:34:43 +0300 Subject: [PATCH] changed in dotnet --- .config/dotnet-tools.json | 12 ++ .github/workflows/workflow.yml | 70 ++++++----- .gitignore | 6 +- init_and_run.sh | 110 ++++++++++++++++++ run_ci.sh | 8 ++ .../CombinationSum/solution.cs | 7 +- .../NumberOfRecentCalls/20201001-20201007.cs | 31 ++--- .../NumberOfRecentCalls/code.cs | 10 +- .../solution.cs | 7 +- .../solution.cs | 21 ++-- .../easy/ClimbingStairs/ClimbingStairs.cs | 19 ++- .../easy/DegreeOfAnArray/DegreeOfAnArray.cs | 7 +- .../easy/MajorityElement/MajorityElement.cs | 7 +- .../easy/MaximumSubarray/MaximumSubarray.cs | 6 +- .../problems/medium/GasStation/solution.cs | 8 +- .../LongestIncreasingSubsequence.cs | 6 +- src/main/main.csproj | 12 +- src/stylecop.json | 9 ++ src/test/allureConfig.json | 1 + .../CombinationSum/CombinaitonSumTest.cs | 9 +- .../NumberOfRecentCallsTest.cs | 6 +- .../challenges/c20201001_20201007/SomeTest.cs | 7 +- .../easy/ClimbingStairs/ClimbingStairsTest.cs | 31 +++-- .../DegreeOfAnArray/DegreeOfAnArrayTest.cs | 5 +- .../MajorityElement/MajorityElementTest.cs | 7 +- .../medium/GasStation/GasStationTest.cs | 13 ++- src/test/test.csproj | 22 +++- testLeCo.sln | 26 ++--- 28 files changed, 363 insertions(+), 120 deletions(-) create mode 100644 .config/dotnet-tools.json create mode 100755 init_and_run.sh create mode 100755 run_ci.sh create mode 100644 src/stylecop.json diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json new file mode 100644 index 000000000..3fe9ed153 --- /dev/null +++ b/.config/dotnet-tools.json @@ -0,0 +1,12 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "dotnet-format": { + "version": "7.4.452404", + "commands": [ + "dotnet-format" + ] + } + } +} \ No newline at end of file diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index da03e92ea..e1ab354f5 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -261,52 +261,48 @@ jobs: # name: allure-reports # path: allure-reports - dotnet-format: - runs-on: ubuntu-latest - steps: - - name: Checkout repo - uses: actions/checkout@v2 + # dotnet-format: + # runs-on: ubuntu-latest + # steps: + # - name: Checkout repo + # uses: actions/checkout@v2 - - name: Add dotnet-format problem matcher - uses: xt0rted/dotnet-format-problem-matcher@v1 + # - name: Add dotnet-format problem matcher + # uses: xt0rted/dotnet-format-problem-matcher@v1 - - name: Restore dotnet tools - uses: xt0rted/dotnet-tool-restore@v1 + # - name: Restore dotnet tools + # uses: xt0rted/dotnet-tool-restore@v1 - - name: Run dotnet format - uses: xt0rted/dotnet-format@v1 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} + # - name: Run dotnet format + # uses: xt0rted/dotnet-format@v1 + # with: + # repo-token: ${{ secrets.GITHUB_TOKEN }} dotnet: runs-on: ubuntu-latest needs: - build # - dotnet-format steps: - - uses: actions/checkout@v2 - - uses: ./.github/actions/allure-prep - - name: Setup .NET - uses: actions/setup-dotnet@v1 - if: always() - with: - dotnet-version: 7.0.x - - name: Print donten version - if: always() - run: dotnet --version - - name: Restore dependencies - if: always() - run: dotnet restore - # - name: dotnet - format check - # if: always() - # run: | - # run: dotnet tool update -g dotnet-format - # dotnet-format --check - - name: Build - if: always() - run: dotnet build --no-restore - - name: Test - if: always() - run: dotnet test --no-build --verbosity normal + - uses: actions/checkout@v3 + - uses: ./.github/actions/allure-prep + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 7.0.x + - name: Restore dependencies + run: dotnet restore + - name: Install dotnet-format + run: | + dotnet tool uninstall dotnet-format + dotnet tool install dotnet-format --version "7.*" --add-source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet7/nuget/v3/index.json + # - name: Restore dotnet tools + # run: dotnet tool restore + - name: Check formatting + run: dotnet format --verify-no-changes -v d + - name: Build + run: dotnet build --no-restore + - name: Test + run: dotnet test --no-build --verbosity normal - name: Look at Allure if: always() diff --git a/.gitignore b/.gitignore index d8e5f5b9a..34bea17df 100644 --- a/.gitignore +++ b/.gitignore @@ -933,7 +933,7 @@ dmypy.json ### Ruby ### *.gem *.rbc -/.config +# /.config /coverage/ /InstalledFiles /pkg/ @@ -1198,8 +1198,8 @@ build .metals/metals.h2.db .metals/metals.lock.db .bloop/ -.bloop/CodeSignTest.json -.bloop/CodeSignTest-test.json +.bloop/testLeCo.json +.bloop/testLeCo-test.json allure-reports/* allure-results/* diff --git a/init_and_run.sh b/init_and_run.sh new file mode 100755 index 000000000..57453c835 --- /dev/null +++ b/init_and_run.sh @@ -0,0 +1,110 @@ +#!/bin/sh + +FULL_RESTORE=0 +# 0 - runs code operations without the Internet +# 1 - reloads packages + +rm allure-results/* -y + +SOLUTION_NAME=testLeCo +ROOT_FOLDER=src +MAIN_PRJ_NAME=main +MAIN_PRJ_FOLDER="${ROOT_FOLDER}/${MAIN_PRJ_NAME}" +MAIN_PRJ_FILE="${MAIN_PRJ_FOLDER}/${MAIN_PRJ_NAME}.csproj" +MAIN_PRJ_TMP_FILE="${MAIN_PRJ_FOLDER}/main.tmp" +TEST_PRJ_NAME=test +TEST_PRJ_FOLDER="${ROOT_FOLDER}/${TEST_PRJ_NAME}" +TEST_PRJ_FILE="${TEST_PRJ_FOLDER}/${TEST_PRJ_NAME}.csproj" +TEST_PRJ_TMP_FILE="${TEST_PRJ_FOLDER}/test.tmp" +# the allure config item +ALLURE_CONFIG_FILE_NAME=allureConfig.json +ALLURE_CONFIG_FILE_PATH=${TEST_PRJ_FOLDER}/${ALLURE_CONFIG_FILE_NAME} +ALLURE_CONFIG_CONTENT="{\n \"allure\": {\n \"directory\": \"../../../../../allure-results\"\n }\n}\n" +ALLURE_ITEM_GROUP="\n \n \n Always\n \n \n" +# stylecop +STYLECOP_ITEM_GROUP=" \n \n \n" +PROJECT_TAG="" + +rm -f "${TEST_PRJ_FILE}" +rm -f "${TEST_PRJ_FOLDER}/Class1.cs" +rm -f "${MAIN_PRJ_FILE}" +rm -f "${MAIN_PRJ_FOLDER}/Class1.cs" +rm -f "${SOLUTION_NAME}.sln" + +dotnet new sln --name "${SOLUTION_NAME}" +dotnet new classlib --name "${MAIN_PRJ_NAME}" --framework net7.0 --output "${MAIN_PRJ_FOLDER}" +dotnet new classlib --name "${TEST_PRJ_NAME}" --framework net7.0 --output "${TEST_PRJ_FOLDER}" +dotnet sln add "${MAIN_PRJ_FILE}" +dotnet sln add "${TEST_PRJ_FILE}" +dotnet add "${TEST_PRJ_FILE}" reference "${MAIN_PRJ_FILE}" + +rm -f "${TEST_PRJ_FOLDER}/Class1.cs" +rm -f "${MAIN_PRJ_FOLDER}/Class1.cs" + +# formatting +dotnet add "${MAIN_PRJ_FOLDER}" package Stylecop.Analyzers +dotnet add "${TEST_PRJ_FOLDER}" package Stylecop.Analyzers + +# testing +dotnet add "${TEST_PRJ_FOLDER}" package Microsoft.NET.Test.Sdk +dotnet add "${TEST_PRJ_FOLDER}" package coverlet.collector +dotnet add "${TEST_PRJ_FOLDER}" package NUnit +dotnet add "${TEST_PRJ_FOLDER}" package NUnit3TestAdapter +dotnet add "${TEST_PRJ_FOLDER}" package NUnit.Allure +dotnet add "${TEST_PRJ_FOLDER}" package NUnit.Allure.Steps +# +dotnet add "${TEST_PRJ_FOLDER}" package xunit +dotnet add "${TEST_PRJ_FOLDER}" package xunit.runner.visualstudio +dotnet add "${TEST_PRJ_FOLDER}" package Allure.XUnit +# +dotnet add "${TEST_PRJ_FOLDER}" package MSTest.TestAdapter +dotnet add "${TEST_PRJ_FOLDER}" package MSTest.TestFramework +# +dotnet add "${TEST_PRJ_FOLDER}" package Allure.Commons +dotnet add "${TEST_PRJ_FOLDER}" package NUnit.Analyzers +# +dotnet add "${TEST_PRJ_FOLDER}" package FluentAssertions +dotnet add "${TEST_PRJ_FOLDER}" package Shouldly +# +########## + +echo "${ALLURE_CONFIG_CONTENT}" >"${ALLURE_CONFIG_FILE_PATH}" + +echo "=============================" +cat "${ALLURE_CONFIG_FILE_PATH}" +echo "=============================" +echo "${ALLURE_ITEM_GROUP}" +echo "=============================" +echo "${STYLECOP_ITEM_GROUP}" +echo "=============================" +echo "${PROJECT_TAG}" + +# main prj +sed '$d' "${MAIN_PRJ_FILE}" +tail -r "${MAIN_PRJ_FILE}" | tail -n +3 | tail -r >"${MAIN_PRJ_TMP_FILE}" +{ + echo "${STYLECOP_ITEM_GROUP}" + echo "${PROJECT_TAG}" +} >>"${MAIN_PRJ_TMP_FILE}" +mv "${MAIN_PRJ_TMP_FILE}" "${MAIN_PRJ_FILE}" + +# test prj +sed '$d' "${TEST_PRJ_FILE}" +tail -r "${TEST_PRJ_FILE}" | tail -n +3 | tail -r >"${TEST_PRJ_TMP_FILE}" +{ + echo "${ALLURE_ITEM_GROUP}" + echo "${STYLECOP_ITEM_GROUP}" + echo "${PROJECT_TAG}" +} >>"${TEST_PRJ_TMP_FILE}" +mv "${TEST_PRJ_TMP_FILE}" "${TEST_PRJ_FILE}" + +if [ "${FULL_RESTORE}" = 1 ]; then + echo "cleanin... ===========" + dotnet clean + dotnet restore +fi +# install from here: dotnet tool install dotnet-format --version "7.*" --add-source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet7/nuget/v3/index.json +dotnet tool restore +dotnet format -v d +dotnet build --no-restore +dotnet test --no-build --verbosity normal diff --git a/run_ci.sh b/run_ci.sh new file mode 100755 index 000000000..a0dcb3df6 --- /dev/null +++ b/run_ci.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +dotnet clean +dotnet restore +dotnet format --verify-no-changes -v d +dotnet build --no-restore + +dotnet test diff --git a/src/main/java/challenges/c20201001_20201007/CombinationSum/solution.cs b/src/main/java/challenges/c20201001_20201007/CombinationSum/solution.cs index 7c4a75b14..16571195e 100644 --- a/src/main/java/challenges/c20201001_20201007/CombinationSum/solution.cs +++ b/src/main/java/challenges/c20201001_20201007/CombinationSum/solution.cs @@ -1,6 +1,11 @@ -namespace challenges.c20201001_20201007.CombinationSum +// +// Copyright (c) PlaceholderCompany. All rights reserved. +// + +namespace Challenges.C20201001_20201007.CombinationSum { using System.Collections.Generic; + public class Solution { public IList> CombinationSum(int[] candidates, int target) diff --git a/src/main/java/challenges/c20201001_20201007/NumberOfRecentCalls/20201001-20201007.cs b/src/main/java/challenges/c20201001_20201007/NumberOfRecentCalls/20201001-20201007.cs index 62110677a..e4069e3d6 100644 --- a/src/main/java/challenges/c20201001_20201007/NumberOfRecentCalls/20201001-20201007.cs +++ b/src/main/java/challenges/c20201001_20201007/NumberOfRecentCalls/20201001-20201007.cs @@ -1,4 +1,8 @@ -namespace challenges.c20201001_20201007.NumberOfRecentCalls +// +// Copyright (c) PlaceholderCompany. All rights reserved. +// + +namespace Challenges.C20201001_20201007.NumberOfRecentCalls { using System; using System.Collections.Generic; @@ -8,30 +12,31 @@ public class RecentCounter private const int MaximumTime = 3000; private int counter; private List requests; + public RecentCounter() { - counter = 0; - requests = new List(); + this.counter = 0; + this.requests = new List(); } public int Ping(int t) { - requests.Add(t); + this.requests.Add(t); var sum = 0; - counter = 0; - for (var i = requests.Count - 1; i >= 0; i--) + this.counter = 0; + for (var i = this.requests.Count - 1; i >= 0; i--) { - sum += requests[i]; - Console.WriteLine($"req -> {requests[i]}"); - counter++; - Console.WriteLine($"counter -> {counter}"); - if (MaximumTime <= sum) + sum += this.requests[i]; + Console.WriteLine($"req -> {this.requests[i]}"); + this.counter++; + Console.WriteLine($"counter -> {this.counter}"); + if (sum >= MaximumTime) { break; } } - return counter; + + return this.counter; } } - } \ No newline at end of file diff --git a/src/main/java/challenges/c20201001_20201007/NumberOfRecentCalls/code.cs b/src/main/java/challenges/c20201001_20201007/NumberOfRecentCalls/code.cs index 218615fae..b43d0e874 100644 --- a/src/main/java/challenges/c20201001_20201007/NumberOfRecentCalls/code.cs +++ b/src/main/java/challenges/c20201001_20201007/NumberOfRecentCalls/code.cs @@ -1,12 +1,16 @@ +// +// Copyright (c) PlaceholderCompany. All rights reserved. +// + /* public class RecentCounter { public RecentCounter() { - + } - + public int Ping(int t) { - + } } */ diff --git a/src/main/java/challenges/c20210101_20210107/CheckArrayFormationThroughConcatenation/solution.cs b/src/main/java/challenges/c20210101_20210107/CheckArrayFormationThroughConcatenation/solution.cs index 4ac9a9772..d1707ca6c 100644 --- a/src/main/java/challenges/c20210101_20210107/CheckArrayFormationThroughConcatenation/solution.cs +++ b/src/main/java/challenges/c20210101_20210107/CheckArrayFormationThroughConcatenation/solution.cs @@ -1,6 +1,9 @@ -namespace challenges.c20210101_20210107.CheckArrayFormationThroughConcatenation +// +// Copyright (c) PlaceholderCompany. All rights reserved. +// + +namespace Challenges.C20210101_20210107.CheckArrayFormationThroughConcatenation { - public class Solution { public bool CanFormArray(int[] arr, int[][] pieces) diff --git a/src/main/java/challenges/c20210101_20210107/FindACorrespondingNodeOfABinaryTreeInACloneOfThatTree/solution.cs b/src/main/java/challenges/c20210101_20210107/FindACorrespondingNodeOfABinaryTreeInACloneOfThatTree/solution.cs index ac12646f9..f81465f03 100644 --- a/src/main/java/challenges/c20210101_20210107/FindACorrespondingNodeOfABinaryTreeInACloneOfThatTree/solution.cs +++ b/src/main/java/challenges/c20210101_20210107/FindACorrespondingNodeOfABinaryTreeInACloneOfThatTree/solution.cs @@ -1,15 +1,22 @@ -namespace challenges.c20210101_20210107.FindACorrespondingNodeOfABinaryTreeInACloneOfThatTree +// +// Copyright (c) PlaceholderCompany. All rights reserved. +// + +namespace Challenges.C20210101_20210107.FindACorrespondingNodeOfABinaryTreeInACloneOfThatTree { // Definition for a binary tree node. public class TreeNode { - public int val; - public TreeNode left; - public TreeNode right; - public TreeNode(int x) { val = x; } - } - + public int Val; + public TreeNode Left; + public TreeNode Right; + public TreeNode(int x) + { + this.Val = x; + } + } + public class Solution { public TreeNode GetTargetCopy(TreeNode original, TreeNode cloned, TreeNode target) diff --git a/src/main/java/problems/easy/ClimbingStairs/ClimbingStairs.cs b/src/main/java/problems/easy/ClimbingStairs/ClimbingStairs.cs index 753c7998d..9ffd65be4 100644 --- a/src/main/java/problems/easy/ClimbingStairs/ClimbingStairs.cs +++ b/src/main/java/problems/easy/ClimbingStairs/ClimbingStairs.cs @@ -1,18 +1,31 @@ -namespace problems.easy.ClimbingStairs +// +// Copyright (c) PlaceholderCompany. All rights reserved. +// + +namespace Problems.Easy.ClimbingStairs { public class Solution { public int ClimbStairs(int n) { - if (1 == n) + if (n == 1) + { return 1; - if (2 == n) + } + + if (n == 2) + { return 2; + } + var values = new int[n]; values[0] = 1; values[1] = 2; for (var i = 2; i < n; i++) + { values[i] = values[i - 1] + values[i - 2]; + } + return values[n - 1]; } } diff --git a/src/main/java/problems/easy/DegreeOfAnArray/DegreeOfAnArray.cs b/src/main/java/problems/easy/DegreeOfAnArray/DegreeOfAnArray.cs index 1c0f28c27..ba6489ffe 100644 --- a/src/main/java/problems/easy/DegreeOfAnArray/DegreeOfAnArray.cs +++ b/src/main/java/problems/easy/DegreeOfAnArray/DegreeOfAnArray.cs @@ -1,4 +1,7 @@ -namespace problems.easy.DegreeOfAnArray +// +// Copyright (c) PlaceholderCompany. All rights reserved. +// + +namespace Problems.Easy.DegreeOfAnArray { - } \ No newline at end of file diff --git a/src/main/java/problems/easy/MajorityElement/MajorityElement.cs b/src/main/java/problems/easy/MajorityElement/MajorityElement.cs index 7d64731c9..1142e468a 100644 --- a/src/main/java/problems/easy/MajorityElement/MajorityElement.cs +++ b/src/main/java/problems/easy/MajorityElement/MajorityElement.cs @@ -1,4 +1,7 @@ -namespace problems.easy.MajorityElement -{ +// +// Copyright (c) PlaceholderCompany. All rights reserved. +// +namespace Problems.Easy.MajorityElement +{ } diff --git a/src/main/java/problems/easy/MaximumSubarray/MaximumSubarray.cs b/src/main/java/problems/easy/MaximumSubarray/MaximumSubarray.cs index 96ad346f3..550e97a0e 100644 --- a/src/main/java/problems/easy/MaximumSubarray/MaximumSubarray.cs +++ b/src/main/java/problems/easy/MaximumSubarray/MaximumSubarray.cs @@ -1,4 +1,8 @@ -namespace problems.easy.MaximumSubarray +// +// Copyright (c) PlaceholderCompany. All rights reserved. +// + +namespace Problems.Easy.MaximumSubarray { public class Solution { diff --git a/src/main/java/problems/medium/GasStation/solution.cs b/src/main/java/problems/medium/GasStation/solution.cs index 38cd9531e..6d29ba1dd 100644 --- a/src/main/java/problems/medium/GasStation/solution.cs +++ b/src/main/java/problems/medium/GasStation/solution.cs @@ -1,4 +1,8 @@ -namespace problems.medium.GasStation +// +// Copyright (c) PlaceholderCompany. All rights reserved. +// + +namespace Problems.Medium.GasStation { using System.Linq; @@ -10,7 +14,9 @@ public int CanCompleteCircuit(int[] gas, int[] cost) .Select(index => gas[index] - cost[index]) .ToList(); if (differences.Sum() < 0) + { return -1; + } var starting = 0; var tank = 0; diff --git a/src/main/java/problems/medium/LongestIncreasingSubsequence/LongestIncreasingSubsequence.cs b/src/main/java/problems/medium/LongestIncreasingSubsequence/LongestIncreasingSubsequence.cs index 6e3273038..99711694f 100644 --- a/src/main/java/problems/medium/LongestIncreasingSubsequence/LongestIncreasingSubsequence.cs +++ b/src/main/java/problems/medium/LongestIncreasingSubsequence/LongestIncreasingSubsequence.cs @@ -1,4 +1,8 @@ -namespace problems.medium.LongestIncreasingSubsequence +// +// Copyright (c) PlaceholderCompany. All rights reserved. +// + +namespace Problems.Medium.LongestIncreasingSubsequence { public class Solution { diff --git a/src/main/main.csproj b/src/main/main.csproj index 4658cbfed..68eb98ba6 100644 --- a/src/main/main.csproj +++ b/src/main/main.csproj @@ -6,4 +6,14 @@ enable - + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + diff --git a/src/stylecop.json b/src/stylecop.json new file mode 100644 index 000000000..2535af18a --- /dev/null +++ b/src/stylecop.json @@ -0,0 +1,9 @@ +{ + "settings": { + "documentationRules": { + "documentInterfaces": false, + "documentExposedElements": false, + "documentInternalElements": false + } + } +} diff --git a/src/test/allureConfig.json b/src/test/allureConfig.json index c3f53134d..2704e6e11 100644 --- a/src/test/allureConfig.json +++ b/src/test/allureConfig.json @@ -3,3 +3,4 @@ "directory": "../../../../../allure-results" } } + diff --git a/src/test/java/challenges/c20201001_20201007/CombinationSum/CombinaitonSumTest.cs b/src/test/java/challenges/c20201001_20201007/CombinationSum/CombinaitonSumTest.cs index 72927910f..b75a7f781 100644 --- a/src/test/java/challenges/c20201001_20201007/CombinationSum/CombinaitonSumTest.cs +++ b/src/test/java/challenges/c20201001_20201007/CombinationSum/CombinaitonSumTest.cs @@ -1,7 +1,10 @@ -namespace challenges.c20201001_20201007.CombinationSum +// +// Copyright (c) PlaceholderCompany. All rights reserved. +// + +namespace Challenges.C20201001_20201007.CombinationSum { - class CombinationSumTest + internal class CombinationSumTest { - } } diff --git a/src/test/java/challenges/c20201001_20201007/NumberOfRecentCalls/NumberOfRecentCallsTest.cs b/src/test/java/challenges/c20201001_20201007/NumberOfRecentCalls/NumberOfRecentCallsTest.cs index 68a5bdd0a..26926a10c 100644 --- a/src/test/java/challenges/c20201001_20201007/NumberOfRecentCalls/NumberOfRecentCallsTest.cs +++ b/src/test/java/challenges/c20201001_20201007/NumberOfRecentCalls/NumberOfRecentCallsTest.cs @@ -1,4 +1,8 @@ -namespace challenges.c20201001_20201007.NumberOfRecentCalls +// +// Copyright (c) PlaceholderCompany. All rights reserved. +// + +namespace Challenges.C20201001_20201007.NumberOfRecentCalls { using System.Linq; using NUnit.Allure.Core; diff --git a/src/test/java/challenges/c20201001_20201007/SomeTest.cs b/src/test/java/challenges/c20201001_20201007/SomeTest.cs index 36ee12f35..5092588e9 100644 --- a/src/test/java/challenges/c20201001_20201007/SomeTest.cs +++ b/src/test/java/challenges/c20201001_20201007/SomeTest.cs @@ -1,6 +1,11 @@ -namespace challenges.c20201001_20201007 +// +// Copyright (c) PlaceholderCompany. All rights reserved. +// + +namespace Challenges.C20201001_20201007 { using NUnit.Framework; + public class SomeTest { [Test] diff --git a/src/test/java/problems/easy/ClimbingStairs/ClimbingStairsTest.cs b/src/test/java/problems/easy/ClimbingStairs/ClimbingStairsTest.cs index ea04e7f42..087fd71c9 100644 --- a/src/test/java/problems/easy/ClimbingStairs/ClimbingStairsTest.cs +++ b/src/test/java/problems/easy/ClimbingStairs/ClimbingStairsTest.cs @@ -1,4 +1,8 @@ -namespace problems.easy.ClimbingStairs +// +// Copyright (c) PlaceholderCompany. All rights reserved. +// + +namespace Problems.Easy.ClimbingStairs { using System.Collections.Generic; using NUnit.Allure.Core; @@ -8,17 +12,7 @@ namespace problems.easy.ClimbingStairs public class ClimbingStairsTest { private Solution cut; - [SetUp] - public void SetUp() - { - cut = new Solution(); - } - - [Test, TestCaseSource(nameof(GetInputData))] - public void ShouldCalculateStairs(int input, int expectedResult) - { - Assert.That(cut.ClimbStairs(input), Is.EqualTo(expectedResult)); - } + public static IEnumerable GetInputData() { yield return new TestCaseData(1, 1); @@ -27,5 +21,18 @@ public static IEnumerable GetInputData() yield return new TestCaseData(4, 5); yield return new TestCaseData(5, 8); } + + [SetUp] + public void SetUp() + { + this.cut = new Solution(); + } + + [Test] + [TestCaseSource(nameof(GetInputData))] + public void ShouldCalculateStairs(int input, int expectedResult) + { + Assert.That(this.cut.ClimbStairs(input), Is.EqualTo(expectedResult)); + } } } \ No newline at end of file diff --git a/src/test/java/problems/easy/DegreeOfAnArray/DegreeOfAnArrayTest.cs b/src/test/java/problems/easy/DegreeOfAnArray/DegreeOfAnArrayTest.cs index 9ad9b3f29..36edfb9c4 100644 --- a/src/test/java/problems/easy/DegreeOfAnArray/DegreeOfAnArrayTest.cs +++ b/src/test/java/problems/easy/DegreeOfAnArray/DegreeOfAnArrayTest.cs @@ -1,2 +1,5 @@ -namespace problems.easy.DegreeOfAnArray; +// +// Copyright (c) PlaceholderCompany. All rights reserved. +// +namespace problems.easy.DegreeOfAnArray; diff --git a/src/test/java/problems/easy/MajorityElement/MajorityElementTest.cs b/src/test/java/problems/easy/MajorityElement/MajorityElementTest.cs index 7d64731c9..1a2b2c7a1 100644 --- a/src/test/java/problems/easy/MajorityElement/MajorityElementTest.cs +++ b/src/test/java/problems/easy/MajorityElement/MajorityElementTest.cs @@ -1,4 +1,7 @@ -namespace problems.easy.MajorityElement -{ +// +// Copyright (c) PlaceholderCompany. All rights reserved. +// +namespace Problems.Easy.MajorityElement +{ } diff --git a/src/test/java/problems/medium/GasStation/GasStationTest.cs b/src/test/java/problems/medium/GasStation/GasStationTest.cs index 9094f4bd8..efc5aaa50 100644 --- a/src/test/java/problems/medium/GasStation/GasStationTest.cs +++ b/src/test/java/problems/medium/GasStation/GasStationTest.cs @@ -1,16 +1,21 @@ -namespace problems.medium.GasStation +// +// Copyright (c) PlaceholderCompany. All rights reserved. +// + +namespace Problems.Medium.GasStation { using NUnit.Allure.Core; using NUnit.Framework; + [AllureNUnit] - class GasStationTest + internal class GasStationTest { private Solution cut; [SetUp] public void SetUp() { - cut = new Solution(); + this.cut = new Solution(); } [TestCase(new int[] { 1, 2, 3, 4, 5 }, new int[] { 3, 4, 5, 1, 2 }, 3)] @@ -18,7 +23,7 @@ public void SetUp() [TestCase(new int[] { 7, 1, 0, 11, 4 }, new int[] { 5, 9, 1, 2, 5 }, 3)] public void TestGasStation(int[] gas, int[] cost, int expectedResult) { - Assert.That(cut.CanCompleteCircuit(gas, cost), Is.EqualTo(expectedResult)); + Assert.That(this.cut.CanCompleteCircuit(gas, cost), Is.EqualTo(expectedResult)); } } } \ No newline at end of file diff --git a/src/test/test.csproj b/src/test/test.csproj index 13ff0fa96..17577ad24 100644 --- a/src/test/test.csproj +++ b/src/test/test.csproj @@ -6,24 +6,30 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all - + + - + - + runtime; build; native; contentfiles; analyzers; buildtransitive all - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive all @@ -41,4 +47,8 @@ + + + + diff --git a/testLeCo.sln b/testLeCo.sln index 1e40a8b81..c18e4b990 100644 --- a/testLeCo.sln +++ b/testLeCo.sln @@ -3,11 +3,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.0.31903.59 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{A0742A13-DC44-48A4-81A6-53AEB93E0F67}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{B08CF47B-1E19-4B78-BCDA-62A6F874FE07}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "main", "src\main\main.csproj", "{A4010920-764F-4FCF-84B0-5C63237BB124}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "main", "src\main\main.csproj", "{1C9F9D2E-D48B-4D24-A65C-2B280486E0CD}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "test", "src\test\test.csproj", "{072D6778-CCF2-411D-9C76-6FFFA9AC6CE6}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "test", "src\test\test.csproj", "{E4D9843B-4B1B-48F3-A7A7-DBFAB92A168D}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -18,17 +18,17 @@ Global HideSolutionNode = FALSE EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {A4010920-764F-4FCF-84B0-5C63237BB124}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A4010920-764F-4FCF-84B0-5C63237BB124}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A4010920-764F-4FCF-84B0-5C63237BB124}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A4010920-764F-4FCF-84B0-5C63237BB124}.Release|Any CPU.Build.0 = Release|Any CPU - {072D6778-CCF2-411D-9C76-6FFFA9AC6CE6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {072D6778-CCF2-411D-9C76-6FFFA9AC6CE6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {072D6778-CCF2-411D-9C76-6FFFA9AC6CE6}.Release|Any CPU.ActiveCfg = Release|Any CPU - {072D6778-CCF2-411D-9C76-6FFFA9AC6CE6}.Release|Any CPU.Build.0 = Release|Any CPU + {1C9F9D2E-D48B-4D24-A65C-2B280486E0CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1C9F9D2E-D48B-4D24-A65C-2B280486E0CD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1C9F9D2E-D48B-4D24-A65C-2B280486E0CD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1C9F9D2E-D48B-4D24-A65C-2B280486E0CD}.Release|Any CPU.Build.0 = Release|Any CPU + {E4D9843B-4B1B-48F3-A7A7-DBFAB92A168D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E4D9843B-4B1B-48F3-A7A7-DBFAB92A168D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E4D9843B-4B1B-48F3-A7A7-DBFAB92A168D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E4D9843B-4B1B-48F3-A7A7-DBFAB92A168D}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(NestedProjects) = preSolution - {A4010920-764F-4FCF-84B0-5C63237BB124} = {A0742A13-DC44-48A4-81A6-53AEB93E0F67} - {072D6778-CCF2-411D-9C76-6FFFA9AC6CE6} = {A0742A13-DC44-48A4-81A6-53AEB93E0F67} + {1C9F9D2E-D48B-4D24-A65C-2B280486E0CD} = {B08CF47B-1E19-4B78-BCDA-62A6F874FE07} + {E4D9843B-4B1B-48F3-A7A7-DBFAB92A168D} = {B08CF47B-1E19-4B78-BCDA-62A6F874FE07} EndGlobalSection EndGlobal