Skip to content

Commit d04dc07

Browse files
Add unit test.
1 parent 1bfbec5 commit d04dc07

2 files changed

Lines changed: 45 additions & 14 deletions

File tree

.editorconfig

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ root = true
33
[*]
44
charset = utf-8
55
end_of_line = lf
6-
indent_size = 2
6+
indent_size = 4
77
indent_style = space
88
insert_final_newline = true
99
trim_trailing_whitespace = true
10+
dotnet_style_operator_placement_when_wrapping = beginning_of_line
11+
tab_width = 4
1012

1113
[*.fsd]
1214
indent_size = 4
@@ -44,9 +46,9 @@ csharp_new_line_before_members_in_anonymous_types = true
4446
csharp_new_line_before_members_in_object_initializers = true
4547
csharp_new_line_before_open_brace = all
4648
csharp_new_line_between_query_expression_clauses = true
47-
csharp_prefer_braces = when_multiline : suggestion
49+
csharp_prefer_braces = when_multiline:suggestion
4850
csharp_prefer_simple_default_expression = true : suggestion
49-
csharp_prefer_simple_using_statement = true : suggestion
51+
csharp_prefer_simple_using_statement = true:suggestion
5052
csharp_prefer_static_local_function = true : suggestion
5153
csharp_preferred_modifier_order = public, private, protected, internal, new, abstract, virtual, sealed, override, static, readonly, extern, unsafe, volatile, async : warning
5254
csharp_preserve_single_line_blocks = true
@@ -75,17 +77,17 @@ csharp_space_between_parentheses = false
7577
csharp_space_between_square_brackets = false
7678
csharp_style_conditional_delegate_call = true : suggestion
7779
csharp_style_deconstructed_variable_declaration = true : suggestion
78-
csharp_style_expression_bodied_accessors = true : suggestion
79-
csharp_style_expression_bodied_constructors = false : suggestion
80-
csharp_style_expression_bodied_indexers = true : suggestion
81-
csharp_style_expression_bodied_lambdas = true : suggestion
82-
csharp_style_expression_bodied_local_functions = true : suggestion
83-
csharp_style_expression_bodied_methods = true : suggestion
84-
csharp_style_expression_bodied_operators = true : suggestion
85-
csharp_style_expression_bodied_properties = true : suggestion
80+
csharp_style_expression_bodied_accessors = true:suggestion
81+
csharp_style_expression_bodied_constructors = false:suggestion
82+
csharp_style_expression_bodied_indexers = true:suggestion
83+
csharp_style_expression_bodied_lambdas = true:suggestion
84+
csharp_style_expression_bodied_local_functions = true:suggestion
85+
csharp_style_expression_bodied_methods = true:suggestion
86+
csharp_style_expression_bodied_operators = true:suggestion
87+
csharp_style_expression_bodied_properties = true:suggestion
8688
csharp_style_implicit_object_creation_when_type_is_apparent = true : suggestion
8789
csharp_style_inlined_variable_declaration = true : suggestion
88-
csharp_style_namespace_declarations = file_scoped : suggestion
90+
csharp_style_namespace_declarations = file_scoped:suggestion
8991
csharp_style_pattern_matching_over_as_with_null_check = true : suggestion
9092
csharp_style_pattern_matching_over_is_with_cast_check = true : suggestion
9193
csharp_style_prefer_extended_property_pattern = true : suggestion
@@ -94,7 +96,7 @@ csharp_style_prefer_local_over_anonymous_function = true : suggestion
9496
csharp_style_prefer_not_pattern = true : suggestion
9597
csharp_style_prefer_null_check_over_type_check = true : suggestion
9698
csharp_style_prefer_pattern_matching = true : suggestion
97-
csharp_style_prefer_primary_constructors = true : suggestion
99+
csharp_style_prefer_primary_constructors = true:suggestion
98100
csharp_style_prefer_range_operator = true : suggestion
99101
csharp_style_prefer_switch_expression = true : suggestion
100102
csharp_style_prefer_tuple_swap = true : warning
@@ -104,7 +106,7 @@ csharp_style_unused_value_expression_statement_preference = discard_variable : n
104106
csharp_style_var_elsewhere = true : suggestion
105107
csharp_style_var_for_built_in_types = true : suggestion
106108
csharp_style_var_when_type_is_apparent = true : suggestion
107-
csharp_using_directive_placement = outside_namespace : warning
109+
csharp_using_directive_placement = outside_namespace:warning
108110
dotnet_analyzer_diagnostic.severity = warning
109111
dotnet_code_quality_unused_parameters = all : suggestion
110112
dotnet_diagnostic.CA1014.severity = none
@@ -380,3 +382,6 @@ resharper_unused_auto_property_accessor_global_highlighting = none
380382
resharper_unused_auto_property_accessor_local_highlighting = suggestion
381383
resharper_unused_member_global_highlighting = none
382384
resharper_unused_member_local_highlighting = suggestion
385+
csharp_style_prefer_method_group_conversion = true:silent
386+
csharp_style_prefer_top_level_statements = true:silent
387+
csharp_prefer_system_threading_lock = true:suggestion

tests/Facility.CodeGen.JavaScript.UnitTests/JavaScriptGeneratorTests.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,32 @@ public void GenerateExampleApiTypeScript_ExternDataWithNameAndModuel()
140140
Assert.That(typesFile.Text, Does.Contain("thing?: IThing;"));
141141
}
142142

143+
[Test]
144+
public void GenerateExampleApiTypeScript_OmitHttpClient()
145+
{
146+
ServiceInfo service;
147+
const string fileName = "Facility.CodeGen.JavaScript.UnitTests.ExampleApi.fsd";
148+
var parser = CreateParser();
149+
var stream = GetType().GetTypeInfo().Assembly.GetManifestResourceStream(fileName)!;
150+
Assert.That(stream, Is.Not.Null);
151+
using (var reader = new StreamReader(stream))
152+
service = parser.ParseDefinition(new ServiceDefinitionText(Path.GetFileName(fileName), reader.ReadToEnd()));
153+
154+
var generator = new JavaScriptGenerator
155+
{
156+
GeneratorName = "JavaScriptGeneratorTests",
157+
TypeScript = true,
158+
NoHttp = true,
159+
NewLine = "\n",
160+
};
161+
var result = generator.GenerateOutput(service);
162+
Assert.That(result, Is.Not.Null);
163+
164+
var files = result.Files.Select(x => x.Name).ToList();
165+
Assert.That(files, Does.Not.Contain("testApi.ts"));
166+
Assert.That(files, Does.Contain("testApiTypes.ts"));
167+
}
168+
143169
[Test]
144170
public void GenerateExampleApiTypeScript_ExternDataWithoutJsAttribute()
145171
{

0 commit comments

Comments
 (0)