Skip to content

Commit

Permalink
Moved Cosmos.Build.Common.Tests from Cosmos.
Browse files Browse the repository at this point in the history
Added .editorconfig.
  • Loading branch information
jp2masa committed Oct 29, 2018
1 parent 8b39dfd commit edbf573
Show file tree
Hide file tree
Showing 7 changed files with 183 additions and 0 deletions.
101 changes: 101 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# EditorConfig is awesome:
http://EditorConfig.org

# top-most EditorConfig file
root = true

# Default settings:
# A newline ending every file
# Use tabs as indentation
# Trim trailing whitespace
[*]
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[*.cs]
csharp_style_conditional_delegate_call = true:suggestion
csharp_style_expression_bodied_accessors = true:suggestion
csharp_style_expression_bodied_constructors = false:suggestion
csharp_style_expression_bodied_indexers = true:suggestion
csharp_style_expression_bodied_methods = true:none
csharp_style_expression_bodied_operators = false:none
csharp_style_expression_bodied_properties = true:suggestion
csharp_style_inlined_variable_declaration = true:suggestion
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
csharp_style_throw_expression = true:suggestion
csharp_style_var_elsewhere = true:none
csharp_style_var_for_built_in_types = true:suggestion
csharp_style_var_when_type_is_apparent = true:warning

csharp_indent_block_contents = true:warning
csharp_indent_braces = false:warning
csharp_indent_case_contents = true:warning
csharp_indent_switch_labels = true:warning

csharp_prefer_braces = true:warning
csharp_prefer_simple_default_expression = false:suggestion

csharp_space_after_cast = false:warning
csharp_space_after_keywords_in_control_flow_statements = true
csharp_space_after_colon_in_inheritance_clause = true:warning
csharp_space_after_comma = true:warning
csharp_space_after_dot = false:error
csharp_space_after_semicolon_in_for_statement = true:warning
csharp_space_before_colon_in_inheritance_clause = true:warning
csharp_space_before_comma = false:warning
csharp_space_before_dot = false:error
csharp_space_before_open_square_brackets = true:warning
csharp_space_before_semicolon_in_for_statement = false:error

[*.{cs,vb}]
dotnet_sort_system_directives_first = true

dotnet_style_coalesce_expression = true:warning
dotnet_style_collection_initializer = true:suggestion
dotnet_style_explicit_tuple_names = true:warning
dotnet_style_null_propagation = true:suggestion
dotnet_style_object_initializer = true:suggestion
dotnet_style_predefined_type_for_locals_parameters_members = true:warning
dotnet_style_predefined_type_for_member_access = false:warning
dotnet_style_qualification_for_event = false:warning
dotnet_style_qualification_for_field = false:warning
dotnet_style_qualification_for_method = false:warning

dotnet_naming_style.pascal_case.capitalization = pascal_case

dotnet_naming_style.parameters.capitalization = pascal_case
dotnet_naming_style.parameters.required_prefix = a

dotnet_naming_style.private_fields.capitalization = pascal_case
dotnet_naming_style.private_fields.required_prefix = _

dotnet_naming_style.interfaces.capitalization = pascal_case
dotnet_naming_style.interfaces.required_prefix = I

dotnet_naming_symbols.interfaces.applicable_kinds = interface

dotnet_naming_symbols.pascal_case_definitions.applicable_kinds = class, struct, enum, property, event, delegate

dotnet_naming_symbols.parameters.applicable_kinds = parameter

dotnet_naming_symbols.private_fields.applicable_kinds = field
dotnet_naming_symbols.private_fields.applicable_accessibilities = private

dotnet_naming_rule.interfaces.severity = warning
dotnet_naming_rule.interfaces.symbols = interfaces
dotnet_naming_rule.interfaces.style = interfaces

dotnet_naming_rule.pascal_case_definitions.severity = warning
dotnet_naming_rule.pascal_case_definitions.symbols = pascal_case_definitions
dotnet_naming_rule.pascal_case_definitions.style = pascal_case

dotnet_naming_rule.parameters.severity = suggestion
dotnet_naming_rule.parameters.symbols = parameters
dotnet_naming_rule.parameters.style = parameters

dotnet_naming_rule.private_fields.severity = suggestion
dotnet_naming_rule.private_fields.symbols = private_fields
dotnet_naming_rule.private_fields.style = private_fields
9 changes: 9 additions & 0 deletions Common.sln
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Targets", "Targets", "{B809
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cosmos.Build.Common", "source\Cosmos.Build.Common\Cosmos.Build.Common.csproj", "{9D0F61EB-2DC1-4DA1-A518-52941C237C85}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{008D41A3-3E20-4E93-AC75-28D4A8F5721F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cosmos.Build.Common.Tests", "tests\Cosmos.Build.Common.Tests\Cosmos.Build.Common.Tests.csproj", "{3FC10DCD-6DD5-4CE4-87E3-722BAE7754C1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -29,13 +33,18 @@ Global
{9D0F61EB-2DC1-4DA1-A518-52941C237C85}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9D0F61EB-2DC1-4DA1-A518-52941C237C85}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9D0F61EB-2DC1-4DA1-A518-52941C237C85}.Release|Any CPU.Build.0 = Release|Any CPU
{3FC10DCD-6DD5-4CE4-87E3-722BAE7754C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3FC10DCD-6DD5-4CE4-87E3-722BAE7754C1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3FC10DCD-6DD5-4CE4-87E3-722BAE7754C1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3FC10DCD-6DD5-4CE4-87E3-722BAE7754C1}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{B9B1C468-05AE-4F2E-B380-183C54F09652} = {D9C56F86-6C41-43A2-B501-60B3E5C02603}
{B8097007-F8B9-4F1F-A99A-C51F087EE634} = {B9B1C468-05AE-4F2E-B380-183C54F09652}
{3FC10DCD-6DD5-4CE4-87E3-722BAE7754C1} = {008D41A3-3E20-4E93-AC75-28D4A8F5721F}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D7D38725-20DB-44F3-8033-76C8A96E3F9D}
Expand Down
3 changes: 3 additions & 0 deletions build/Targets/PackageVersions.targets
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@
<PackageReference Update="Microsoft.Build.Framework" Version="$(MicrosoftBuildVersion)" />
<PackageReference Update="Microsoft.Build.Utilities.Core" Version="$(MicrosoftBuildVersion)" />
<PackageReference Update="Microsoft.NETFramework.ReferenceAssemblies" Version="$(MicrosoftNETFrameworkReferenceAssembliesVersion)" />
<PackageReference Update="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkVersion)" />
<PackageReference Update="Microsoft.VisualStudio.ProjectSystem" Version="$(MicrosoftVisualStudioProjectSystemVersion)" />
<PackageReference Update="Microsoft.VisualStudio.ProjectSystem.Analyzers" Version="$(MicrosoftVisualStudioProjectSystemVersion)" />
<PackageReference Update="Microsoft.VisualStudio.SDK.EmbedInteropTypes" Version="$(MicrosoftVisualStudioSdkEmbedInteropTypesVersion)" />
<PackageReference Update="Microsoft.VisualStudio.Threading.Analyzers" Version="$(MicrosoftVisualStudioThreadingAnalyzersVersion)" />
<PackageReference Update="Microsoft.VSSDK.BuildTools" Version="$(MicrosoftVSSDKBuildToolsVersion)" />
<PackageReference Update="MSTest.TestAdapter" Version="$(MSTestVersion)" />
<PackageReference Update="MSTest.TestFramework" Version="$(MSTestVersion)" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 2 additions & 0 deletions build/Targets/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
<RoslynAnalyzersVersion>2.6.2</RoslynAnalyzersVersion>
<MicrosoftBuildVersion>15.8.166</MicrosoftBuildVersion>
<MicrosoftNETFrameworkReferenceAssembliesVersion>1.0.0-alpha-004</MicrosoftNETFrameworkReferenceAssembliesVersion>
<MicrosoftNETTestSdkVersion>15.8.0</MicrosoftNETTestSdkVersion>
<MicrosoftVisualStudioProjectSystemVersion>15.8.243</MicrosoftVisualStudioProjectSystemVersion>
<MicrosoftVisualStudioSdkEmbedInteropTypesVersion>15.0.21</MicrosoftVisualStudioSdkEmbedInteropTypesVersion>
<MicrosoftVisualStudioThreadingAnalyzersVersion>15.8.145</MicrosoftVisualStudioThreadingAnalyzersVersion>
<MicrosoftVSSDKBuildToolsVersion>15.8.3252</MicrosoftVSSDKBuildToolsVersion>
<MSTestVersion>1.3.2</MSTestVersion>
</PropertyGroup>

</Project>
25 changes: 25 additions & 0 deletions tests/Cosmos.Build.Common.Tests/BuildPropertiesTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Cosmos.Build.Common.Tests
{
[TestClass]
public class BuildPropertiesTest
{
[TestMethod]
public void TestParsing()
{
var properties = new BuildProperties();
properties.SetProperty(BuildPropertyNames.StackCorruptionDetectionEnabledString, "False");
Assert.AreEqual(
false,
properties.GetProperty<bool>(BuildPropertyNames.StackCorruptionDetectionEnabledString, true));
Assert.AreEqual(
false,
properties.StackCorruptionDetectionEnabled);
Assert.AreEqual(
"False",
properties.GetProperty(BuildPropertyNames.StackCorruptionDetectionEnabledString));
}
}
}
17 changes: 17 additions & 0 deletions tests/Cosmos.Build.Common.Tests/Cosmos.Build.Common.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="MSTest.TestAdapter" />
<PackageReference Include="MSTest.TestFramework" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\source\Cosmos.Build.Common\Cosmos.Build.Common.csproj" />
</ItemGroup>

</Project>
26 changes: 26 additions & 0 deletions tests/Cosmos.Build.Common.Tests/EnumValueTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Cosmos.Build.Common.Tests
{
[TestClass]
public class EnumValueTest
{
[TestMethod]
public void TestParsing()
{
var actual = EnumValue.Parse("bin", BinFormat.Bin);
Assert.AreEqual(BinFormat.Bin, actual);
actual = EnumValue.Parse("", BinFormat.Bin);
Assert.AreEqual(BinFormat.Bin, actual);
actual = EnumValue.Parse(" 1", BinFormat.Bin);
Assert.AreEqual(BinFormat.Bin, actual);
actual = EnumValue.Parse("elf", BinFormat.Bin);
Assert.AreEqual(BinFormat.Elf, actual);
actual = EnumValue.Parse("Elf", BinFormat.Bin);
Assert.AreEqual(BinFormat.Elf, actual);
actual = EnumValue.Parse("Bin", BinFormat.Bin);
Assert.AreEqual(BinFormat.Bin, actual);
}
}
}

0 comments on commit edbf573

Please sign in to comment.