Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Grpc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tci-gateway-module
Grpc
Commits
9c3f15c4
Commit
9c3f15c4
authored
9 years ago
by
Jan Tattermusch
Browse files
Options
Downloads
Patches
Plain Diff
improve C# sanity test
parent
38ed2cfd
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/csharp/Grpc.Core.Tests/SanityTest.cs
+14
-14
14 additions, 14 deletions
src/csharp/Grpc.Core.Tests/SanityTest.cs
src/csharp/tests.json
+11
-11
11 additions, 11 deletions
src/csharp/tests.json
with
25 additions
and
25 deletions
src/csharp/Grpc.Core.Tests/SanityTest.cs
+
14
−
14
View file @
9c3f15c4
...
@@ -38,6 +38,7 @@ using System.Reflection;
...
@@ -38,6 +38,7 @@ using System.Reflection;
using
Grpc.Core
;
using
Grpc.Core
;
using
Grpc.Core.Internal
;
using
Grpc.Core.Internal
;
using
Grpc.Core.Utils
;
using
Grpc.Core.Utils
;
using
Newtonsoft.Json
;
using
NUnit.Framework
;
using
NUnit.Framework
;
namespace
Grpc.Core.Tests
namespace
Grpc.Core.Tests
...
@@ -55,27 +56,23 @@ namespace Grpc.Core.Tests
...
@@ -55,27 +56,23 @@ namespace Grpc.Core.Tests
[
Test
]
[
Test
]
public
void
TestsJsonUpToDate
()
public
void
TestsJsonUpToDate
()
{
{
var
testClasse
s
=
DiscoverAllTestClasses
();
var
discoveredTest
s
=
DiscoverAllTestClasses
();
string
testsJson
=
GetTestsJson
(
);
string
discoveredTestsJson
=
JsonConvert
.
SerializeObject
(
discoveredTests
,
Formatting
.
Indented
);
// we don't have a JSON parser at hand, but check that the test class
Assert
.
AreEqual
(
discoveredTestsJson
,
ReadTestsJson
());
// name is contained in the file instead.
foreach
(
var
className
in
testClasses
)
{
Assert
.
IsTrue
(
testsJson
.
Contains
(
className
),
string
.
Format
(
"Test class \"{0}\" is missing in C# tests.json file"
,
className
));
}
}
}
/// <summary>
/// <summary>
/// Gets list of all test classes obtained by inspecting all the test assemblies.
/// Gets list of all test classes obtained by inspecting all the test assemblies.
/// </summary>
/// </summary>
private
List
<
string
>
DiscoverAllTestClasses
()
private
Dictionary
<
string
,
List
<
string
>
>
DiscoverAllTestClasses
()
{
{
var
assemblies
=
GetTestAssemblies
();
var
assemblies
=
GetTestAssemblies
();
var
test
Classes
=
new
List
<
string
>();
var
test
sByAssembly
=
new
Dictionary
<
string
,
List
<
string
>
>
();
foreach
(
var
assembly
in
assemblies
)
foreach
(
var
assembly
in
assemblies
)
{
{
var
testClasses
=
new
List
<
string
>();
foreach
(
var
t
in
assembly
.
GetTypes
())
foreach
(
var
t
in
assembly
.
GetTypes
())
{
{
foreach
(
var
m
in
t
.
GetMethods
())
foreach
(
var
m
in
t
.
GetMethods
())
...
@@ -89,16 +86,19 @@ namespace Grpc.Core.Tests
...
@@ -89,16 +86,19 @@ namespace Grpc.Core.Tests
}
}
}
}
testClasses
.
Sort
();
testsByAssembly
.
Add
(
assembly
.
GetName
().
Name
,
testClasses
);
}
}
testClasses
.
Sort
();
return
testsByAssembly
;
return
testClasses
;
}
}
private
string
GetTestsJson
()
/// <summary>
/// Reads contents of tests.json file.
/// </summary>
private
string
ReadTestsJson
()
{
{
var
assemblyDir
=
Path
.
GetDirectoryName
(
Assembly
.
GetExecutingAssembly
().
Location
);
var
assemblyDir
=
Path
.
GetDirectoryName
(
Assembly
.
GetExecutingAssembly
().
Location
);
var
testsJsonFile
=
Path
.
Combine
(
assemblyDir
,
".."
,
".."
,
".."
,
"tests.json"
);
var
testsJsonFile
=
Path
.
Combine
(
assemblyDir
,
".."
,
".."
,
".."
,
"tests.json"
);
return
File
.
ReadAllText
(
testsJsonFile
);
return
File
.
ReadAllText
(
testsJsonFile
);
}
}
...
...
This diff is collapsed.
Click to expand it.
src/csharp/tests.json
+
11
−
11
View file @
9c3f15c4
{
{
"assemblies"
:
[
"Grpc.Core.Tests"
:
[
"Grpc.Core.Tests"
,
"Grpc.Examples.Tests"
,
"Grpc.HealthCheck.Tests"
,
"Grpc.IntegrationTesting"
],
"tests"
:
[
"Grpc.Core.Internal.Tests.AsyncCallTest"
,
"Grpc.Core.Internal.Tests.AsyncCallTest"
,
"Grpc.Core.Internal.Tests.ChannelArgsSafeHandleTest"
,
"Grpc.Core.Internal.Tests.ChannelArgsSafeHandleTest"
,
"Grpc.Core.Internal.Tests.CompletionQueueEventTest"
,
"Grpc.Core.Internal.Tests.CompletionQueueEventTest"
,
...
@@ -32,13 +26,19 @@
...
@@ -32,13 +26,19 @@
"Grpc.Core.Tests.ServerTest"
,
"Grpc.Core.Tests.ServerTest"
,
"Grpc.Core.Tests.ShutdownTest"
,
"Grpc.Core.Tests.ShutdownTest"
,
"Grpc.Core.Tests.TimeoutsTest"
,
"Grpc.Core.Tests.TimeoutsTest"
,
"Grpc.Core.Tests.UserAgentStringTest"
,
"Grpc.Core.Tests.UserAgentStringTest"
"Math.Tests.MathClientServerTest"
,
],
"Grpc.Examples.Tests"
:
[
"Math.Tests.MathClientServerTest"
],
"Grpc.HealthCheck.Tests"
:
[
"Grpc.HealthCheck.Tests.HealthClientServerTest"
,
"Grpc.HealthCheck.Tests.HealthClientServerTest"
,
"Grpc.HealthCheck.Tests.HealthServiceImplTest"
,
"Grpc.HealthCheck.Tests.HealthServiceImplTest"
"Grpc.IntegrationTesting.HistogramTest"
,
],
"Grpc.IntegrationTesting"
:
[
"Grpc.IntegrationTesting.GeneratedClientTest"
,
"Grpc.IntegrationTesting.GeneratedClientTest"
,
"Grpc.IntegrationTesting.GeneratedServiceBaseTest"
,
"Grpc.IntegrationTesting.GeneratedServiceBaseTest"
,
"Grpc.IntegrationTesting.HistogramTest"
,
"Grpc.IntegrationTesting.InteropClientServerTest"
,
"Grpc.IntegrationTesting.InteropClientServerTest"
,
"Grpc.IntegrationTesting.MetadataCredentialsTest"
,
"Grpc.IntegrationTesting.MetadataCredentialsTest"
,
"Grpc.IntegrationTesting.RunnerClientServerTest"
,
"Grpc.IntegrationTesting.RunnerClientServerTest"
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment