Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code coverage: use nuget package #1737

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
3a20f5b
Add Nuget
martin-strecker-sonarsource Oct 31, 2023
1269fbe
WIP: Remove usused dependencies from BinaryToXmlCoverageReportConverter
martin-strecker-sonarsource Oct 31, 2023
241ca9b
Fix Conv_FailsIfFileConverterReturnsAnErrorCode
martin-strecker-sonarsource Oct 31, 2023
aaf00b9
Remove Conv_HasThreeArguments test
martin-strecker-sonarsource Oct 31, 2023
5c021e2
Remove Initialize_CanGetGetExeToolPathFromSetupConfiguration test
martin-strecker-sonarsource Oct 31, 2023
c1d6d1a
Remove Initialize_CanGetGetExeToolPathFromEnvironmentVariable_FullPat…
martin-strecker-sonarsource Oct 31, 2023
77f0080
Remove Initialize_NoPath_ReturnsFalseAndLogsWarning
martin-strecker-sonarsource Oct 31, 2023
ff71054
Remove Initialize_CanGetGetExeToolPathFromEnvironmentVariable_NoExeIn…
martin-strecker-sonarsource Oct 31, 2023
503d77b
Remove Initialize_CanGetGetExeToolPathFromEnvironmentVariable_FileDoe…
martin-strecker-sonarsource Oct 31, 2023
9445ec5
Adopt Conv_OutputIsCaptured
martin-strecker-sonarsource Oct 31, 2023
95439c7
Remove Conv_FailsIfFileNotFound (duplicate of Conv_OutputIsCaptured)
martin-strecker-sonarsource Oct 31, 2023
67c5f20
Rename test
martin-strecker-sonarsource Oct 31, 2023
e259aba
Fix errors after re-base
martin-strecker-sonarsource Oct 31, 2023
5678ef4
Run Conv_ConvertToXml_ToolConvertsSampleFile in CI
martin-strecker-sonarsource Oct 31, 2023
f0b4391
Fix culture and checksum missmatches
martin-strecker-sonarsource Oct 31, 2023
d35e942
Turn off "includeSkipped" and fix checksum
martin-strecker-sonarsource Oct 31, 2023
3ad7e9b
Add tests for ApplicationCultureInfo
martin-strecker-sonarsource Nov 2, 2023
c79a1aa
Remove "TestFile"
martin-strecker-sonarsource Nov 2, 2023
9b67c1d
Remove CreateVisualStudioSetupConfigurationFactory()
martin-strecker-sonarsource Nov 2, 2023
9ef17b1
Add Conv_ConvertToXml_ToolConvertsSampleFile_ProblematicCulture
martin-strecker-sonarsource Nov 2, 2023
b3097a4
Remove CodeCoverageExeTestMethodAttribute
martin-strecker-sonarsource Nov 2, 2023
e974945
Remove CONV_ERROR_OutputFileNotFound from resource
martin-strecker-sonarsource Nov 2, 2023
fca0d3f
File header
martin-strecker-sonarsource Nov 2, 2023
41044c9
Nameout file after test to avoid collissions
martin-strecker-sonarsource Nov 2, 2023
4db2ccb
Use DoNotParallelize
martin-strecker-sonarsource Nov 2, 2023
728a41c
Unused using
martin-strecker-sonarsource Nov 2, 2023
9a65d56
Unused using, region
martin-strecker-sonarsource Nov 2, 2023
797204d
Apply suggestions from code review
martin-strecker-sonarsource Nov 2, 2023
db680bb
Fix message
martin-strecker-sonarsource Nov 2, 2023
958d79b
using simplification
martin-strecker-sonarsource Nov 3, 2023
48e5bfe
Change to VanguardException
martin-strecker-sonarsource Nov 3, 2023
8bb576b
Formatting
martin-strecker-sonarsource Nov 3, 2023
d53e008
Inline static ConvertBinaryToXml to ConvertToXml
martin-strecker-sonarsource Nov 3, 2023
d496ddc
Add support for file related expetions and tests
martin-strecker-sonarsource Nov 3, 2023
fda2c9f
Fix test file isolation issues
martin-strecker-sonarsource Nov 3, 2023
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
100 changes: 100 additions & 0 deletions Tests/SonarScanner.MSBuild.TFS.Test/ApplicationCultureInfoTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/*
* SonarScanner for .NET
* Copyright (C) 2016-2023 SonarSource SA
* mailto: info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

using System;
using System.Globalization;
using FluentAssertions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SonarScanner.MSBuild.Common;

namespace SonarScanner.MSBuild.TFS.Tests
{
[TestClass]
[DoNotParallelize]
public class ApplicationCultureInfoTests
{
[TestMethod]
public void ApplicationCultureInfoSetAndResetCultureWithUsing()
{
var previous = CultureInfo.DefaultThreadCurrentCulture;
var enUs = CultureInfo.GetCultureInfo("en-US");
var deDe = CultureInfo.GetCultureInfo("de-DE");
CultureInfo.DefaultThreadCurrentCulture = deDe;
try
{
CultureInfo.DefaultThreadCurrentCulture.Should().Be(deDe);
using (new ApplicationCultureInfo(enUs))
{
CultureInfo.DefaultThreadCurrentCulture.Should().Be(enUs);
}
CultureInfo.DefaultThreadCurrentCulture.Should().Be(deDe);
}
finally
{
CultureInfo.DefaultThreadCurrentCulture = previous;
}
}

[TestMethod]
public void ApplicationCultureInfoSetAndResetCultureManual()
{
var previous = CultureInfo.DefaultThreadCurrentCulture;
var enUs = CultureInfo.GetCultureInfo("en-US");
var deDe = CultureInfo.GetCultureInfo("de-DE");
CultureInfo.DefaultThreadCurrentCulture = deDe;
try
{
CultureInfo.DefaultThreadCurrentCulture.Should().Be(deDe);
var sut = new ApplicationCultureInfo(enUs);
CultureInfo.DefaultThreadCurrentCulture.Should().Be(enUs);
sut.Dispose();
CultureInfo.DefaultThreadCurrentCulture.Should().Be(deDe);
}
finally
{
CultureInfo.DefaultThreadCurrentCulture = previous;
}
}

[TestMethod]
[ExpectedException(typeof(InvalidOperationException))]
costin-zaharia-sonarsource marked this conversation as resolved.
Show resolved Hide resolved
public void ApplicationCultureInfoSetAndResetCultureOnFailure()
{
var previous = CultureInfo.DefaultThreadCurrentCulture;
var enUs = CultureInfo.GetCultureInfo("en-US");
var deDe = CultureInfo.GetCultureInfo("de-DE");
CultureInfo.DefaultThreadCurrentCulture = deDe;
try
{
CultureInfo.DefaultThreadCurrentCulture.Should().Be(deDe);
using (new ApplicationCultureInfo(enUs))
{
CultureInfo.DefaultThreadCurrentCulture.Should().Be(enUs);
throw new InvalidOperationException();
}
}
finally
{
CultureInfo.DefaultThreadCurrentCulture.Should().Be(deDe);
CultureInfo.DefaultThreadCurrentCulture = previous;
}
}
}
}
Loading