-
Notifications
You must be signed in to change notification settings - Fork 331
Expand file tree
/
Copy pathModuleInitializer.cs
More file actions
149 lines (146 loc) · 11.9 KB
/
ModuleInitializer.cs
File metadata and controls
149 lines (146 loc) · 11.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using System.Runtime.CompilerServices;
namespace Cli.Tests;
/// <summary>
/// Setup global settings for the test project.
/// </summary>
static class ModuleInitializer
{
/// <summary>
/// Initialize the Verifier settings we used for the project, such as what fields to ignore
/// when comparing objects and how we will name the snapshot files.
/// </summary>
[ModuleInitializer]
public static void Init()
{
// Ignore the connection string from the output to avoid committing it.
VerifierSettings.IgnoreMember<DataSource>(dataSource => dataSource.ConnectionString);
// Ignore the IsDatasourceHealthEnabled from the output to avoid committing it.
VerifierSettings.IgnoreMember<DataSource>(dataSource => dataSource.IsDatasourceHealthEnabled);
// Ignore the DatasourceThresholdMs from the output to avoid committing it.
VerifierSettings.IgnoreMember<DataSource>(dataSource => dataSource.DatasourceThresholdMs);
// Ignore the IsUserDelegatedAuthEnabled from the output as it's a computed property.
VerifierSettings.IgnoreMember<DataSource>(dataSource => dataSource.IsUserDelegatedAuthEnabled);
// Ignore the datasource files as that's unimportant from a test standpoint.
VerifierSettings.IgnoreMember<RuntimeConfig>(config => config.DataSourceFiles);
// Ignore the CosmosDataSourceUsed as that's unimportant from a test standpoint.
VerifierSettings.IgnoreMember<RuntimeConfig>(config => config.CosmosDataSourceUsed);
// Ignore the SqlDataSourceUsed as that's unimportant from a test standpoint.
VerifierSettings.IgnoreMember<RuntimeConfig>(config => config.SqlDataSourceUsed);
// Ignore the global IsCachingEnabled as that's unimportant from a test standpoint.
VerifierSettings.IgnoreMember<RuntimeConfig>(config => config.IsCachingEnabled);
// Ignore the global RuntimeOptions.IsCachingEnabled as that's unimportant from a test standpoint.
VerifierSettings.IgnoreMember<RuntimeOptions>(options => options.IsCachingEnabled);
// Ignore the entity IsCachingEnabled as that's unimportant from a test standpoint.
VerifierSettings.IgnoreMember<Entity>(entity => entity.IsCachingEnabled);
// Ignore the global IsRestEnabled as that's unimportant from a test standpoint.
VerifierSettings.IgnoreMember<RuntimeConfig>(config => config.IsRestEnabled);
// Ignore the global RuntimeOptions.IsRestEnabled as that's unimportant from a test standpoint.
VerifierSettings.IgnoreMember<RuntimeOptions>(options => options.IsRestEnabled);
// Ignore the entity IsRestEnabled as that's unimportant from a test standpoint.
VerifierSettings.IgnoreMember<Entity>(entity => entity.IsRestEnabled);
// Ignore the global IsGraphQLEnabled as that's unimportant from a test standpoint.
VerifierSettings.IgnoreMember<RuntimeConfig>(config => config.IsGraphQLEnabled);
// Ignore the global RuntimeOptions.IsGraphQLEnabled as that's unimportant from a test standpoint.
VerifierSettings.IgnoreMember<RuntimeOptions>(options => options.IsGraphQLEnabled);
// Ignore the entity IsGraphQLEnabled as that's unimportant from a test standpoint.
VerifierSettings.IgnoreMember<Entity>(entity => entity.IsGraphQLEnabled);
// Ignore the global IsMcpEnabled as that's unimportant from a test standpoint.
VerifierSettings.IgnoreMember<RuntimeConfig>(config => config.IsMcpEnabled);
// Ignore the global RuntimeOptions.IsMcpEnabled as that's unimportant from a test standpoint.
VerifierSettings.IgnoreMember<RuntimeOptions>(options => options.IsMcpEnabled);
// Ignore the global IsHealthEnabled as that's unimportant from a test standpoint.
VerifierSettings.IgnoreMember<RuntimeConfig>(config => config.IsHealthEnabled);
// Ignore the global RuntimeOptions.IsHealthCheckEnabled as that's unimportant from a test standpoint.
VerifierSettings.IgnoreMember<RuntimeOptions>(options => options.IsHealthCheckEnabled);
// Ignore the entity IsEntityHealthEnabled as that's unimportant from a test standpoint.
VerifierSettings.IgnoreMember<Entity>(entity => entity.IsEntityHealthEnabled);
// Ignore the entity EntityThresholdMs as that's unimportant from a test standpoint.
VerifierSettings.IgnoreMember<Entity>(entity => entity.EntityThresholdMs);
// Ignore the entity EntityFirst as that's unimportant from a test standpoint.
VerifierSettings.IgnoreMember<Entity>(entity => entity.EntityFirst);
// Ignore the entity IsLinkingEntity as that's unimportant from a test standpoint.
VerifierSettings.IgnoreMember<Entity>(entity => entity.IsLinkingEntity);
// Ignore the entity IsAutoentity as that's unimportant from a test standpoint.
VerifierSettings.IgnoreMember<Entity>(entity => entity.IsAutoentity);
// Ignore the UserProvidedTtlOptions. They aren't serialized to our config file, enforced by EntityCacheOptionsConverter.
VerifierSettings.IgnoreMember<EntityCacheOptions>(cacheOptions => cacheOptions.UserProvidedTtlOptions);
// Ignore the UserProvidedEnabledOptions. They aren't serialized to our config file, enforced by EntityCacheOptionsConverter.
VerifierSettings.IgnoreMember<EntityCacheOptions>(cacheOptions => cacheOptions.UserProvidedEnabledOptions);
// Ignore the UserProvidedCustomToolEnabled. They aren't serialized to our config file, enforced by EntityMcpOptionsConverterFactory.
VerifierSettings.IgnoreMember<EntityMcpOptions>(mcpOptions => mcpOptions.UserProvidedCustomToolEnabled);
// Ignore the UserProvidedDmlToolsEnabled. They aren't serialized to our config file, enforced by EntityMcpOptionsConverterFactory.
VerifierSettings.IgnoreMember<EntityMcpOptions>(mcpOptions => mcpOptions.UserProvidedDmlToolsEnabled);
// Ignore the IsRequestBodyStrict as that's unimportant from a test standpoint.
VerifierSettings.IgnoreMember<RuntimeConfig>(config => config.IsRequestBodyStrict);
// Ignore the IsGraphQLEnabled as that's unimportant from a test standpoint.
VerifierSettings.IgnoreMember<RuntimeConfig>(config => config.IsGraphQLEnabled);
// Ignore the IsRestEnabled as that's unimportant from a test standpoint.
VerifierSettings.IgnoreMember<RuntimeConfig>(config => config.IsRestEnabled);
// Ignore the IsMcpEnabled as that's unimportant from a test standpoint.
VerifierSettings.IgnoreMember<RuntimeConfig>(config => config.IsMcpEnabled);
// Ignore the McpDmlTools as that's unimportant from a test standpoint.
VerifierSettings.IgnoreMember<RuntimeConfig>(config => config.McpDmlTools);
// Ignore the IsStaticWebAppsIdentityProvider as that's unimportant from a test standpoint.
VerifierSettings.IgnoreMember<RuntimeConfig>(config => config.IsStaticWebAppsIdentityProvider);
// Ignore the IsAppServiceIdentityProvider as that's unimportant from a test standpoint.
VerifierSettings.IgnoreMember<RuntimeConfig>(config => config.IsAppServiceIdentityProvider);
// Ignore the IsUnauthenticatedIdentityProvider as that's unimportant from a test standpoint.
VerifierSettings.IgnoreMember<RuntimeConfig>(config => config.IsUnauthenticatedIdentityProvider);
// Ignore the RestPath as that's unimportant from a test standpoint.
VerifierSettings.IgnoreMember<RuntimeConfig>(config => config.RestPath);
// Ignore the GraphQLPath as that's unimportant from a test standpoint.
VerifierSettings.IgnoreMember<RuntimeConfig>(config => config.GraphQLPath);
// Ignore the McpPath as that's unimportant from a test standpoint.
VerifierSettings.IgnoreMember<RuntimeConfig>(config => config.McpPath);
// Ignore the AllowIntrospection as that's unimportant from a test standpoint.
VerifierSettings.IgnoreMember<RuntimeConfig>(config => config.AllowIntrospection);
// Ignore the EnableAggregation as that's unimportant from a test standpoint.
VerifierSettings.IgnoreMember<RuntimeConfig>(options => options.EnableAggregation);
// Ignore the AllowedRolesForHealth as that's unimportant from a test standpoint.
VerifierSettings.IgnoreMember<RuntimeConfig>(config => config.AllowedRolesForHealth);
// Ignore the CacheTtlSeconds as that's unimportant from a test standpoint.
VerifierSettings.IgnoreMember<RuntimeConfig>(config => config.CacheTtlSecondsForHealthReport);
// Ignore the EnableAggregation as that's unimportant from a test standpoint.
VerifierSettings.IgnoreMember<GraphQLRuntimeOptions>(options => options.EnableAggregation);
// Ignore the EnableDwNto1JoinOpt as that's unimportant from a test standpoint.
VerifierSettings.IgnoreMember<RuntimeConfig>(options => options.EnableDwNto1JoinOpt);
// Ignore the FeatureFlags as that's unimportant from a test standpoint.
VerifierSettings.IgnoreMember<GraphQLRuntimeOptions>(options => options.FeatureFlags);
// Ignore the JSON schema path as that's unimportant from a test standpoint.
VerifierSettings.IgnoreMember<RuntimeConfig>(config => config.Schema);
// Ignore the JSON schema path as that's unimportant from a test standpoint.
VerifierSettings.IgnoreMember<RuntimeConfig>(config => config.Autoentities);
// Ignore the message as that's not serialized in our config file anyway.
VerifierSettings.IgnoreMember<DataSource>(dataSource => dataSource.DatabaseTypeNotSupportedMessage);
// Ignore DefaultDataSourceName as that's not serialized in our config file.
VerifierSettings.IgnoreMember<RuntimeConfig>(config => config.DefaultDataSourceName);
// Ignore IsRootConfig as that's a computed property for validation, not serialized.
VerifierSettings.IgnoreMember<RuntimeConfig>(config => config.IsRootConfig);
// Ignore IsChildConfig as that's a runtime flag for validation, not serialized.
VerifierSettings.IgnoreMember<RuntimeConfig>(config => config.IsChildConfig);
// Ignore AutoentityResolutionCounts as that's populated at runtime during metadata initialization.
VerifierSettings.IgnoreMember<RuntimeConfig>(config => config.AutoentityResolutionCounts);
// Ignore ChildConfigs as that's populated at runtime during child config loading.
VerifierSettings.IgnoreMember<RuntimeConfig>(config => config.ChildConfigs);
// Ignore MaxResponseSizeMB as as that's unimportant from a test standpoint.
VerifierSettings.IgnoreMember<HostOptions>(options => options.MaxResponseSizeMB);
// Ignore UserProvidedMaxResponseSizeMB as that's not serialized in our config file.
VerifierSettings.IgnoreMember<HostOptions>(options => options.UserProvidedMaxResponseSizeMB);
// Ignore UserProvidedDepthLimit as that's not serialized in our config file.
VerifierSettings.IgnoreMember<GraphQLRuntimeOptions>(options => options.UserProvidedDepthLimit);
// Ignore EnableLegacyDateTimeScalar as that's not serialized in our config file.
VerifierSettings.IgnoreMember<GraphQLRuntimeOptions>(options => options.EnableLegacyDateTimeScalar);
// Ignore UserProvidedPath as that's not serialized in our config file.
VerifierSettings.IgnoreMember<McpRuntimeOptions>(options => options.UserProvidedPath);
// Customise the path where we store snapshots, so they are easier to locate in a PR review.
VerifyBase.DerivePathInfo(
(sourceFile, projectDirectory, type, method) => new(
directory: Path.Combine(projectDirectory, "Snapshots"),
typeName: type.Name,
methodName: method.Name));
// Enable DiffPlex output to better identify in the test output where the failure is with a rich diff.
VerifyDiffPlex.Initialize();
}
}