From a844323c7e96d7a525b963769c2a8e7db5ea4b61 Mon Sep 17 00:00:00 2001 From: kkm Date: Sun, 7 Oct 2018 00:39:02 -0700 Subject: Rename test classes *Test; UWYU in Tools.Test project --- .../Grpc.Tools.Tests/CSharpGeneratorTests.cs | 7 +-- src/csharp/Grpc.Tools.Tests/CppGeneratorTests.cs | 7 +-- src/csharp/Grpc.Tools.Tests/DepFileUtilTests.cs | 6 +-- src/csharp/Grpc.Tools.Tests/GeneratorTests.cs | 5 +- src/csharp/Grpc.Tools.Tests/NUnitMain.cs | 2 +- .../Grpc.Tools.Tests/ProtoCompileBasicTests.cs | 6 +-- .../ProtoCompileCommandLineGeneratorTests.cs | 5 +- .../ProtoCompileCommandLinePrinterTests.cs | 5 +- .../Grpc.Tools.Tests/ProtoToolsPlatformTaskTest.cs | 53 ---------------------- .../ProtoToolsPlatformTaskTests.cs | 53 ++++++++++++++++++++++ src/csharp/Grpc.Tools.Tests/Utils.cs | 3 -- src/csharp/tests.json | 16 +++---- 12 files changed, 76 insertions(+), 92 deletions(-) delete mode 100644 src/csharp/Grpc.Tools.Tests/ProtoToolsPlatformTaskTest.cs create mode 100644 src/csharp/Grpc.Tools.Tests/ProtoToolsPlatformTaskTests.cs (limited to 'src/csharp') diff --git a/src/csharp/Grpc.Tools.Tests/CSharpGeneratorTests.cs b/src/csharp/Grpc.Tools.Tests/CSharpGeneratorTests.cs index dbffa65d8c..654500d53d 100644 --- a/src/csharp/Grpc.Tools.Tests/CSharpGeneratorTests.cs +++ b/src/csharp/Grpc.Tools.Tests/CSharpGeneratorTests.cs @@ -16,15 +16,10 @@ #endregion -using System.IO; -using Microsoft.Build.Framework; -using Microsoft.Build.Utilities; -using Moq; using NUnit.Framework; namespace Grpc.Tools.Tests { - - public class CSharpGeneratorTests : GeneratorTests { + public class CSharpGeneratorTest : GeneratorTest { GeneratorServices _generator; [SetUp] diff --git a/src/csharp/Grpc.Tools.Tests/CppGeneratorTests.cs b/src/csharp/Grpc.Tools.Tests/CppGeneratorTests.cs index e25a6498cd..a3450fae17 100644 --- a/src/csharp/Grpc.Tools.Tests/CppGeneratorTests.cs +++ b/src/csharp/Grpc.Tools.Tests/CppGeneratorTests.cs @@ -17,13 +17,10 @@ #endregion using System.IO; -using Microsoft.Build.Framework; -using Microsoft.Build.Utilities; -using Moq; using NUnit.Framework; namespace Grpc.Tools.Tests { - public class CppGeneratorTests : GeneratorTests { + public class CppGeneratorTest : GeneratorTest { GeneratorServices _generator; [SetUp] @@ -79,5 +76,5 @@ namespace Grpc.Tools.Tests { Assert.AreEqual(2, poss.Length); Assert.That(Path.GetDirectoryName(poss[0]), Is.EqualTo("out")); } - } + }; } diff --git a/src/csharp/Grpc.Tools.Tests/DepFileUtilTests.cs b/src/csharp/Grpc.Tools.Tests/DepFileUtilTests.cs index 42d0ae5998..ea34c89921 100644 --- a/src/csharp/Grpc.Tools.Tests/DepFileUtilTests.cs +++ b/src/csharp/Grpc.Tools.Tests/DepFileUtilTests.cs @@ -16,15 +16,13 @@ #endregion -using System; using System.IO; -using Grpc.Tools; using Microsoft.Build.Framework; using Microsoft.Build.Utilities; using NUnit.Framework; namespace Grpc.Tools.Tests { - public class DepFileUtilTests { + public class DepFileUtilTest { [Test] public void HashString64Hex_IsSane() { @@ -130,5 +128,5 @@ obj\Release x64\net45\/FooGrpc.cs: C:/usr/include/google/protobuf/wrappers.proto } catch { } } } - } + }; } diff --git a/src/csharp/Grpc.Tools.Tests/GeneratorTests.cs b/src/csharp/Grpc.Tools.Tests/GeneratorTests.cs index 93df9d6cab..52fab1d8ca 100644 --- a/src/csharp/Grpc.Tools.Tests/GeneratorTests.cs +++ b/src/csharp/Grpc.Tools.Tests/GeneratorTests.cs @@ -16,14 +16,13 @@ #endregion -using System.IO; using Microsoft.Build.Framework; using Microsoft.Build.Utilities; using Moq; using NUnit.Framework; namespace Grpc.Tools.Tests { - public class GeneratorTests { + public class GeneratorTest { protected Mock _mockEngine; protected TaskLoggingHelper _log; @@ -47,5 +46,5 @@ namespace Grpc.Tools.Tests { Assert.IsNull(GeneratorServices.GetForLanguage(lang, _log)); _mockEngine.Verify(me => me.LogErrorEvent(It.IsAny()), Times.Once); } - } + }; } diff --git a/src/csharp/Grpc.Tools.Tests/NUnitMain.cs b/src/csharp/Grpc.Tools.Tests/NUnitMain.cs index c4452c50d2..5a8ae8cf87 100644 --- a/src/csharp/Grpc.Tools.Tests/NUnitMain.cs +++ b/src/csharp/Grpc.Tools.Tests/NUnitMain.cs @@ -19,7 +19,7 @@ using System.Reflection; using NUnitLite; -namespace Grps.Tools.Tests { +namespace Grpc.Tools.Tests { static class NUnitMain { public static int Main(string[] args) => #if NETCOREAPP1_0 diff --git a/src/csharp/Grpc.Tools.Tests/ProtoCompileBasicTests.cs b/src/csharp/Grpc.Tools.Tests/ProtoCompileBasicTests.cs index 0660b3e33d..cf9d210424 100644 --- a/src/csharp/Grpc.Tools.Tests/ProtoCompileBasicTests.cs +++ b/src/csharp/Grpc.Tools.Tests/ProtoCompileBasicTests.cs @@ -16,13 +16,13 @@ #endregion -using System.Reflection; +using System.Reflection; // UWYU: Object.GetType() extension. using Microsoft.Build.Framework; using Moq; using NUnit.Framework; namespace Grpc.Tools.Tests { - public class ProtoCompileBasicTests { + public class ProtoCompileBasicTest { // Mock task class that stops right before invoking protoc. public class ProtoCompileTestable : ProtoCompile { public string LastPathToTool { get; private set; } @@ -66,5 +66,5 @@ namespace Grpc.Tools.Tests { Assert.NotNull(pinfo); Assert.That(pinfo, Has.Attribute()); } - } + }; } diff --git a/src/csharp/Grpc.Tools.Tests/ProtoCompileCommandLineGeneratorTests.cs b/src/csharp/Grpc.Tools.Tests/ProtoCompileCommandLineGeneratorTests.cs index fcdff11da4..c5d43f08d9 100644 --- a/src/csharp/Grpc.Tools.Tests/ProtoCompileCommandLineGeneratorTests.cs +++ b/src/csharp/Grpc.Tools.Tests/ProtoCompileCommandLineGeneratorTests.cs @@ -16,13 +16,12 @@ #endregion -using System.Reflection; using Microsoft.Build.Framework; using Moq; using NUnit.Framework; namespace Grpc.Tools.Tests { - internal class ProtoCompileCommandLineGeneratorTests : ProtoCompileBasicTests { + public class ProtoCompileCommandLineGeneratorTest : ProtoCompileBasicTest { [SetUp] public new void SetUp() { _task.Generator = "csharp"; @@ -158,5 +157,5 @@ namespace Grpc.Tools.Tests { Assert.That(_task.LastResponseFile, Does.Contain("--csharp_out=" + expect)); } - } + }; } diff --git a/src/csharp/Grpc.Tools.Tests/ProtoCompileCommandLinePrinterTests.cs b/src/csharp/Grpc.Tools.Tests/ProtoCompileCommandLinePrinterTests.cs index 91cfceaf56..a0406371dc 100644 --- a/src/csharp/Grpc.Tools.Tests/ProtoCompileCommandLinePrinterTests.cs +++ b/src/csharp/Grpc.Tools.Tests/ProtoCompileCommandLinePrinterTests.cs @@ -16,13 +16,12 @@ #endregion -using System.Reflection; using Microsoft.Build.Framework; using Moq; using NUnit.Framework; namespace Grpc.Tools.Tests { - internal class ProtoCompileCommandLinePrinterTests : ProtoCompileBasicTests { + public class ProtoCompileCommandLinePrinterTest : ProtoCompileBasicTest { [SetUp] public new void SetUp() { _task.Generator = "csharp"; @@ -44,5 +43,5 @@ namespace Grpc.Tools.Tests { bool result = _task.Execute(); Assert.IsTrue(result); } - } + }; } diff --git a/src/csharp/Grpc.Tools.Tests/ProtoToolsPlatformTaskTest.cs b/src/csharp/Grpc.Tools.Tests/ProtoToolsPlatformTaskTest.cs deleted file mode 100644 index 3ba0bdfbf6..0000000000 --- a/src/csharp/Grpc.Tools.Tests/ProtoToolsPlatformTaskTest.cs +++ /dev/null @@ -1,53 +0,0 @@ -#region Copyright notice and license - -// Copyright 2018 gRPC authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#endregion - -using System; -using Microsoft.Build.Framework; -using Moq; -using NUnit.Framework; - -namespace Grpc.Tools.Tests { - // This test requires that environment variables be set to the exected - // output of the task in its external test harness: - // PROTOTOOLS_TEST_CPU = { x64 | x86 } - // PROTOTOOLS_TEST_OS = { linux | macosx | windows } - public class ProtoToolsPlatformTaskTests { - static string s_expectOs; - static string s_expectCpu; - - [OneTimeSetUp] - public static void Init() { - s_expectCpu = Environment.GetEnvironmentVariable("PROTOTOOLS_TEST_CPU"); - s_expectOs = Environment.GetEnvironmentVariable("PROTOTOOLS_TEST_OS"); - if (s_expectCpu == null || s_expectOs == null) - Assert.Inconclusive("This test requires PROTOTOOLS_TEST_CPU and " + - "PROTOTOOLS_TEST_OS set in the environment to match the OS it runs on."); - } - - [Test] - public void CpuAndOsMatchExpected() { - var mockEng = new Mock(); - var task = new ProtoToolsPlatform() { - BuildEngine = mockEng.Object - }; - task.Execute(); - Assert.AreEqual(s_expectCpu, task.Cpu); - Assert.AreEqual(s_expectOs, task.Os); - } - }; -} diff --git a/src/csharp/Grpc.Tools.Tests/ProtoToolsPlatformTaskTests.cs b/src/csharp/Grpc.Tools.Tests/ProtoToolsPlatformTaskTests.cs new file mode 100644 index 0000000000..235f8de527 --- /dev/null +++ b/src/csharp/Grpc.Tools.Tests/ProtoToolsPlatformTaskTests.cs @@ -0,0 +1,53 @@ +#region Copyright notice and license + +// Copyright 2018 gRPC authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#endregion + +using System; +using Microsoft.Build.Framework; +using Moq; +using NUnit.Framework; + +namespace Grpc.Tools.Tests { + // This test requires that environment variables be set to the expected + // output of the task in its external test harness: + // PROTOTOOLS_TEST_CPU = { x64 | x86 } + // PROTOTOOLS_TEST_OS = { linux | macosx | windows } + public class ProtoToolsPlatformTaskTest { + static string s_expectOs; + static string s_expectCpu; + + [OneTimeSetUp] + public static void Init() { + s_expectCpu = Environment.GetEnvironmentVariable("PROTOTOOLS_TEST_CPU"); + s_expectOs = Environment.GetEnvironmentVariable("PROTOTOOLS_TEST_OS"); + if (s_expectCpu == null || s_expectOs == null) + Assert.Inconclusive("This test requires PROTOTOOLS_TEST_CPU and " + + "PROTOTOOLS_TEST_OS set in the environment to match the OS it runs on."); + } + + [Test] + public void CpuAndOsMatchExpected() { + var mockEng = new Mock(); + var task = new ProtoToolsPlatform() { + BuildEngine = mockEng.Object + }; + task.Execute(); + Assert.AreEqual(s_expectCpu, task.Cpu); + Assert.AreEqual(s_expectOs, task.Os); + } + }; +} diff --git a/src/csharp/Grpc.Tools.Tests/Utils.cs b/src/csharp/Grpc.Tools.Tests/Utils.cs index 618e335452..bb051a4873 100644 --- a/src/csharp/Grpc.Tools.Tests/Utils.cs +++ b/src/csharp/Grpc.Tools.Tests/Utils.cs @@ -16,10 +16,7 @@ #endregion -using System; -using System.Collections.Generic; using System.Linq; -using System.Text; using Microsoft.Build.Framework; using Microsoft.Build.Utilities; diff --git a/src/csharp/tests.json b/src/csharp/tests.json index 761308b33f..760776f9e7 100644 --- a/src/csharp/tests.json +++ b/src/csharp/tests.json @@ -66,13 +66,13 @@ "Grpc.Reflection.Tests.SymbolRegistryTest" ], "Grpc.Tools.Tests": [ - "Grpc.Tools.Tests.CppGeneratorTests", - "Grpc.Tools.Tests.CSharpGeneratorTests", - "Grpc.Tools.Tests.DepFileUtilTests", - "Grpc.Tools.Tests.GeneratorTests", - "Grpc.Tools.Tests.ProtoCompileBasicTests", - "Grpc.Tools.Tests.ProtoCompileCommandLineGeneratorTests", - "Grpc.Tools.Tests.ProtoCompileCommandLinePrinterTests", - "Grpc.Tools.Tests.ProtoToolsPlatformTaskTests" + "Grpc.Tools.Tests.CppGeneratorTest", + "Grpc.Tools.Tests.CSharpGeneratorTest", + "Grpc.Tools.Tests.DepFileUtilTest", + "Grpc.Tools.Tests.GeneratorTest", + "Grpc.Tools.Tests.ProtoCompileBasicTest", + "Grpc.Tools.Tests.ProtoCompileCommandLineGeneratorTest", + "Grpc.Tools.Tests.ProtoCompileCommandLinePrinterTest", + "Grpc.Tools.Tests.ProtoToolsPlatformTaskTest" ] } -- cgit v1.2.3