Compare commits
	
		
			24 Commits
		
	
	
		
			main
			...
			features/d
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					607f7b6fc3 | ||
| 
						 | 
					7425940514 | ||
| 
						 | 
					6725edb1ae | ||
| 
						 | 
					7d4b94bc9b | ||
| 
						 | 
					b097dd54e6 | ||
| 
						 | 
					ae0dcb3bf1 | ||
| 
						 | 
					a7092ec705 | ||
| 
						 | 
					820a698a9f | ||
| 
						 | 
					9e02293e0b | ||
| 
						 | 
					82e13472c1 | ||
| 
						 | 
					15c3cb55b9 | ||
| 
						 | 
					ee14cb99a0 | ||
| 
						 | 
					6da5a4abb4 | ||
| 
						 | 
					13070725c1 | ||
| 
						 | 
					29c543475d | ||
| 8aaeeb9d81 | |||
| 
						 | 
					d2199bc2d7 | ||
| f971b8d8a3 | |||
| 76ea9e26a0 | |||
| 
						 | 
					28ea4d4801 | ||
| 4ae34c4756 | |||
| 
						 | 
					756fd94e27 | ||
| 
						 | 
					d658215381 | ||
| 
						 | 
					54502060f6 | 
							
								
								
									
										226
									
								
								.editorconfig
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										226
									
								
								.editorconfig
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,226 @@
 | 
			
		||||
# Remove the line below if you want to inherit .editorconfig settings from higher directories
 | 
			
		||||
root = true
 | 
			
		||||
 | 
			
		||||
# C# files
 | 
			
		||||
[*.cs]
 | 
			
		||||
 | 
			
		||||
#### Core EditorConfig Options ####
 | 
			
		||||
 | 
			
		||||
# Indentation and spacing
 | 
			
		||||
indent_size = 4
 | 
			
		||||
indent_style = tab
 | 
			
		||||
tab_width = 4
 | 
			
		||||
 | 
			
		||||
# New line preferences
 | 
			
		||||
end_of_line = crlf
 | 
			
		||||
insert_final_newline = false
 | 
			
		||||
 | 
			
		||||
#### .NET Coding Conventions ####
 | 
			
		||||
 | 
			
		||||
# Organize usings
 | 
			
		||||
dotnet_separate_import_directive_groups = false
 | 
			
		||||
dotnet_sort_system_directives_first = true
 | 
			
		||||
file_header_template = unset
 | 
			
		||||
 | 
			
		||||
# this. and Me. preferences
 | 
			
		||||
dotnet_style_qualification_for_event = false
 | 
			
		||||
dotnet_style_qualification_for_field = false
 | 
			
		||||
dotnet_style_qualification_for_method = false
 | 
			
		||||
dotnet_style_qualification_for_property = false
 | 
			
		||||
 | 
			
		||||
# Language keywords vs BCL types preferences
 | 
			
		||||
dotnet_style_predefined_type_for_locals_parameters_members = true
 | 
			
		||||
dotnet_style_predefined_type_for_member_access = true
 | 
			
		||||
 | 
			
		||||
# Parentheses preferences
 | 
			
		||||
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity
 | 
			
		||||
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity
 | 
			
		||||
dotnet_style_parentheses_in_other_operators = never_if_unnecessary
 | 
			
		||||
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity
 | 
			
		||||
 | 
			
		||||
# Modifier preferences
 | 
			
		||||
dotnet_style_require_accessibility_modifiers = for_non_interface_members
 | 
			
		||||
 | 
			
		||||
# Expression-level preferences
 | 
			
		||||
dotnet_style_coalesce_expression = true
 | 
			
		||||
dotnet_style_collection_initializer = true
 | 
			
		||||
dotnet_style_explicit_tuple_names = true
 | 
			
		||||
dotnet_style_namespace_match_folder = true
 | 
			
		||||
dotnet_style_null_propagation = true
 | 
			
		||||
dotnet_style_object_initializer = true
 | 
			
		||||
dotnet_style_operator_placement_when_wrapping = beginning_of_line
 | 
			
		||||
dotnet_style_prefer_auto_properties = true
 | 
			
		||||
dotnet_style_prefer_compound_assignment = true
 | 
			
		||||
dotnet_style_prefer_conditional_expression_over_assignment = true
 | 
			
		||||
dotnet_style_prefer_conditional_expression_over_return = true
 | 
			
		||||
dotnet_style_prefer_foreach_explicit_cast_in_source = when_strongly_typed
 | 
			
		||||
dotnet_style_prefer_inferred_anonymous_type_member_names = true
 | 
			
		||||
dotnet_style_prefer_inferred_tuple_names = true
 | 
			
		||||
dotnet_style_prefer_is_null_check_over_reference_equality_method = true
 | 
			
		||||
dotnet_style_prefer_simplified_boolean_expressions = true
 | 
			
		||||
dotnet_style_prefer_simplified_interpolation = true
 | 
			
		||||
 | 
			
		||||
# Field preferences
 | 
			
		||||
dotnet_style_readonly_field = true
 | 
			
		||||
 | 
			
		||||
# Parameter preferences
 | 
			
		||||
dotnet_code_quality_unused_parameters = all
 | 
			
		||||
 | 
			
		||||
# Suppression preferences
 | 
			
		||||
dotnet_remove_unnecessary_suppression_exclusions = none
 | 
			
		||||
 | 
			
		||||
# New line preferences
 | 
			
		||||
dotnet_style_allow_multiple_blank_lines_experimental = false
 | 
			
		||||
dotnet_style_allow_statement_immediately_after_block_experimental = false
 | 
			
		||||
 | 
			
		||||
#### C# Coding Conventions ####
 | 
			
		||||
 | 
			
		||||
# var preferences
 | 
			
		||||
csharp_style_var_elsewhere = true
 | 
			
		||||
csharp_style_var_for_built_in_types = true
 | 
			
		||||
csharp_style_var_when_type_is_apparent = true
 | 
			
		||||
 | 
			
		||||
# Expression-bodied members
 | 
			
		||||
csharp_style_expression_bodied_accessors = true
 | 
			
		||||
csharp_style_expression_bodied_constructors = false
 | 
			
		||||
csharp_style_expression_bodied_indexers = true
 | 
			
		||||
csharp_style_expression_bodied_lambdas = true
 | 
			
		||||
csharp_style_expression_bodied_local_functions = false
 | 
			
		||||
csharp_style_expression_bodied_methods = false
 | 
			
		||||
csharp_style_expression_bodied_operators = false
 | 
			
		||||
csharp_style_expression_bodied_properties = true
 | 
			
		||||
 | 
			
		||||
# Pattern matching preferences
 | 
			
		||||
csharp_style_pattern_matching_over_as_with_null_check = true
 | 
			
		||||
csharp_style_pattern_matching_over_is_with_cast_check = true
 | 
			
		||||
csharp_style_prefer_extended_property_pattern = true
 | 
			
		||||
csharp_style_prefer_not_pattern = true
 | 
			
		||||
csharp_style_prefer_pattern_matching = true
 | 
			
		||||
csharp_style_prefer_switch_expression = true
 | 
			
		||||
 | 
			
		||||
# Null-checking preferences
 | 
			
		||||
csharp_style_conditional_delegate_call = true
 | 
			
		||||
 | 
			
		||||
# Modifier preferences
 | 
			
		||||
csharp_prefer_static_local_function = true
 | 
			
		||||
csharp_preferred_modifier_order = public,private,protected,internal,file,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,required,volatile,async
 | 
			
		||||
csharp_style_prefer_readonly_struct = true
 | 
			
		||||
 | 
			
		||||
# Code-block preferences
 | 
			
		||||
csharp_prefer_braces = when_multiline
 | 
			
		||||
csharp_prefer_simple_using_statement = true
 | 
			
		||||
csharp_style_namespace_declarations = file_scoped
 | 
			
		||||
csharp_style_prefer_method_group_conversion = true
 | 
			
		||||
csharp_style_prefer_top_level_statements = true
 | 
			
		||||
 | 
			
		||||
# Expression-level preferences
 | 
			
		||||
csharp_prefer_simple_default_expression = true
 | 
			
		||||
csharp_style_deconstructed_variable_declaration = true
 | 
			
		||||
csharp_style_implicit_object_creation_when_type_is_apparent = true
 | 
			
		||||
csharp_style_inlined_variable_declaration = true
 | 
			
		||||
csharp_style_prefer_index_operator = true
 | 
			
		||||
csharp_style_prefer_local_over_anonymous_function = true
 | 
			
		||||
csharp_style_prefer_null_check_over_type_check = true
 | 
			
		||||
csharp_style_prefer_range_operator = true
 | 
			
		||||
csharp_style_prefer_tuple_swap = true
 | 
			
		||||
csharp_style_prefer_utf8_string_literals = true
 | 
			
		||||
csharp_style_throw_expression = true
 | 
			
		||||
csharp_style_unused_value_assignment_preference = discard_variable
 | 
			
		||||
csharp_style_unused_value_expression_statement_preference = discard_variable
 | 
			
		||||
 | 
			
		||||
# 'using' directive preferences
 | 
			
		||||
csharp_using_directive_placement = outside_namespace
 | 
			
		||||
 | 
			
		||||
# New line preferences
 | 
			
		||||
csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true
 | 
			
		||||
csharp_style_allow_blank_lines_between_consecutive_braces_experimental = false
 | 
			
		||||
csharp_style_allow_embedded_statements_on_same_line_experimental = false
 | 
			
		||||
 | 
			
		||||
#### C# Formatting Rules ####
 | 
			
		||||
 | 
			
		||||
# New line preferences
 | 
			
		||||
csharp_new_line_before_catch = true
 | 
			
		||||
csharp_new_line_before_else = true
 | 
			
		||||
csharp_new_line_before_finally = true
 | 
			
		||||
csharp_new_line_before_members_in_anonymous_types = true
 | 
			
		||||
csharp_new_line_before_members_in_object_initializers = true
 | 
			
		||||
csharp_new_line_before_open_brace = all
 | 
			
		||||
csharp_new_line_between_query_expression_clauses = true
 | 
			
		||||
 | 
			
		||||
# Indentation preferences
 | 
			
		||||
csharp_indent_block_contents = true
 | 
			
		||||
csharp_indent_braces = false
 | 
			
		||||
csharp_indent_case_contents = true
 | 
			
		||||
csharp_indent_case_contents_when_block = true
 | 
			
		||||
csharp_indent_labels = one_less_than_current
 | 
			
		||||
csharp_indent_switch_labels = true
 | 
			
		||||
 | 
			
		||||
# Space preferences
 | 
			
		||||
csharp_space_after_cast = false
 | 
			
		||||
csharp_space_after_colon_in_inheritance_clause = true
 | 
			
		||||
csharp_space_after_comma = true
 | 
			
		||||
csharp_space_after_dot = false
 | 
			
		||||
csharp_space_after_keywords_in_control_flow_statements = true
 | 
			
		||||
csharp_space_after_semicolon_in_for_statement = true
 | 
			
		||||
csharp_space_around_binary_operators = before_and_after
 | 
			
		||||
csharp_space_around_declaration_statements = false
 | 
			
		||||
csharp_space_before_colon_in_inheritance_clause = true
 | 
			
		||||
csharp_space_before_comma = false
 | 
			
		||||
csharp_space_before_dot = false
 | 
			
		||||
csharp_space_before_open_square_brackets = false
 | 
			
		||||
csharp_space_before_semicolon_in_for_statement = false
 | 
			
		||||
csharp_space_between_empty_square_brackets = false
 | 
			
		||||
csharp_space_between_method_call_empty_parameter_list_parentheses = false
 | 
			
		||||
csharp_space_between_method_call_name_and_opening_parenthesis = false
 | 
			
		||||
csharp_space_between_method_call_parameter_list_parentheses = false
 | 
			
		||||
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
 | 
			
		||||
csharp_space_between_method_declaration_name_and_open_parenthesis = false
 | 
			
		||||
csharp_space_between_method_declaration_parameter_list_parentheses = false
 | 
			
		||||
csharp_space_between_parentheses = false
 | 
			
		||||
csharp_space_between_square_brackets = false
 | 
			
		||||
 | 
			
		||||
# Wrapping preferences
 | 
			
		||||
csharp_preserve_single_line_blocks = true
 | 
			
		||||
csharp_preserve_single_line_statements = false
 | 
			
		||||
 | 
			
		||||
#### Naming styles ####
 | 
			
		||||
 | 
			
		||||
# Naming rules
 | 
			
		||||
 | 
			
		||||
dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion
 | 
			
		||||
dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
 | 
			
		||||
dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i
 | 
			
		||||
 | 
			
		||||
dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion
 | 
			
		||||
dotnet_naming_rule.types_should_be_pascal_case.symbols = types
 | 
			
		||||
dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case
 | 
			
		||||
 | 
			
		||||
dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion
 | 
			
		||||
dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
 | 
			
		||||
dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case
 | 
			
		||||
 | 
			
		||||
# Symbol specifications
 | 
			
		||||
 | 
			
		||||
dotnet_naming_symbols.interface.applicable_kinds = interface
 | 
			
		||||
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
 | 
			
		||||
dotnet_naming_symbols.interface.required_modifiers = 
 | 
			
		||||
 | 
			
		||||
dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
 | 
			
		||||
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
 | 
			
		||||
dotnet_naming_symbols.types.required_modifiers = 
 | 
			
		||||
 | 
			
		||||
dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
 | 
			
		||||
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
 | 
			
		||||
dotnet_naming_symbols.non_field_members.required_modifiers = 
 | 
			
		||||
 | 
			
		||||
# Naming styles
 | 
			
		||||
 | 
			
		||||
dotnet_naming_style.pascal_case.required_prefix = 
 | 
			
		||||
dotnet_naming_style.pascal_case.required_suffix = 
 | 
			
		||||
dotnet_naming_style.pascal_case.word_separator = 
 | 
			
		||||
dotnet_naming_style.pascal_case.capitalization = pascal_case
 | 
			
		||||
 | 
			
		||||
dotnet_naming_style.begins_with_i.required_prefix = I
 | 
			
		||||
dotnet_naming_style.begins_with_i.required_suffix = 
 | 
			
		||||
dotnet_naming_style.begins_with_i.word_separator = 
 | 
			
		||||
dotnet_naming_style.begins_with_i.capitalization = pascal_case
 | 
			
		||||
							
								
								
									
										3
									
								
								.gitmodules
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								.gitmodules
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,3 @@
 | 
			
		||||
[submodule "dependencies/Connected.Components"]
 | 
			
		||||
	path = dependencies/Connected.Components
 | 
			
		||||
	url = https://git.tompit.com/Connected/Connected.Components.git
 | 
			
		||||
							
								
								
									
										69
									
								
								Connected.Common.Types.sln
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										69
									
								
								Connected.Common.Types.sln
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,69 @@
 | 
			
		||||
 | 
			
		||||
Microsoft Visual Studio Solution File, Format Version 12.00
 | 
			
		||||
# Visual Studio Version 17
 | 
			
		||||
VisualStudioVersion = 17.4.32916.344
 | 
			
		||||
MinimumVisualStudioVersion = 10.0.40219.1
 | 
			
		||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Connected.Common.Types.Client", "src\Connected.Common.Types.Client\Connected.Common.Types.Client.csproj", "{B94A8E27-3682-4321-9BF7-F0A2D775E905}"
 | 
			
		||||
EndProject
 | 
			
		||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Connected.Common.Types.Middleware", "src\Connected.Common.Types.Middleware\Connected.Common.Types.Middleware.csproj", "{72B591CC-DAC3-4F9A-A95C-67C265FB4E93}"
 | 
			
		||||
EndProject
 | 
			
		||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Connected.Common.Types", "src\Connected.Common.Types\Connected.Common.Types.csproj", "{EDDF95B7-236C-4F87-A9F0-1BC5A7FA9980}"
 | 
			
		||||
EndProject
 | 
			
		||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Connected.Common.Types.UI", "src\Connected.Common.Types.UI\Connected.Common.Types.UI.csproj", "{62A9D5D4-942B-40DA-AA9C-CF3D48339B60}"
 | 
			
		||||
EndProject
 | 
			
		||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Connected.Common.Types.Model", "src\Connected.Common.Types.Model\Connected.Common.Types.Model.csproj", "{DB82BD88-23C1-4E8A-9E48-92848E1942C0}"
 | 
			
		||||
EndProject
 | 
			
		||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{D1988217-0AF1-4A13-94AA-FF55337383D0}"
 | 
			
		||||
EndProject
 | 
			
		||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Connected.Common.Types.Tests", "tests\Connected.Common.Types.Tests\Connected.Common.Types.Tests.csproj", "{B1C41076-5120-47DA-AEE7-D90E0EB7C038}"
 | 
			
		||||
EndProject
 | 
			
		||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Dependencies", "Dependencies", "{D27CBC04-496C-4112-A2AF-786715AFEDE5}"
 | 
			
		||||
EndProject
 | 
			
		||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Connected.Components", "dependencies\Connected.Components\src\Connected.Components\Connected.Components.csproj", "{17EBBBC2-B4AF-4CE4-8F76-73C6E088B3E1}"
 | 
			
		||||
EndProject
 | 
			
		||||
Global
 | 
			
		||||
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 | 
			
		||||
		Debug|Any CPU = Debug|Any CPU
 | 
			
		||||
		Release|Any CPU = Release|Any CPU
 | 
			
		||||
	EndGlobalSection
 | 
			
		||||
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
 | 
			
		||||
		{B94A8E27-3682-4321-9BF7-F0A2D775E905}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 | 
			
		||||
		{B94A8E27-3682-4321-9BF7-F0A2D775E905}.Debug|Any CPU.Build.0 = Debug|Any CPU
 | 
			
		||||
		{B94A8E27-3682-4321-9BF7-F0A2D775E905}.Release|Any CPU.ActiveCfg = Release|Any CPU
 | 
			
		||||
		{B94A8E27-3682-4321-9BF7-F0A2D775E905}.Release|Any CPU.Build.0 = Release|Any CPU
 | 
			
		||||
		{72B591CC-DAC3-4F9A-A95C-67C265FB4E93}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 | 
			
		||||
		{72B591CC-DAC3-4F9A-A95C-67C265FB4E93}.Debug|Any CPU.Build.0 = Debug|Any CPU
 | 
			
		||||
		{72B591CC-DAC3-4F9A-A95C-67C265FB4E93}.Release|Any CPU.ActiveCfg = Release|Any CPU
 | 
			
		||||
		{72B591CC-DAC3-4F9A-A95C-67C265FB4E93}.Release|Any CPU.Build.0 = Release|Any CPU
 | 
			
		||||
		{EDDF95B7-236C-4F87-A9F0-1BC5A7FA9980}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 | 
			
		||||
		{EDDF95B7-236C-4F87-A9F0-1BC5A7FA9980}.Debug|Any CPU.Build.0 = Debug|Any CPU
 | 
			
		||||
		{EDDF95B7-236C-4F87-A9F0-1BC5A7FA9980}.Release|Any CPU.ActiveCfg = Release|Any CPU
 | 
			
		||||
		{EDDF95B7-236C-4F87-A9F0-1BC5A7FA9980}.Release|Any CPU.Build.0 = Release|Any CPU
 | 
			
		||||
		{62A9D5D4-942B-40DA-AA9C-CF3D48339B60}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 | 
			
		||||
		{62A9D5D4-942B-40DA-AA9C-CF3D48339B60}.Debug|Any CPU.Build.0 = Debug|Any CPU
 | 
			
		||||
		{62A9D5D4-942B-40DA-AA9C-CF3D48339B60}.Release|Any CPU.ActiveCfg = Release|Any CPU
 | 
			
		||||
		{62A9D5D4-942B-40DA-AA9C-CF3D48339B60}.Release|Any CPU.Build.0 = Release|Any CPU
 | 
			
		||||
		{DB82BD88-23C1-4E8A-9E48-92848E1942C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 | 
			
		||||
		{DB82BD88-23C1-4E8A-9E48-92848E1942C0}.Debug|Any CPU.Build.0 = Debug|Any CPU
 | 
			
		||||
		{DB82BD88-23C1-4E8A-9E48-92848E1942C0}.Release|Any CPU.ActiveCfg = Release|Any CPU
 | 
			
		||||
		{DB82BD88-23C1-4E8A-9E48-92848E1942C0}.Release|Any CPU.Build.0 = Release|Any CPU
 | 
			
		||||
		{B1C41076-5120-47DA-AEE7-D90E0EB7C038}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 | 
			
		||||
		{B1C41076-5120-47DA-AEE7-D90E0EB7C038}.Debug|Any CPU.Build.0 = Debug|Any CPU
 | 
			
		||||
		{B1C41076-5120-47DA-AEE7-D90E0EB7C038}.Release|Any CPU.ActiveCfg = Release|Any CPU
 | 
			
		||||
		{B1C41076-5120-47DA-AEE7-D90E0EB7C038}.Release|Any CPU.Build.0 = Release|Any CPU
 | 
			
		||||
		{17EBBBC2-B4AF-4CE4-8F76-73C6E088B3E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 | 
			
		||||
		{17EBBBC2-B4AF-4CE4-8F76-73C6E088B3E1}.Debug|Any CPU.Build.0 = Debug|Any CPU
 | 
			
		||||
		{17EBBBC2-B4AF-4CE4-8F76-73C6E088B3E1}.Release|Any CPU.ActiveCfg = Release|Any CPU
 | 
			
		||||
		{17EBBBC2-B4AF-4CE4-8F76-73C6E088B3E1}.Release|Any CPU.Build.0 = Release|Any CPU
 | 
			
		||||
	EndGlobalSection
 | 
			
		||||
	GlobalSection(SolutionProperties) = preSolution
 | 
			
		||||
		HideSolutionNode = FALSE
 | 
			
		||||
	EndGlobalSection
 | 
			
		||||
	GlobalSection(NestedProjects) = preSolution
 | 
			
		||||
		{B1C41076-5120-47DA-AEE7-D90E0EB7C038} = {D1988217-0AF1-4A13-94AA-FF55337383D0}
 | 
			
		||||
		{17EBBBC2-B4AF-4CE4-8F76-73C6E088B3E1} = {D27CBC04-496C-4112-A2AF-786715AFEDE5}
 | 
			
		||||
	EndGlobalSection
 | 
			
		||||
	GlobalSection(ExtensibilityGlobals) = postSolution
 | 
			
		||||
		SolutionGuid = {4C661325-1729-4560-89F9-E2B51B111B72}
 | 
			
		||||
	EndGlobalSection
 | 
			
		||||
EndGlobal
 | 
			
		||||
							
								
								
									
										661
									
								
								LICENSE
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										661
									
								
								LICENSE
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,661 @@
 | 
			
		||||
                    GNU AFFERO GENERAL PUBLIC LICENSE
 | 
			
		||||
                       Version 3, 19 November 2007
 | 
			
		||||
 | 
			
		||||
 Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
 | 
			
		||||
 Everyone is permitted to copy and distribute verbatim copies
 | 
			
		||||
 of this license document, but changing it is not allowed.
 | 
			
		||||
 | 
			
		||||
                            Preamble
 | 
			
		||||
 | 
			
		||||
  The GNU Affero General Public License is a free, copyleft license for
 | 
			
		||||
software and other kinds of works, specifically designed to ensure
 | 
			
		||||
cooperation with the community in the case of network server software.
 | 
			
		||||
 | 
			
		||||
  The licenses for most software and other practical works are designed
 | 
			
		||||
to take away your freedom to share and change the works.  By contrast,
 | 
			
		||||
our General Public Licenses are intended to guarantee your freedom to
 | 
			
		||||
share and change all versions of a program--to make sure it remains free
 | 
			
		||||
software for all its users.
 | 
			
		||||
 | 
			
		||||
  When we speak of free software, we are referring to freedom, not
 | 
			
		||||
price.  Our General Public Licenses are designed to make sure that you
 | 
			
		||||
have the freedom to distribute copies of free software (and charge for
 | 
			
		||||
them if you wish), that you receive source code or can get it if you
 | 
			
		||||
want it, that you can change the software or use pieces of it in new
 | 
			
		||||
free programs, and that you know you can do these things.
 | 
			
		||||
 | 
			
		||||
  Developers that use our General Public Licenses protect your rights
 | 
			
		||||
with two steps: (1) assert copyright on the software, and (2) offer
 | 
			
		||||
you this License which gives you legal permission to copy, distribute
 | 
			
		||||
and/or modify the software.
 | 
			
		||||
 | 
			
		||||
  A secondary benefit of defending all users' freedom is that
 | 
			
		||||
improvements made in alternate versions of the program, if they
 | 
			
		||||
receive widespread use, become available for other developers to
 | 
			
		||||
incorporate.  Many developers of free software are heartened and
 | 
			
		||||
encouraged by the resulting cooperation.  However, in the case of
 | 
			
		||||
software used on network servers, this result may fail to come about.
 | 
			
		||||
The GNU General Public License permits making a modified version and
 | 
			
		||||
letting the public access it on a server without ever releasing its
 | 
			
		||||
source code to the public.
 | 
			
		||||
 | 
			
		||||
  The GNU Affero General Public License is designed specifically to
 | 
			
		||||
ensure that, in such cases, the modified source code becomes available
 | 
			
		||||
to the community.  It requires the operator of a network server to
 | 
			
		||||
provide the source code of the modified version running there to the
 | 
			
		||||
users of that server.  Therefore, public use of a modified version, on
 | 
			
		||||
a publicly accessible server, gives the public access to the source
 | 
			
		||||
code of the modified version.
 | 
			
		||||
 | 
			
		||||
  An older license, called the Affero General Public License and
 | 
			
		||||
published by Affero, was designed to accomplish similar goals.  This is
 | 
			
		||||
a different license, not a version of the Affero GPL, but Affero has
 | 
			
		||||
released a new version of the Affero GPL which permits relicensing under
 | 
			
		||||
this license.
 | 
			
		||||
 | 
			
		||||
  The precise terms and conditions for copying, distribution and
 | 
			
		||||
modification follow.
 | 
			
		||||
 | 
			
		||||
                       TERMS AND CONDITIONS
 | 
			
		||||
 | 
			
		||||
  0. Definitions.
 | 
			
		||||
 | 
			
		||||
  "This License" refers to version 3 of the GNU Affero General Public License.
 | 
			
		||||
 | 
			
		||||
  "Copyright" also means copyright-like laws that apply to other kinds of
 | 
			
		||||
works, such as semiconductor masks.
 | 
			
		||||
 | 
			
		||||
  "The Program" refers to any copyrightable work licensed under this
 | 
			
		||||
License.  Each licensee is addressed as "you".  "Licensees" and
 | 
			
		||||
"recipients" may be individuals or organizations.
 | 
			
		||||
 | 
			
		||||
  To "modify" a work means to copy from or adapt all or part of the work
 | 
			
		||||
in a fashion requiring copyright permission, other than the making of an
 | 
			
		||||
exact copy.  The resulting work is called a "modified version" of the
 | 
			
		||||
earlier work or a work "based on" the earlier work.
 | 
			
		||||
 | 
			
		||||
  A "covered work" means either the unmodified Program or a work based
 | 
			
		||||
on the Program.
 | 
			
		||||
 | 
			
		||||
  To "propagate" a work means to do anything with it that, without
 | 
			
		||||
permission, would make you directly or secondarily liable for
 | 
			
		||||
infringement under applicable copyright law, except executing it on a
 | 
			
		||||
computer or modifying a private copy.  Propagation includes copying,
 | 
			
		||||
distribution (with or without modification), making available to the
 | 
			
		||||
public, and in some countries other activities as well.
 | 
			
		||||
 | 
			
		||||
  To "convey" a work means any kind of propagation that enables other
 | 
			
		||||
parties to make or receive copies.  Mere interaction with a user through
 | 
			
		||||
a computer network, with no transfer of a copy, is not conveying.
 | 
			
		||||
 | 
			
		||||
  An interactive user interface displays "Appropriate Legal Notices"
 | 
			
		||||
to the extent that it includes a convenient and prominently visible
 | 
			
		||||
feature that (1) displays an appropriate copyright notice, and (2)
 | 
			
		||||
tells the user that there is no warranty for the work (except to the
 | 
			
		||||
extent that warranties are provided), that licensees may convey the
 | 
			
		||||
work under this License, and how to view a copy of this License.  If
 | 
			
		||||
the interface presents a list of user commands or options, such as a
 | 
			
		||||
menu, a prominent item in the list meets this criterion.
 | 
			
		||||
 | 
			
		||||
  1. Source Code.
 | 
			
		||||
 | 
			
		||||
  The "source code" for a work means the preferred form of the work
 | 
			
		||||
for making modifications to it.  "Object code" means any non-source
 | 
			
		||||
form of a work.
 | 
			
		||||
 | 
			
		||||
  A "Standard Interface" means an interface that either is an official
 | 
			
		||||
standard defined by a recognized standards body, or, in the case of
 | 
			
		||||
interfaces specified for a particular programming language, one that
 | 
			
		||||
is widely used among developers working in that language.
 | 
			
		||||
 | 
			
		||||
  The "System Libraries" of an executable work include anything, other
 | 
			
		||||
than the work as a whole, that (a) is included in the normal form of
 | 
			
		||||
packaging a Major Component, but which is not part of that Major
 | 
			
		||||
Component, and (b) serves only to enable use of the work with that
 | 
			
		||||
Major Component, or to implement a Standard Interface for which an
 | 
			
		||||
implementation is available to the public in source code form.  A
 | 
			
		||||
"Major Component", in this context, means a major essential component
 | 
			
		||||
(kernel, window system, and so on) of the specific operating system
 | 
			
		||||
(if any) on which the executable work runs, or a compiler used to
 | 
			
		||||
produce the work, or an object code interpreter used to run it.
 | 
			
		||||
 | 
			
		||||
  The "Corresponding Source" for a work in object code form means all
 | 
			
		||||
the source code needed to generate, install, and (for an executable
 | 
			
		||||
work) run the object code and to modify the work, including scripts to
 | 
			
		||||
control those activities.  However, it does not include the work's
 | 
			
		||||
System Libraries, or general-purpose tools or generally available free
 | 
			
		||||
programs which are used unmodified in performing those activities but
 | 
			
		||||
which are not part of the work.  For example, Corresponding Source
 | 
			
		||||
includes interface definition files associated with source files for
 | 
			
		||||
the work, and the source code for shared libraries and dynamically
 | 
			
		||||
linked subprograms that the work is specifically designed to require,
 | 
			
		||||
such as by intimate data communication or control flow between those
 | 
			
		||||
subprograms and other parts of the work.
 | 
			
		||||
 | 
			
		||||
  The Corresponding Source need not include anything that users
 | 
			
		||||
can regenerate automatically from other parts of the Corresponding
 | 
			
		||||
Source.
 | 
			
		||||
 | 
			
		||||
  The Corresponding Source for a work in source code form is that
 | 
			
		||||
same work.
 | 
			
		||||
 | 
			
		||||
  2. Basic Permissions.
 | 
			
		||||
 | 
			
		||||
  All rights granted under this License are granted for the term of
 | 
			
		||||
copyright on the Program, and are irrevocable provided the stated
 | 
			
		||||
conditions are met.  This License explicitly affirms your unlimited
 | 
			
		||||
permission to run the unmodified Program.  The output from running a
 | 
			
		||||
covered work is covered by this License only if the output, given its
 | 
			
		||||
content, constitutes a covered work.  This License acknowledges your
 | 
			
		||||
rights of fair use or other equivalent, as provided by copyright law.
 | 
			
		||||
 | 
			
		||||
  You may make, run and propagate covered works that you do not
 | 
			
		||||
convey, without conditions so long as your license otherwise remains
 | 
			
		||||
in force.  You may convey covered works to others for the sole purpose
 | 
			
		||||
of having them make modifications exclusively for you, or provide you
 | 
			
		||||
with facilities for running those works, provided that you comply with
 | 
			
		||||
the terms of this License in conveying all material for which you do
 | 
			
		||||
not control copyright.  Those thus making or running the covered works
 | 
			
		||||
for you must do so exclusively on your behalf, under your direction
 | 
			
		||||
and control, on terms that prohibit them from making any copies of
 | 
			
		||||
your copyrighted material outside their relationship with you.
 | 
			
		||||
 | 
			
		||||
  Conveying under any other circumstances is permitted solely under
 | 
			
		||||
the conditions stated below.  Sublicensing is not allowed; section 10
 | 
			
		||||
makes it unnecessary.
 | 
			
		||||
 | 
			
		||||
  3. Protecting Users' Legal Rights From Anti-Circumvention Law.
 | 
			
		||||
 | 
			
		||||
  No covered work shall be deemed part of an effective technological
 | 
			
		||||
measure under any applicable law fulfilling obligations under article
 | 
			
		||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
 | 
			
		||||
similar laws prohibiting or restricting circumvention of such
 | 
			
		||||
measures.
 | 
			
		||||
 | 
			
		||||
  When you convey a covered work, you waive any legal power to forbid
 | 
			
		||||
circumvention of technological measures to the extent such circumvention
 | 
			
		||||
is effected by exercising rights under this License with respect to
 | 
			
		||||
the covered work, and you disclaim any intention to limit operation or
 | 
			
		||||
modification of the work as a means of enforcing, against the work's
 | 
			
		||||
users, your or third parties' legal rights to forbid circumvention of
 | 
			
		||||
technological measures.
 | 
			
		||||
 | 
			
		||||
  4. Conveying Verbatim Copies.
 | 
			
		||||
 | 
			
		||||
  You may convey verbatim copies of the Program's source code as you
 | 
			
		||||
receive it, in any medium, provided that you conspicuously and
 | 
			
		||||
appropriately publish on each copy an appropriate copyright notice;
 | 
			
		||||
keep intact all notices stating that this License and any
 | 
			
		||||
non-permissive terms added in accord with section 7 apply to the code;
 | 
			
		||||
keep intact all notices of the absence of any warranty; and give all
 | 
			
		||||
recipients a copy of this License along with the Program.
 | 
			
		||||
 | 
			
		||||
  You may charge any price or no price for each copy that you convey,
 | 
			
		||||
and you may offer support or warranty protection for a fee.
 | 
			
		||||
 | 
			
		||||
  5. Conveying Modified Source Versions.
 | 
			
		||||
 | 
			
		||||
  You may convey a work based on the Program, or the modifications to
 | 
			
		||||
produce it from the Program, in the form of source code under the
 | 
			
		||||
terms of section 4, provided that you also meet all of these conditions:
 | 
			
		||||
 | 
			
		||||
    a) The work must carry prominent notices stating that you modified
 | 
			
		||||
    it, and giving a relevant date.
 | 
			
		||||
 | 
			
		||||
    b) The work must carry prominent notices stating that it is
 | 
			
		||||
    released under this License and any conditions added under section
 | 
			
		||||
    7.  This requirement modifies the requirement in section 4 to
 | 
			
		||||
    "keep intact all notices".
 | 
			
		||||
 | 
			
		||||
    c) You must license the entire work, as a whole, under this
 | 
			
		||||
    License to anyone who comes into possession of a copy.  This
 | 
			
		||||
    License will therefore apply, along with any applicable section 7
 | 
			
		||||
    additional terms, to the whole of the work, and all its parts,
 | 
			
		||||
    regardless of how they are packaged.  This License gives no
 | 
			
		||||
    permission to license the work in any other way, but it does not
 | 
			
		||||
    invalidate such permission if you have separately received it.
 | 
			
		||||
 | 
			
		||||
    d) If the work has interactive user interfaces, each must display
 | 
			
		||||
    Appropriate Legal Notices; however, if the Program has interactive
 | 
			
		||||
    interfaces that do not display Appropriate Legal Notices, your
 | 
			
		||||
    work need not make them do so.
 | 
			
		||||
 | 
			
		||||
  A compilation of a covered work with other separate and independent
 | 
			
		||||
works, which are not by their nature extensions of the covered work,
 | 
			
		||||
and which are not combined with it such as to form a larger program,
 | 
			
		||||
in or on a volume of a storage or distribution medium, is called an
 | 
			
		||||
"aggregate" if the compilation and its resulting copyright are not
 | 
			
		||||
used to limit the access or legal rights of the compilation's users
 | 
			
		||||
beyond what the individual works permit.  Inclusion of a covered work
 | 
			
		||||
in an aggregate does not cause this License to apply to the other
 | 
			
		||||
parts of the aggregate.
 | 
			
		||||
 | 
			
		||||
  6. Conveying Non-Source Forms.
 | 
			
		||||
 | 
			
		||||
  You may convey a covered work in object code form under the terms
 | 
			
		||||
of sections 4 and 5, provided that you also convey the
 | 
			
		||||
machine-readable Corresponding Source under the terms of this License,
 | 
			
		||||
in one of these ways:
 | 
			
		||||
 | 
			
		||||
    a) Convey the object code in, or embodied in, a physical product
 | 
			
		||||
    (including a physical distribution medium), accompanied by the
 | 
			
		||||
    Corresponding Source fixed on a durable physical medium
 | 
			
		||||
    customarily used for software interchange.
 | 
			
		||||
 | 
			
		||||
    b) Convey the object code in, or embodied in, a physical product
 | 
			
		||||
    (including a physical distribution medium), accompanied by a
 | 
			
		||||
    written offer, valid for at least three years and valid for as
 | 
			
		||||
    long as you offer spare parts or customer support for that product
 | 
			
		||||
    model, to give anyone who possesses the object code either (1) a
 | 
			
		||||
    copy of the Corresponding Source for all the software in the
 | 
			
		||||
    product that is covered by this License, on a durable physical
 | 
			
		||||
    medium customarily used for software interchange, for a price no
 | 
			
		||||
    more than your reasonable cost of physically performing this
 | 
			
		||||
    conveying of source, or (2) access to copy the
 | 
			
		||||
    Corresponding Source from a network server at no charge.
 | 
			
		||||
 | 
			
		||||
    c) Convey individual copies of the object code with a copy of the
 | 
			
		||||
    written offer to provide the Corresponding Source.  This
 | 
			
		||||
    alternative is allowed only occasionally and noncommercially, and
 | 
			
		||||
    only if you received the object code with such an offer, in accord
 | 
			
		||||
    with subsection 6b.
 | 
			
		||||
 | 
			
		||||
    d) Convey the object code by offering access from a designated
 | 
			
		||||
    place (gratis or for a charge), and offer equivalent access to the
 | 
			
		||||
    Corresponding Source in the same way through the same place at no
 | 
			
		||||
    further charge.  You need not require recipients to copy the
 | 
			
		||||
    Corresponding Source along with the object code.  If the place to
 | 
			
		||||
    copy the object code is a network server, the Corresponding Source
 | 
			
		||||
    may be on a different server (operated by you or a third party)
 | 
			
		||||
    that supports equivalent copying facilities, provided you maintain
 | 
			
		||||
    clear directions next to the object code saying where to find the
 | 
			
		||||
    Corresponding Source.  Regardless of what server hosts the
 | 
			
		||||
    Corresponding Source, you remain obligated to ensure that it is
 | 
			
		||||
    available for as long as needed to satisfy these requirements.
 | 
			
		||||
 | 
			
		||||
    e) Convey the object code using peer-to-peer transmission, provided
 | 
			
		||||
    you inform other peers where the object code and Corresponding
 | 
			
		||||
    Source of the work are being offered to the general public at no
 | 
			
		||||
    charge under subsection 6d.
 | 
			
		||||
 | 
			
		||||
  A separable portion of the object code, whose source code is excluded
 | 
			
		||||
from the Corresponding Source as a System Library, need not be
 | 
			
		||||
included in conveying the object code work.
 | 
			
		||||
 | 
			
		||||
  A "User Product" is either (1) a "consumer product", which means any
 | 
			
		||||
tangible personal property which is normally used for personal, family,
 | 
			
		||||
or household purposes, or (2) anything designed or sold for incorporation
 | 
			
		||||
into a dwelling.  In determining whether a product is a consumer product,
 | 
			
		||||
doubtful cases shall be resolved in favor of coverage.  For a particular
 | 
			
		||||
product received by a particular user, "normally used" refers to a
 | 
			
		||||
typical or common use of that class of product, regardless of the status
 | 
			
		||||
of the particular user or of the way in which the particular user
 | 
			
		||||
actually uses, or expects or is expected to use, the product.  A product
 | 
			
		||||
is a consumer product regardless of whether the product has substantial
 | 
			
		||||
commercial, industrial or non-consumer uses, unless such uses represent
 | 
			
		||||
the only significant mode of use of the product.
 | 
			
		||||
 | 
			
		||||
  "Installation Information" for a User Product means any methods,
 | 
			
		||||
procedures, authorization keys, or other information required to install
 | 
			
		||||
and execute modified versions of a covered work in that User Product from
 | 
			
		||||
a modified version of its Corresponding Source.  The information must
 | 
			
		||||
suffice to ensure that the continued functioning of the modified object
 | 
			
		||||
code is in no case prevented or interfered with solely because
 | 
			
		||||
modification has been made.
 | 
			
		||||
 | 
			
		||||
  If you convey an object code work under this section in, or with, or
 | 
			
		||||
specifically for use in, a User Product, and the conveying occurs as
 | 
			
		||||
part of a transaction in which the right of possession and use of the
 | 
			
		||||
User Product is transferred to the recipient in perpetuity or for a
 | 
			
		||||
fixed term (regardless of how the transaction is characterized), the
 | 
			
		||||
Corresponding Source conveyed under this section must be accompanied
 | 
			
		||||
by the Installation Information.  But this requirement does not apply
 | 
			
		||||
if neither you nor any third party retains the ability to install
 | 
			
		||||
modified object code on the User Product (for example, the work has
 | 
			
		||||
been installed in ROM).
 | 
			
		||||
 | 
			
		||||
  The requirement to provide Installation Information does not include a
 | 
			
		||||
requirement to continue to provide support service, warranty, or updates
 | 
			
		||||
for a work that has been modified or installed by the recipient, or for
 | 
			
		||||
the User Product in which it has been modified or installed.  Access to a
 | 
			
		||||
network may be denied when the modification itself materially and
 | 
			
		||||
adversely affects the operation of the network or violates the rules and
 | 
			
		||||
protocols for communication across the network.
 | 
			
		||||
 | 
			
		||||
  Corresponding Source conveyed, and Installation Information provided,
 | 
			
		||||
in accord with this section must be in a format that is publicly
 | 
			
		||||
documented (and with an implementation available to the public in
 | 
			
		||||
source code form), and must require no special password or key for
 | 
			
		||||
unpacking, reading or copying.
 | 
			
		||||
 | 
			
		||||
  7. Additional Terms.
 | 
			
		||||
 | 
			
		||||
  "Additional permissions" are terms that supplement the terms of this
 | 
			
		||||
License by making exceptions from one or more of its conditions.
 | 
			
		||||
Additional permissions that are applicable to the entire Program shall
 | 
			
		||||
be treated as though they were included in this License, to the extent
 | 
			
		||||
that they are valid under applicable law.  If additional permissions
 | 
			
		||||
apply only to part of the Program, that part may be used separately
 | 
			
		||||
under those permissions, but the entire Program remains governed by
 | 
			
		||||
this License without regard to the additional permissions.
 | 
			
		||||
 | 
			
		||||
  When you convey a copy of a covered work, you may at your option
 | 
			
		||||
remove any additional permissions from that copy, or from any part of
 | 
			
		||||
it.  (Additional permissions may be written to require their own
 | 
			
		||||
removal in certain cases when you modify the work.)  You may place
 | 
			
		||||
additional permissions on material, added by you to a covered work,
 | 
			
		||||
for which you have or can give appropriate copyright permission.
 | 
			
		||||
 | 
			
		||||
  Notwithstanding any other provision of this License, for material you
 | 
			
		||||
add to a covered work, you may (if authorized by the copyright holders of
 | 
			
		||||
that material) supplement the terms of this License with terms:
 | 
			
		||||
 | 
			
		||||
    a) Disclaiming warranty or limiting liability differently from the
 | 
			
		||||
    terms of sections 15 and 16 of this License; or
 | 
			
		||||
 | 
			
		||||
    b) Requiring preservation of specified reasonable legal notices or
 | 
			
		||||
    author attributions in that material or in the Appropriate Legal
 | 
			
		||||
    Notices displayed by works containing it; or
 | 
			
		||||
 | 
			
		||||
    c) Prohibiting misrepresentation of the origin of that material, or
 | 
			
		||||
    requiring that modified versions of such material be marked in
 | 
			
		||||
    reasonable ways as different from the original version; or
 | 
			
		||||
 | 
			
		||||
    d) Limiting the use for publicity purposes of names of licensors or
 | 
			
		||||
    authors of the material; or
 | 
			
		||||
 | 
			
		||||
    e) Declining to grant rights under trademark law for use of some
 | 
			
		||||
    trade names, trademarks, or service marks; or
 | 
			
		||||
 | 
			
		||||
    f) Requiring indemnification of licensors and authors of that
 | 
			
		||||
    material by anyone who conveys the material (or modified versions of
 | 
			
		||||
    it) with contractual assumptions of liability to the recipient, for
 | 
			
		||||
    any liability that these contractual assumptions directly impose on
 | 
			
		||||
    those licensors and authors.
 | 
			
		||||
 | 
			
		||||
  All other non-permissive additional terms are considered "further
 | 
			
		||||
restrictions" within the meaning of section 10.  If the Program as you
 | 
			
		||||
received it, or any part of it, contains a notice stating that it is
 | 
			
		||||
governed by this License along with a term that is a further
 | 
			
		||||
restriction, you may remove that term.  If a license document contains
 | 
			
		||||
a further restriction but permits relicensing or conveying under this
 | 
			
		||||
License, you may add to a covered work material governed by the terms
 | 
			
		||||
of that license document, provided that the further restriction does
 | 
			
		||||
not survive such relicensing or conveying.
 | 
			
		||||
 | 
			
		||||
  If you add terms to a covered work in accord with this section, you
 | 
			
		||||
must place, in the relevant source files, a statement of the
 | 
			
		||||
additional terms that apply to those files, or a notice indicating
 | 
			
		||||
where to find the applicable terms.
 | 
			
		||||
 | 
			
		||||
  Additional terms, permissive or non-permissive, may be stated in the
 | 
			
		||||
form of a separately written license, or stated as exceptions;
 | 
			
		||||
the above requirements apply either way.
 | 
			
		||||
 | 
			
		||||
  8. Termination.
 | 
			
		||||
 | 
			
		||||
  You may not propagate or modify a covered work except as expressly
 | 
			
		||||
provided under this License.  Any attempt otherwise to propagate or
 | 
			
		||||
modify it is void, and will automatically terminate your rights under
 | 
			
		||||
this License (including any patent licenses granted under the third
 | 
			
		||||
paragraph of section 11).
 | 
			
		||||
 | 
			
		||||
  However, if you cease all violation of this License, then your
 | 
			
		||||
license from a particular copyright holder is reinstated (a)
 | 
			
		||||
provisionally, unless and until the copyright holder explicitly and
 | 
			
		||||
finally terminates your license, and (b) permanently, if the copyright
 | 
			
		||||
holder fails to notify you of the violation by some reasonable means
 | 
			
		||||
prior to 60 days after the cessation.
 | 
			
		||||
 | 
			
		||||
  Moreover, your license from a particular copyright holder is
 | 
			
		||||
reinstated permanently if the copyright holder notifies you of the
 | 
			
		||||
violation by some reasonable means, this is the first time you have
 | 
			
		||||
received notice of violation of this License (for any work) from that
 | 
			
		||||
copyright holder, and you cure the violation prior to 30 days after
 | 
			
		||||
your receipt of the notice.
 | 
			
		||||
 | 
			
		||||
  Termination of your rights under this section does not terminate the
 | 
			
		||||
licenses of parties who have received copies or rights from you under
 | 
			
		||||
this License.  If your rights have been terminated and not permanently
 | 
			
		||||
reinstated, you do not qualify to receive new licenses for the same
 | 
			
		||||
material under section 10.
 | 
			
		||||
 | 
			
		||||
  9. Acceptance Not Required for Having Copies.
 | 
			
		||||
 | 
			
		||||
  You are not required to accept this License in order to receive or
 | 
			
		||||
run a copy of the Program.  Ancillary propagation of a covered work
 | 
			
		||||
occurring solely as a consequence of using peer-to-peer transmission
 | 
			
		||||
to receive a copy likewise does not require acceptance.  However,
 | 
			
		||||
nothing other than this License grants you permission to propagate or
 | 
			
		||||
modify any covered work.  These actions infringe copyright if you do
 | 
			
		||||
not accept this License.  Therefore, by modifying or propagating a
 | 
			
		||||
covered work, you indicate your acceptance of this License to do so.
 | 
			
		||||
 | 
			
		||||
  10. Automatic Licensing of Downstream Recipients.
 | 
			
		||||
 | 
			
		||||
  Each time you convey a covered work, the recipient automatically
 | 
			
		||||
receives a license from the original licensors, to run, modify and
 | 
			
		||||
propagate that work, subject to this License.  You are not responsible
 | 
			
		||||
for enforcing compliance by third parties with this License.
 | 
			
		||||
 | 
			
		||||
  An "entity transaction" is a transaction transferring control of an
 | 
			
		||||
organization, or substantially all assets of one, or subdividing an
 | 
			
		||||
organization, or merging organizations.  If propagation of a covered
 | 
			
		||||
work results from an entity transaction, each party to that
 | 
			
		||||
transaction who receives a copy of the work also receives whatever
 | 
			
		||||
licenses to the work the party's predecessor in interest had or could
 | 
			
		||||
give under the previous paragraph, plus a right to possession of the
 | 
			
		||||
Corresponding Source of the work from the predecessor in interest, if
 | 
			
		||||
the predecessor has it or can get it with reasonable efforts.
 | 
			
		||||
 | 
			
		||||
  You may not impose any further restrictions on the exercise of the
 | 
			
		||||
rights granted or affirmed under this License.  For example, you may
 | 
			
		||||
not impose a license fee, royalty, or other charge for exercise of
 | 
			
		||||
rights granted under this License, and you may not initiate litigation
 | 
			
		||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
 | 
			
		||||
any patent claim is infringed by making, using, selling, offering for
 | 
			
		||||
sale, or importing the Program or any portion of it.
 | 
			
		||||
 | 
			
		||||
  11. Patents.
 | 
			
		||||
 | 
			
		||||
  A "contributor" is a copyright holder who authorizes use under this
 | 
			
		||||
License of the Program or a work on which the Program is based.  The
 | 
			
		||||
work thus licensed is called the contributor's "contributor version".
 | 
			
		||||
 | 
			
		||||
  A contributor's "essential patent claims" are all patent claims
 | 
			
		||||
owned or controlled by the contributor, whether already acquired or
 | 
			
		||||
hereafter acquired, that would be infringed by some manner, permitted
 | 
			
		||||
by this License, of making, using, or selling its contributor version,
 | 
			
		||||
but do not include claims that would be infringed only as a
 | 
			
		||||
consequence of further modification of the contributor version.  For
 | 
			
		||||
purposes of this definition, "control" includes the right to grant
 | 
			
		||||
patent sublicenses in a manner consistent with the requirements of
 | 
			
		||||
this License.
 | 
			
		||||
 | 
			
		||||
  Each contributor grants you a non-exclusive, worldwide, royalty-free
 | 
			
		||||
patent license under the contributor's essential patent claims, to
 | 
			
		||||
make, use, sell, offer for sale, import and otherwise run, modify and
 | 
			
		||||
propagate the contents of its contributor version.
 | 
			
		||||
 | 
			
		||||
  In the following three paragraphs, a "patent license" is any express
 | 
			
		||||
agreement or commitment, however denominated, not to enforce a patent
 | 
			
		||||
(such as an express permission to practice a patent or covenant not to
 | 
			
		||||
sue for patent infringement).  To "grant" such a patent license to a
 | 
			
		||||
party means to make such an agreement or commitment not to enforce a
 | 
			
		||||
patent against the party.
 | 
			
		||||
 | 
			
		||||
  If you convey a covered work, knowingly relying on a patent license,
 | 
			
		||||
and the Corresponding Source of the work is not available for anyone
 | 
			
		||||
to copy, free of charge and under the terms of this License, through a
 | 
			
		||||
publicly available network server or other readily accessible means,
 | 
			
		||||
then you must either (1) cause the Corresponding Source to be so
 | 
			
		||||
available, or (2) arrange to deprive yourself of the benefit of the
 | 
			
		||||
patent license for this particular work, or (3) arrange, in a manner
 | 
			
		||||
consistent with the requirements of this License, to extend the patent
 | 
			
		||||
license to downstream recipients.  "Knowingly relying" means you have
 | 
			
		||||
actual knowledge that, but for the patent license, your conveying the
 | 
			
		||||
covered work in a country, or your recipient's use of the covered work
 | 
			
		||||
in a country, would infringe one or more identifiable patents in that
 | 
			
		||||
country that you have reason to believe are valid.
 | 
			
		||||
 | 
			
		||||
  If, pursuant to or in connection with a single transaction or
 | 
			
		||||
arrangement, you convey, or propagate by procuring conveyance of, a
 | 
			
		||||
covered work, and grant a patent license to some of the parties
 | 
			
		||||
receiving the covered work authorizing them to use, propagate, modify
 | 
			
		||||
or convey a specific copy of the covered work, then the patent license
 | 
			
		||||
you grant is automatically extended to all recipients of the covered
 | 
			
		||||
work and works based on it.
 | 
			
		||||
 | 
			
		||||
  A patent license is "discriminatory" if it does not include within
 | 
			
		||||
the scope of its coverage, prohibits the exercise of, or is
 | 
			
		||||
conditioned on the non-exercise of one or more of the rights that are
 | 
			
		||||
specifically granted under this License.  You may not convey a covered
 | 
			
		||||
work if you are a party to an arrangement with a third party that is
 | 
			
		||||
in the business of distributing software, under which you make payment
 | 
			
		||||
to the third party based on the extent of your activity of conveying
 | 
			
		||||
the work, and under which the third party grants, to any of the
 | 
			
		||||
parties who would receive the covered work from you, a discriminatory
 | 
			
		||||
patent license (a) in connection with copies of the covered work
 | 
			
		||||
conveyed by you (or copies made from those copies), or (b) primarily
 | 
			
		||||
for and in connection with specific products or compilations that
 | 
			
		||||
contain the covered work, unless you entered into that arrangement,
 | 
			
		||||
or that patent license was granted, prior to 28 March 2007.
 | 
			
		||||
 | 
			
		||||
  Nothing in this License shall be construed as excluding or limiting
 | 
			
		||||
any implied license or other defenses to infringement that may
 | 
			
		||||
otherwise be available to you under applicable patent law.
 | 
			
		||||
 | 
			
		||||
  12. No Surrender of Others' Freedom.
 | 
			
		||||
 | 
			
		||||
  If conditions are imposed on you (whether by court order, agreement or
 | 
			
		||||
otherwise) that contradict the conditions of this License, they do not
 | 
			
		||||
excuse you from the conditions of this License.  If you cannot convey a
 | 
			
		||||
covered work so as to satisfy simultaneously your obligations under this
 | 
			
		||||
License and any other pertinent obligations, then as a consequence you may
 | 
			
		||||
not convey it at all.  For example, if you agree to terms that obligate you
 | 
			
		||||
to collect a royalty for further conveying from those to whom you convey
 | 
			
		||||
the Program, the only way you could satisfy both those terms and this
 | 
			
		||||
License would be to refrain entirely from conveying the Program.
 | 
			
		||||
 | 
			
		||||
  13. Remote Network Interaction; Use with the GNU General Public License.
 | 
			
		||||
 | 
			
		||||
  Notwithstanding any other provision of this License, if you modify the
 | 
			
		||||
Program, your modified version must prominently offer all users
 | 
			
		||||
interacting with it remotely through a computer network (if your version
 | 
			
		||||
supports such interaction) an opportunity to receive the Corresponding
 | 
			
		||||
Source of your version by providing access to the Corresponding Source
 | 
			
		||||
from a network server at no charge, through some standard or customary
 | 
			
		||||
means of facilitating copying of software.  This Corresponding Source
 | 
			
		||||
shall include the Corresponding Source for any work covered by version 3
 | 
			
		||||
of the GNU General Public License that is incorporated pursuant to the
 | 
			
		||||
following paragraph.
 | 
			
		||||
 | 
			
		||||
  Notwithstanding any other provision of this License, you have
 | 
			
		||||
permission to link or combine any covered work with a work licensed
 | 
			
		||||
under version 3 of the GNU General Public License into a single
 | 
			
		||||
combined work, and to convey the resulting work.  The terms of this
 | 
			
		||||
License will continue to apply to the part which is the covered work,
 | 
			
		||||
but the work with which it is combined will remain governed by version
 | 
			
		||||
3 of the GNU General Public License.
 | 
			
		||||
 | 
			
		||||
  14. Revised Versions of this License.
 | 
			
		||||
 | 
			
		||||
  The Free Software Foundation may publish revised and/or new versions of
 | 
			
		||||
the GNU Affero General Public License from time to time.  Such new versions
 | 
			
		||||
will be similar in spirit to the present version, but may differ in detail to
 | 
			
		||||
address new problems or concerns.
 | 
			
		||||
 | 
			
		||||
  Each version is given a distinguishing version number.  If the
 | 
			
		||||
Program specifies that a certain numbered version of the GNU Affero General
 | 
			
		||||
Public License "or any later version" applies to it, you have the
 | 
			
		||||
option of following the terms and conditions either of that numbered
 | 
			
		||||
version or of any later version published by the Free Software
 | 
			
		||||
Foundation.  If the Program does not specify a version number of the
 | 
			
		||||
GNU Affero General Public License, you may choose any version ever published
 | 
			
		||||
by the Free Software Foundation.
 | 
			
		||||
 | 
			
		||||
  If the Program specifies that a proxy can decide which future
 | 
			
		||||
versions of the GNU Affero General Public License can be used, that proxy's
 | 
			
		||||
public statement of acceptance of a version permanently authorizes you
 | 
			
		||||
to choose that version for the Program.
 | 
			
		||||
 | 
			
		||||
  Later license versions may give you additional or different
 | 
			
		||||
permissions.  However, no additional obligations are imposed on any
 | 
			
		||||
author or copyright holder as a result of your choosing to follow a
 | 
			
		||||
later version.
 | 
			
		||||
 | 
			
		||||
  15. Disclaimer of Warranty.
 | 
			
		||||
 | 
			
		||||
  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
 | 
			
		||||
APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
 | 
			
		||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
 | 
			
		||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
 | 
			
		||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 | 
			
		||||
PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
 | 
			
		||||
IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
 | 
			
		||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
 | 
			
		||||
 | 
			
		||||
  16. Limitation of Liability.
 | 
			
		||||
 | 
			
		||||
  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
 | 
			
		||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
 | 
			
		||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
 | 
			
		||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
 | 
			
		||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
 | 
			
		||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
 | 
			
		||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
 | 
			
		||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
 | 
			
		||||
SUCH DAMAGES.
 | 
			
		||||
 | 
			
		||||
  17. Interpretation of Sections 15 and 16.
 | 
			
		||||
 | 
			
		||||
  If the disclaimer of warranty and limitation of liability provided
 | 
			
		||||
above cannot be given local legal effect according to their terms,
 | 
			
		||||
reviewing courts shall apply local law that most closely approximates
 | 
			
		||||
an absolute waiver of all civil liability in connection with the
 | 
			
		||||
Program, unless a warranty or assumption of liability accompanies a
 | 
			
		||||
copy of the Program in return for a fee.
 | 
			
		||||
 | 
			
		||||
                     END OF TERMS AND CONDITIONS
 | 
			
		||||
 | 
			
		||||
            How to Apply These Terms to Your New Programs
 | 
			
		||||
 | 
			
		||||
  If you develop a new program, and you want it to be of the greatest
 | 
			
		||||
possible use to the public, the best way to achieve this is to make it
 | 
			
		||||
free software which everyone can redistribute and change under these terms.
 | 
			
		||||
 | 
			
		||||
  To do so, attach the following notices to the program.  It is safest
 | 
			
		||||
to attach them to the start of each source file to most effectively
 | 
			
		||||
state the exclusion of warranty; and each file should have at least
 | 
			
		||||
the "copyright" line and a pointer to where the full notice is found.
 | 
			
		||||
 | 
			
		||||
    <one line to give the program's name and a brief idea of what it does.>
 | 
			
		||||
    Copyright (C) <year>  <name of author>
 | 
			
		||||
 | 
			
		||||
    This program is free software: you can redistribute it and/or modify
 | 
			
		||||
    it under the terms of the GNU Affero General Public License as published
 | 
			
		||||
    by the Free Software Foundation, either version 3 of the License, or
 | 
			
		||||
    (at your option) any later version.
 | 
			
		||||
 | 
			
		||||
    This program is distributed in the hope that it will be useful,
 | 
			
		||||
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
    GNU Affero General Public License for more details.
 | 
			
		||||
 | 
			
		||||
    You should have received a copy of the GNU Affero General Public License
 | 
			
		||||
    along with this program.  If not, see <https://www.gnu.org/licenses/>.
 | 
			
		||||
 | 
			
		||||
Also add information on how to contact you by electronic and paper mail.
 | 
			
		||||
 | 
			
		||||
  If your software can interact with users remotely through a computer
 | 
			
		||||
network, you should also make sure that it provides a way for users to
 | 
			
		||||
get its source.  For example, if your program is a web application, its
 | 
			
		||||
interface could display a "Source" link that leads users to an archive
 | 
			
		||||
of the code.  There are many ways you could offer source, and different
 | 
			
		||||
solutions will be better for different programs; see section 13 for the
 | 
			
		||||
specific requirements.
 | 
			
		||||
 | 
			
		||||
  You should also get your employer (if you work as a programmer) or school,
 | 
			
		||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
 | 
			
		||||
For more information on this, and how to apply and follow the GNU AGPL, see
 | 
			
		||||
<https://www.gnu.org/licenses/>.
 | 
			
		||||
							
								
								
									
										0
									
								
								build/.gitkeep
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								build/.gitkeep
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										5
									
								
								build/buildProjects.bat
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								build/buildProjects.bat
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,5 @@
 | 
			
		||||
dotnet build ../src/Connected.Common.Types.Model/Connected.Common.Types.Model.csproj
 | 
			
		||||
dotnet build ../src/Connected.Common.Types.Middleware/Connected.Common.Types.Middleware.csproj
 | 
			
		||||
dotnet build ../src/Connected.Common.Types/Connected.Common.Types.csproj
 | 
			
		||||
dotnet build ../src/Connected.Common.Types.Client/Connected.Common.Types.Client.csproj
 | 
			
		||||
dotnet build ../src/Connected.Common.Types.UI/Connected.Common.Types.UI.csproj
 | 
			
		||||
							
								
								
									
										1
									
								
								dependencies/Connected.Components
									
									
									
									
										vendored
									
									
										Submodule
									
								
							
							
								
								
								
								
								
								
									
									
								
							
						
						
									
										1
									
								
								dependencies/Connected.Components
									
									
									
									
										vendored
									
									
										Submodule
									
								
							@ -0,0 +1 @@
 | 
			
		||||
Subproject commit d7c2b58f2ef43d427146e6c76aad71adfe90ab09
 | 
			
		||||
							
								
								
									
										17
									
								
								nuget.config
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								nuget.config
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,17 @@
 | 
			
		||||
<?xml version="1.0" encoding="utf-8"?>
 | 
			
		||||
<configuration>
 | 
			
		||||
    <config>
 | 
			
		||||
        <add key="repositoryPath" value="%PACKAGEHOME%/External" />
 | 
			
		||||
    </config>
 | 
			
		||||
 | 
			
		||||
    <packageRestore>
 | 
			
		||||
        <add key="enabled" value="True" />
 | 
			
		||||
        <add key="automatic" value="True" />
 | 
			
		||||
    </packageRestore>
 | 
			
		||||
    <packageSources>
 | 
			
		||||
        <add key="NuGet official package source" value="https://api.nuget.org/v3/index.json" />
 | 
			
		||||
		<add key="Local repository" value="%LOCAL_NUGET%" />
 | 
			
		||||
    </packageSources>
 | 
			
		||||
 | 
			
		||||
    <disabledPackageSources />
 | 
			
		||||
</configuration>
 | 
			
		||||
							
								
								
									
										21
									
								
								src/Connected.Common.Types.Client/ClientBootstrapper.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								src/Connected.Common.Types.Client/ClientBootstrapper.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,21 @@
 | 
			
		||||
using Connected.Common.Types.TaxRates;
 | 
			
		||||
using Connected.Startup;
 | 
			
		||||
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
 | 
			
		||||
using Microsoft.Extensions.DependencyInjection;
 | 
			
		||||
 | 
			
		||||
namespace Connected.Common.Types;
 | 
			
		||||
 | 
			
		||||
public class ClientBootstrapper : IStartup
 | 
			
		||||
{
 | 
			
		||||
	public async Task Configure(WebAssemblyHost host)
 | 
			
		||||
	{
 | 
			
		||||
		await Task.CompletedTask;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public async Task ConfigureServices(IServiceCollection services)
 | 
			
		||||
	{
 | 
			
		||||
		services.Add(ServiceDescriptor.Scoped(typeof(ITaxRateService), typeof(TaxRateService)));
 | 
			
		||||
 | 
			
		||||
		await Task.CompletedTask;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,45 @@
 | 
			
		||||
<Project Sdk="Microsoft.NET.Sdk">
 | 
			
		||||
 | 
			
		||||
	<PropertyGroup>
 | 
			
		||||
		<TargetFramework>net7.0</TargetFramework>
 | 
			
		||||
		<ImplicitUsings>enable</ImplicitUsings>
 | 
			
		||||
		<Nullable>enable</Nullable>
 | 
			
		||||
		<RootNamespace>Connected.Common.Types</RootNamespace>
 | 
			
		||||
		<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
 | 
			
		||||
		<Title>$(AssemblyName)</Title>
 | 
			
		||||
		<Authors>Tom PIT ltd</Authors>
 | 
			
		||||
		<Copyright>2022 Tom PIT ltd</Copyright>
 | 
			
		||||
		<PackageProjectUrl>https://git.tompit.com/Connected/Info</PackageProjectUrl>
 | 
			
		||||
		<PackageReadmeFile>README.md</PackageReadmeFile>
 | 
			
		||||
		<PackageTags>connected;platform;</PackageTags>
 | 
			
		||||
		<IncludeSymbols>True</IncludeSymbols>
 | 
			
		||||
		<SymbolPackageFormat>snupkg</SymbolPackageFormat>
 | 
			
		||||
		<PackageLicenseFile>LICENSE</PackageLicenseFile>
 | 
			
		||||
		<PackageOutputPath>$(OutputPath)</PackageOutputPath>
 | 
			
		||||
	</PropertyGroup>
 | 
			
		||||
 | 
			
		||||
	<ItemGroup>
 | 
			
		||||
		<PackageReference Include="Connected.Client" Version="1.0.*-*"/>
 | 
			
		||||
		<PackageReference Include="Connected.Common.Types.Model" Version="1.0.*-*"/>
 | 
			
		||||
		<PackageReference Include="Nerdbank.GitVersioning"
 | 
			
		||||
									Version="3.5.119"
 | 
			
		||||
									PrivateAssets="all"
 | 
			
		||||
									Condition="!Exists('packages.config')" />
 | 
			
		||||
	</ItemGroup>
 | 
			
		||||
 | 
			
		||||
	<ItemGroup>
 | 
			
		||||
		<None Include="..\..\LICENSE">
 | 
			
		||||
			<Pack>True</Pack>
 | 
			
		||||
			<PackagePath>\</PackagePath>
 | 
			
		||||
		</None>
 | 
			
		||||
		<None Include="..\..\README.md">
 | 
			
		||||
			<Pack>True</Pack>
 | 
			
		||||
			<PackagePath>\</PackagePath>
 | 
			
		||||
		</None>
 | 
			
		||||
	</ItemGroup>
 | 
			
		||||
 | 
			
		||||
	<Target Name="CopyPackages" AfterTargets="Pack">
 | 
			
		||||
		<Copy SourceFiles="$(OutputPath)..\$(PackageId).$(PackageVersion).nupkg" DestinationFolder="$([System.Environment]::GetEnvironmentVariable('LOCAL_NUGET'))" />
 | 
			
		||||
		<Copy SourceFiles="$(OutputPath)..\$(PackageId).$(PackageVersion).snupkg" DestinationFolder="$([System.Environment]::GetEnvironmentVariable('LOCAL_NUGET'))" />
 | 
			
		||||
	</Target>
 | 
			
		||||
</Project>
 | 
			
		||||
							
								
								
									
										13
									
								
								src/Connected.Common.Types.Client/TaxRates/TaxRate.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								src/Connected.Common.Types.Client/TaxRates/TaxRate.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,13 @@
 | 
			
		||||
using Connected.Data;
 | 
			
		||||
 | 
			
		||||
namespace Connected.Common.Types.TaxRates;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// This is the client implementation if the <see cref="ITaxRate"/>.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public class TaxRate : PrimaryKey<int>, ITaxRate
 | 
			
		||||
{
 | 
			
		||||
	public string? Name { get; init; }
 | 
			
		||||
	public float Rate { get; init; }
 | 
			
		||||
	public Status Status { get; init; } = Status.Enabled;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										72
									
								
								src/Connected.Common.Types.Client/TaxRates/TaxRateService.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										72
									
								
								src/Connected.Common.Types.Client/TaxRates/TaxRateService.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,72 @@
 | 
			
		||||
using System.Collections.Immutable;
 | 
			
		||||
using Connected.Configuration;
 | 
			
		||||
using Connected.Net;
 | 
			
		||||
using Connected.Remote;
 | 
			
		||||
using Connected.ServiceModel;
 | 
			
		||||
using Connected.Services;
 | 
			
		||||
 | 
			
		||||
namespace Connected.Common.Types.TaxRates;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// This is the client implementation of the <see cref="ITaxRateService"/>.
 | 
			
		||||
/// </summary>
 | 
			
		||||
internal class TaxRateService : EntityService<int>, ITaxRateService, IRemoteService
 | 
			
		||||
{	
 | 
			
		||||
	public TaxRateService(IHttpService http, IConfigurationService configurationService)
 | 
			
		||||
	{
 | 
			
		||||
		Http = http;
 | 
			
		||||
		ConfigurationService = configurationService;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private IHttpService Http { get; }
 | 
			
		||||
 | 
			
		||||
	private IConfigurationService ConfigurationService { get; }
 | 
			
		||||
 | 
			
		||||
	private string GetBaseAddress() 
 | 
			
		||||
	{
 | 
			
		||||
		var serviceConfigurations = ConfigurationService.Remote.Query(nameof(TaxRateService));
 | 
			
		||||
 | 
			
		||||
		foreach (var configuration in serviceConfigurations)
 | 
			
		||||
		{
 | 
			
		||||
			if (!string.IsNullOrWhiteSpace(configuration?.Address))
 | 
			
		||||
				return configuration.Address;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		throw new Exception("No base address registered for TaxRateService");
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public async Task Delete(PrimaryKeyArgs<int> e)
 | 
			
		||||
	{
 | 
			
		||||
		await Http.Post($"{GetBaseAddress()}/management/commonTypes/taxRates/delete", e);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public async Task<int> Insert(InsertTaxRateArgs e)
 | 
			
		||||
	{
 | 
			
		||||
		return await Http.Post<int>($"{GetBaseAddress()}/management/commonTypes/taxRates/insert", e);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public async Task<ImmutableList<ITaxRate>?> Query(PrimaryKeyListArgs<int> e)
 | 
			
		||||
	{
 | 
			
		||||
		return (await Http.Post<List<TaxRate>?>($"{GetBaseAddress()}/management/commonTypes/taxRates/select", e))?.ToImmutableList<ITaxRate>() ?? ImmutableList<ITaxRate>.Empty;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public async Task<ImmutableList<ITaxRate>?> Query(QueryArgs? args)
 | 
			
		||||
	{
 | 
			
		||||
		return (await Http.Post<List<TaxRate>?>($"{GetBaseAddress()}/management/commonTypes/taxRates/query", args ?? QueryArgs.NoPaging))?.ToImmutableList<ITaxRate>() ?? ImmutableList<ITaxRate>.Empty;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public async Task<ITaxRate?> Select(PrimaryKeyArgs<int> e)
 | 
			
		||||
	{
 | 
			
		||||
		return await Http.Post<TaxRate>($"{GetBaseAddress()}/management/commonTypes/taxRates/select", e);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public async Task<ITaxRate?> Select(TaxRateArgs e)
 | 
			
		||||
	{
 | 
			
		||||
		return await Http.Post<TaxRate>($"{GetBaseAddress()}/management/commonTypes/taxRates/select", e);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public async Task Update(UpdateTaxRateArgs e)
 | 
			
		||||
	{
 | 
			
		||||
		await Http.Post<TaxRate>($"{GetBaseAddress()}/management/commonTypes/taxRates/update", e);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										14
									
								
								src/Connected.Common.Types.Client/version.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								src/Connected.Common.Types.Client/version.json
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,14 @@
 | 
			
		||||
{
 | 
			
		||||
  "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/main/src/NerdBank.GitVersioning/version.schema.json",
 | 
			
		||||
  "version": "1.0-prerelease",
 | 
			
		||||
  "semVer1NumericIdentifierPadding": 4,
 | 
			
		||||
  "nugetPackageVersion": {
 | 
			
		||||
    "semVer": 2, // optional. Set to either 1 or 2 to control how the NuGet package version string is generated. Default is 1.
 | 
			
		||||
    "precision": "build" // optional. Use when you want to use a more or less precise package version than the default major.minor.build.
 | 
			
		||||
  },
 | 
			
		||||
  "cloudBuild": {
 | 
			
		||||
    "buildNumber": {
 | 
			
		||||
      "enabled": true
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,45 @@
 | 
			
		||||
<Project Sdk="Microsoft.NET.Sdk">
 | 
			
		||||
 | 
			
		||||
	<PropertyGroup>
 | 
			
		||||
		<TargetFramework>net7.0</TargetFramework>
 | 
			
		||||
		<ImplicitUsings>enable</ImplicitUsings>
 | 
			
		||||
		<Nullable>enable</Nullable>
 | 
			
		||||
		<RootNamespace>Connected.Common.Types</RootNamespace>
 | 
			
		||||
		<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
 | 
			
		||||
		<Title>$(AssemblyName)</Title>
 | 
			
		||||
		<Authors>Tom PIT ltd</Authors>
 | 
			
		||||
		<Copyright>2022 Tom PIT ltd</Copyright>
 | 
			
		||||
		<PackageProjectUrl>https://git.tompit.com/Connected/Info</PackageProjectUrl>
 | 
			
		||||
		<PackageReadmeFile>README.md</PackageReadmeFile>
 | 
			
		||||
		<PackageTags>connected;platform;</PackageTags>
 | 
			
		||||
		<IncludeSymbols>True</IncludeSymbols>
 | 
			
		||||
		<SymbolPackageFormat>snupkg</SymbolPackageFormat>
 | 
			
		||||
		<PackageLicenseFile>LICENSE</PackageLicenseFile>
 | 
			
		||||
		<PackageOutputPath>$(OutputPath)</PackageOutputPath>
 | 
			
		||||
	</PropertyGroup>
 | 
			
		||||
 | 
			
		||||
	<ItemGroup>
 | 
			
		||||
		<PackageReference Include="Connected.Middleware" Version="1.0.*-*" />
 | 
			
		||||
		<PackageReference Include="Connected.Common.Types.Model" Version="1.0.*-*" />
 | 
			
		||||
		<PackageReference Include="Nerdbank.GitVersioning"
 | 
			
		||||
									Version="3.5.119"
 | 
			
		||||
									PrivateAssets="all"
 | 
			
		||||
									Condition="!Exists('packages.config')" />
 | 
			
		||||
	</ItemGroup>
 | 
			
		||||
 | 
			
		||||
	<ItemGroup>
 | 
			
		||||
		<None Include="..\..\LICENSE">
 | 
			
		||||
			<Pack>True</Pack>
 | 
			
		||||
			<PackagePath>\</PackagePath>
 | 
			
		||||
		</None>
 | 
			
		||||
		<None Include="..\..\README.md">
 | 
			
		||||
			<Pack>True</Pack>
 | 
			
		||||
			<PackagePath>\</PackagePath>
 | 
			
		||||
		</None>
 | 
			
		||||
	</ItemGroup>
 | 
			
		||||
 | 
			
		||||
	<Target Name="CopyPackages" AfterTargets="Pack">
 | 
			
		||||
		<Copy SourceFiles="$(OutputPath)..\$(PackageId).$(PackageVersion).nupkg" DestinationFolder="$([System.Environment]::GetEnvironmentVariable('LOCAL_NUGET'))" />
 | 
			
		||||
		<Copy SourceFiles="$(OutputPath)..\$(PackageId).$(PackageVersion).snupkg" DestinationFolder="$([System.Environment]::GetEnvironmentVariable('LOCAL_NUGET'))" />
 | 
			
		||||
	</Target>
 | 
			
		||||
</Project>
 | 
			
		||||
@ -0,0 +1,8 @@
 | 
			
		||||
using Connected.Common.Types.Currencies;
 | 
			
		||||
 | 
			
		||||
namespace Connected.Common.Types.Middleware.Currencies;
 | 
			
		||||
 | 
			
		||||
public interface ICurrencyFormatterMiddleware<TValue> : IMiddleware
 | 
			
		||||
{
 | 
			
		||||
	Task<string?> Format(TValue value, ICurrency currency, string format);
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										14
									
								
								src/Connected.Common.Types.Middleware/version.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								src/Connected.Common.Types.Middleware/version.json
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,14 @@
 | 
			
		||||
{
 | 
			
		||||
  "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/main/src/NerdBank.GitVersioning/version.schema.json",
 | 
			
		||||
  "version": "1.0-prerelease",
 | 
			
		||||
  "semVer1NumericIdentifierPadding": 4,
 | 
			
		||||
  "nugetPackageVersion": {
 | 
			
		||||
    "semVer": 2, // optional. Set to either 1 or 2 to control how the NuGet package version string is generated. Default is 1.
 | 
			
		||||
    "precision": "build" // optional. Use when you want to use a more or less precise package version than the default major.minor.build.
 | 
			
		||||
  },
 | 
			
		||||
  "cloudBuild": {
 | 
			
		||||
    "buildNumber": {
 | 
			
		||||
      "enabled": true
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,32 @@
 | 
			
		||||
using System.ComponentModel.DataAnnotations;
 | 
			
		||||
using Connected.Annotations;
 | 
			
		||||
using Connected.Data;
 | 
			
		||||
using Connected.ServiceModel;
 | 
			
		||||
 | 
			
		||||
namespace Connected.Common.Types.BankAccounts;
 | 
			
		||||
 | 
			
		||||
public class BankAccountInsertArgs : Dto
 | 
			
		||||
{
 | 
			
		||||
	[MinValue(1)]
 | 
			
		||||
	public int Bank { get; set; }
 | 
			
		||||
 | 
			
		||||
	[Required]
 | 
			
		||||
	[MaxLength(128)]
 | 
			
		||||
	public string? Iban { get; set; }
 | 
			
		||||
 | 
			
		||||
	[Required]
 | 
			
		||||
	[MaxLength(128)]
 | 
			
		||||
	public string? Type { get; set; }
 | 
			
		||||
 | 
			
		||||
	[Required]
 | 
			
		||||
	[MaxLength(128)]
 | 
			
		||||
	public string? PrimaryKey { get; set; }
 | 
			
		||||
 | 
			
		||||
	public Status Status { get; set; } = Status.Enabled;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
public sealed class BankAccountUpdateArgs : BankAccountInsertArgs
 | 
			
		||||
{
 | 
			
		||||
	[MinValue(1)]
 | 
			
		||||
	public int Id { get; set; }
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,12 @@
 | 
			
		||||
using Connected.Data;
 | 
			
		||||
 | 
			
		||||
namespace Connected.Common.Types.BankAccounts;
 | 
			
		||||
 | 
			
		||||
public interface IBankAccount : IPrimaryKey<int>
 | 
			
		||||
{
 | 
			
		||||
	string Iban { get; init; }
 | 
			
		||||
	Status Status { get; init; }
 | 
			
		||||
	int Bank { get; init; }
 | 
			
		||||
	string Type { get; init; }
 | 
			
		||||
	string PrimaryKey { get; init; }
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,32 @@
 | 
			
		||||
using System.Collections.Immutable;
 | 
			
		||||
using Connected.Annotations;
 | 
			
		||||
using Connected.Notifications;
 | 
			
		||||
using Connected.ServiceModel;
 | 
			
		||||
 | 
			
		||||
namespace Connected.Common.Types.BankAccounts;
 | 
			
		||||
 | 
			
		||||
[Service]
 | 
			
		||||
[ServiceUrl(Routes.BankAccounts)]
 | 
			
		||||
public interface IBankAccountService : IServiceNotifications<int>
 | 
			
		||||
{
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Get)]
 | 
			
		||||
	Task<ImmutableList<IBankAccount>?> Query();
 | 
			
		||||
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Get | ServiceMethodVerbs.Post)]
 | 
			
		||||
	Task<ImmutableList<IBankAccount>?> Query(PrimaryKeyArgs<int> args);
 | 
			
		||||
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Get | ServiceMethodVerbs.Post)]
 | 
			
		||||
	Task<ImmutableList<IBankAccount>?> Query(PrimaryKeyListArgs<int> args);
 | 
			
		||||
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Get | ServiceMethodVerbs.Post)]
 | 
			
		||||
	Task<IBankAccount?> Select(PrimaryKeyArgs<int> args);
 | 
			
		||||
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Post | ServiceMethodVerbs.Delete)]
 | 
			
		||||
	Task Delete(PrimaryKeyArgs<int> args);
 | 
			
		||||
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Post | ServiceMethodVerbs.Put)]
 | 
			
		||||
	Task<int> Insert(BankAccountInsertArgs args);
 | 
			
		||||
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Post | ServiceMethodVerbs.Put | ServiceMethodVerbs.Patch)]
 | 
			
		||||
	Task Update(BankAccountUpdateArgs args);
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										28
									
								
								src/Connected.Common.Types.Model/Banks/BankArgs.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								src/Connected.Common.Types.Model/Banks/BankArgs.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,28 @@
 | 
			
		||||
using System.ComponentModel.DataAnnotations;
 | 
			
		||||
using Connected.Annotations;
 | 
			
		||||
using Connected.Data;
 | 
			
		||||
using Connected.ServiceModel;
 | 
			
		||||
 | 
			
		||||
namespace Connected.Common.Types.Banks;
 | 
			
		||||
 | 
			
		||||
public class InsertBankArgs : Dto
 | 
			
		||||
{
 | 
			
		||||
	[Required]
 | 
			
		||||
	[MaxLength(128)]
 | 
			
		||||
	public string? Name { get; set; }
 | 
			
		||||
 | 
			
		||||
	[MinValue(1)]
 | 
			
		||||
	public int Country { get; set; }
 | 
			
		||||
 | 
			
		||||
	[Required]
 | 
			
		||||
	[MaxLength(128)]
 | 
			
		||||
	public string? Bic { get; set; }
 | 
			
		||||
 | 
			
		||||
	public Status Status { get; set; } = Status.Enabled;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
public class UpdateBankArgs : InsertBankArgs
 | 
			
		||||
{
 | 
			
		||||
	[MinValue(1)]
 | 
			
		||||
	public int Id { get; set; }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										11
									
								
								src/Connected.Common.Types.Model/Banks/IBank.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								src/Connected.Common.Types.Model/Banks/IBank.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,11 @@
 | 
			
		||||
using Connected.Data;
 | 
			
		||||
 | 
			
		||||
namespace Connected.Common.Types.Banks;
 | 
			
		||||
 | 
			
		||||
public interface IBank : IPrimaryKey<int>
 | 
			
		||||
{
 | 
			
		||||
	string Name { get; init; }
 | 
			
		||||
	int Country { get; init; }
 | 
			
		||||
	string Bic { get; init; }
 | 
			
		||||
	Status Status { get; init; }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										29
									
								
								src/Connected.Common.Types.Model/Banks/IBankService.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								src/Connected.Common.Types.Model/Banks/IBankService.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,29 @@
 | 
			
		||||
using System.Collections.Immutable;
 | 
			
		||||
using Connected.Annotations;
 | 
			
		||||
using Connected.Notifications;
 | 
			
		||||
using Connected.ServiceModel;
 | 
			
		||||
 | 
			
		||||
namespace Connected.Common.Types.Banks;
 | 
			
		||||
 | 
			
		||||
[Service]
 | 
			
		||||
[ServiceUrl(Routes.Banks)]
 | 
			
		||||
public interface IBankService : IServiceNotifications<int>
 | 
			
		||||
{
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Get)]
 | 
			
		||||
	Task<ImmutableList<IBank>?> Query();
 | 
			
		||||
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Get | ServiceMethodVerbs.Post)]
 | 
			
		||||
	Task<ImmutableList<IBank>?> Query(PrimaryKeyListArgs<int> args);
 | 
			
		||||
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Get | ServiceMethodVerbs.Post)]
 | 
			
		||||
	Task<IBank?> Select(PrimaryKeyArgs<int> args);
 | 
			
		||||
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Post | ServiceMethodVerbs.Put)]
 | 
			
		||||
	Task<int> Insert(InsertBankArgs args);
 | 
			
		||||
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Post | ServiceMethodVerbs.Put | ServiceMethodVerbs.Patch)]
 | 
			
		||||
	Task Update(UpdateBankArgs args);
 | 
			
		||||
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Post | ServiceMethodVerbs.Delete)]
 | 
			
		||||
	Task Delete(PrimaryKeyArgs<int> args);
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,45 @@
 | 
			
		||||
<Project Sdk="Microsoft.NET.Sdk">
 | 
			
		||||
 | 
			
		||||
	<PropertyGroup>
 | 
			
		||||
		<TargetFramework>net7.0</TargetFramework>
 | 
			
		||||
		<ImplicitUsings>enable</ImplicitUsings>
 | 
			
		||||
		<Nullable>enable</Nullable>
 | 
			
		||||
		<RootNamespace>Connected.Common.Types</RootNamespace>
 | 
			
		||||
		<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
 | 
			
		||||
		<Title>$(AssemblyName)</Title>
 | 
			
		||||
		<Authors>Tom PIT ltd</Authors>
 | 
			
		||||
		<Copyright>2022 Tom PIT ltd</Copyright>
 | 
			
		||||
		<PackageProjectUrl>https://git.tompit.com/Connected/Info</PackageProjectUrl>
 | 
			
		||||
		<PackageReadmeFile>README.md</PackageReadmeFile>
 | 
			
		||||
		<PackageTags>connected;platform;</PackageTags>
 | 
			
		||||
		<IncludeSymbols>True</IncludeSymbols>
 | 
			
		||||
		<SymbolPackageFormat>snupkg</SymbolPackageFormat>
 | 
			
		||||
		<PackageLicenseFile>LICENSE</PackageLicenseFile>
 | 
			
		||||
		<PackageOutputPath>$(OutputPath)</PackageOutputPath>
 | 
			
		||||
	</PropertyGroup>
 | 
			
		||||
 | 
			
		||||
	<ItemGroup>
 | 
			
		||||
		<PackageReference Include="Connected.Common.Model" Version="1.0.*-*" />
 | 
			
		||||
		<PackageReference Include="Connected" Version="1.0.*-*" />
 | 
			
		||||
		<PackageReference Include="Nerdbank.GitVersioning"
 | 
			
		||||
									Version="3.5.119"
 | 
			
		||||
									PrivateAssets="all"
 | 
			
		||||
									Condition="!Exists('packages.config')" />
 | 
			
		||||
	</ItemGroup>
 | 
			
		||||
 | 
			
		||||
	<ItemGroup>
 | 
			
		||||
		<None Include="..\..\LICENSE">
 | 
			
		||||
			<Pack>True</Pack>
 | 
			
		||||
			<PackagePath>\</PackagePath>
 | 
			
		||||
		</None>
 | 
			
		||||
		<None Include="..\..\README.md">
 | 
			
		||||
			<Pack>True</Pack>
 | 
			
		||||
			<PackagePath>\</PackagePath>
 | 
			
		||||
		</None>
 | 
			
		||||
	</ItemGroup>
 | 
			
		||||
 | 
			
		||||
	<Target Name="CopyPackages" AfterTargets="Pack">
 | 
			
		||||
		<Copy SourceFiles="$(OutputPath)..\$(PackageId).$(PackageVersion).nupkg" DestinationFolder="$([System.Environment]::GetEnvironmentVariable('LOCAL_NUGET'))" />
 | 
			
		||||
		<Copy SourceFiles="$(OutputPath)..\$(PackageId).$(PackageVersion).snupkg" DestinationFolder="$([System.Environment]::GetEnvironmentVariable('LOCAL_NUGET'))" />
 | 
			
		||||
	</Target>
 | 
			
		||||
</Project>
 | 
			
		||||
							
								
								
									
										18
									
								
								src/Connected.Common.Types.Model/Continent/ContinentArgs.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								src/Connected.Common.Types.Model/Continent/ContinentArgs.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,18 @@
 | 
			
		||||
using System.ComponentModel.DataAnnotations;
 | 
			
		||||
using Connected.Annotations;
 | 
			
		||||
using Connected.ServiceModel;
 | 
			
		||||
 | 
			
		||||
namespace Connected.Common.Types.Continent;
 | 
			
		||||
 | 
			
		||||
public class InsertContinentArgs : Dto
 | 
			
		||||
{
 | 
			
		||||
	[Required]
 | 
			
		||||
	[MaxLength(128)]
 | 
			
		||||
	public string? Name { get; set; }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
public sealed class UpdateContitentArgs : InsertContinentArgs
 | 
			
		||||
{
 | 
			
		||||
	[MinValue(1)]
 | 
			
		||||
	public int Id { get; set; }
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,13 @@
 | 
			
		||||
using Connected.Annotations;
 | 
			
		||||
using Connected.ServiceModel;
 | 
			
		||||
 | 
			
		||||
namespace Connected.Common.Types.Continent.Countries;
 | 
			
		||||
 | 
			
		||||
public class InsertContinentCountryArgs : Dto
 | 
			
		||||
{
 | 
			
		||||
	[MinValue(1)]
 | 
			
		||||
	public int Continent { get; set; }
 | 
			
		||||
 | 
			
		||||
	[MinValue(1)]
 | 
			
		||||
	public int Country { get; set; }
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,9 @@
 | 
			
		||||
using Connected.Data;
 | 
			
		||||
 | 
			
		||||
namespace Connected.Common.Types.Continent.Countries;
 | 
			
		||||
 | 
			
		||||
public interface IContinentCountry : IPrimaryKey<int>
 | 
			
		||||
{
 | 
			
		||||
	int Continent { get; init; }
 | 
			
		||||
	int Country { get; init; }
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,34 @@
 | 
			
		||||
using System.Collections.Immutable;
 | 
			
		||||
using Connected.Annotations;
 | 
			
		||||
using Connected.Notifications;
 | 
			
		||||
using Connected.ServiceModel;
 | 
			
		||||
 | 
			
		||||
namespace Connected.Common.Types.Continent.Countries;
 | 
			
		||||
 | 
			
		||||
[Service]
 | 
			
		||||
[ServiceUrl(Routes.ContinentCountries)]
 | 
			
		||||
public interface IContinentCountryService : IServiceNotifications<int>
 | 
			
		||||
{
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Get)]
 | 
			
		||||
	Task<ImmutableList<IContinentCountry>?> Query();
 | 
			
		||||
	/// <summary>
 | 
			
		||||
	/// Queries countries for the specified continent id.
 | 
			
		||||
	/// </summary>
 | 
			
		||||
	/// <param name="args">The id fo the continent.</param>
 | 
			
		||||
	/// <returns>The list of countries.</returns>
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Get | ServiceMethodVerbs.Post)]
 | 
			
		||||
	Task<ImmutableList<IContinentCountry>?> QueryCountries(PrimaryKeyArgs<int> args);
 | 
			
		||||
	/// <summary>
 | 
			
		||||
	/// Select a <see cref="IContinentCountry"/> entity for the specified country id.
 | 
			
		||||
	/// </summary>
 | 
			
		||||
	/// <param name="args">The country id.</param>
 | 
			
		||||
	/// <returns>The <see cref="IContinentCountry"/> entity if exists, <code>null</code> otherwise.</returns>
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Get | ServiceMethodVerbs.Post)]
 | 
			
		||||
	Task<IContinentCountry> SelectCountry(PrimaryKeyArgs<int> args);
 | 
			
		||||
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Post | ServiceMethodVerbs.Put)]
 | 
			
		||||
	Task<int> Insert(InsertContinentCountryArgs args);
 | 
			
		||||
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Post | ServiceMethodVerbs.Delete)]
 | 
			
		||||
	Task Delete(PrimaryKeyArgs<int> args);
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										8
									
								
								src/Connected.Common.Types.Model/Continent/IContinent.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								src/Connected.Common.Types.Model/Continent/IContinent.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,8 @@
 | 
			
		||||
using Connected.Data;
 | 
			
		||||
 | 
			
		||||
namespace Connected.Common.Types.Continent;
 | 
			
		||||
 | 
			
		||||
public interface IContinent : IPrimaryKey<int>
 | 
			
		||||
{
 | 
			
		||||
	string Name { get; init; }
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,29 @@
 | 
			
		||||
using System.Collections.Immutable;
 | 
			
		||||
using Connected.Annotations;
 | 
			
		||||
using Connected.Notifications;
 | 
			
		||||
using Connected.ServiceModel;
 | 
			
		||||
 | 
			
		||||
namespace Connected.Common.Types.Continent;
 | 
			
		||||
 | 
			
		||||
[Service]
 | 
			
		||||
[ServiceUrl(Routes.Continents)]
 | 
			
		||||
public interface IContinentService : IServiceNotifications<int>
 | 
			
		||||
{
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Get)]
 | 
			
		||||
	Task<ImmutableList<IContinent>?> Query();
 | 
			
		||||
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Get | ServiceMethodVerbs.Post)]
 | 
			
		||||
	Task<ImmutableList<IContinent>> Query(PrimaryKeyListArgs<int> args);
 | 
			
		||||
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Get | ServiceMethodVerbs.Post)]
 | 
			
		||||
	Task<IContinent> Select(PrimaryKeyArgs<int> args);
 | 
			
		||||
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Put | ServiceMethodVerbs.Post)]
 | 
			
		||||
	Task<int> Insert(InsertContinentArgs args);
 | 
			
		||||
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Put | ServiceMethodVerbs.Post | ServiceMethodVerbs.Patch)]
 | 
			
		||||
	Task Update(UpdateContitentArgs args);
 | 
			
		||||
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Delete | ServiceMethodVerbs.Post)]
 | 
			
		||||
	Task Delete(PrimaryKeyArgs<int> args);
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										27
									
								
								src/Connected.Common.Types.Model/Countries/CountryArgs.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								src/Connected.Common.Types.Model/Countries/CountryArgs.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,27 @@
 | 
			
		||||
using System.ComponentModel.DataAnnotations;
 | 
			
		||||
using Connected.Annotations;
 | 
			
		||||
using Connected.Data;
 | 
			
		||||
using Connected.ServiceModel;
 | 
			
		||||
 | 
			
		||||
namespace Connected.Common.Types.Countries;
 | 
			
		||||
 | 
			
		||||
public class InsertCountryArgs : Dto
 | 
			
		||||
{
 | 
			
		||||
	[Required]
 | 
			
		||||
	[MaxLength(128)]
 | 
			
		||||
	public string Name { get; set; }
 | 
			
		||||
 | 
			
		||||
	[MinValue(0)]
 | 
			
		||||
	public int Lcid { get; set; }
 | 
			
		||||
 | 
			
		||||
	[MaxLength(128)]
 | 
			
		||||
	public string? IsoCode { get; set; }
 | 
			
		||||
 | 
			
		||||
	public Status Status { get; set; } = Status.Enabled;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
public class UpdateCountryArgs : InsertCountryArgs
 | 
			
		||||
{
 | 
			
		||||
	[MinValue(1)]
 | 
			
		||||
	public int Id { get; set; }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										11
									
								
								src/Connected.Common.Types.Model/Countries/ICountry.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								src/Connected.Common.Types.Model/Countries/ICountry.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,11 @@
 | 
			
		||||
using Connected.Data;
 | 
			
		||||
 | 
			
		||||
namespace Connected.Common.Types.Countries;
 | 
			
		||||
 | 
			
		||||
public interface ICountry : IPrimaryKey<int>
 | 
			
		||||
{
 | 
			
		||||
	string Name { get; init; }
 | 
			
		||||
	int Lcid { get; init; }
 | 
			
		||||
	string IsoCode { get; init; }
 | 
			
		||||
	Status Status { get; init; }
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,33 @@
 | 
			
		||||
using System.Collections.Immutable;
 | 
			
		||||
using Connected.Annotations;
 | 
			
		||||
using Connected.Notifications;
 | 
			
		||||
using Connected.ServiceModel;
 | 
			
		||||
 | 
			
		||||
namespace Connected.Common.Types.Countries;
 | 
			
		||||
 | 
			
		||||
[Service]
 | 
			
		||||
[ServiceUrl(Routes.Countries)]
 | 
			
		||||
 | 
			
		||||
public interface ICountryService : IServiceNotifications<int>
 | 
			
		||||
{
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Get)]
 | 
			
		||||
	Task<ImmutableList<ICountry>?> Query();
 | 
			
		||||
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Get | ServiceMethodVerbs.Post)]
 | 
			
		||||
	Task<ImmutableList<ICountry>?> Query(PrimaryKeyListArgs<int> args);
 | 
			
		||||
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Get | ServiceMethodVerbs.Post)]
 | 
			
		||||
	Task<ICountry?> Select(PrimaryKeyArgs<int> args);
 | 
			
		||||
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Get | ServiceMethodVerbs.Post)]
 | 
			
		||||
	Task<ICountry?> Select(NameArgs args);
 | 
			
		||||
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Delete | ServiceMethodVerbs.Post)]
 | 
			
		||||
	Task Delete(PrimaryKeyArgs<int> args);
 | 
			
		||||
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Put | ServiceMethodVerbs.Post)]
 | 
			
		||||
	Task<int> Insert(InsertCountryArgs args);
 | 
			
		||||
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Put | ServiceMethodVerbs.Post | ServiceMethodVerbs.Patch)]
 | 
			
		||||
	Task Update(UpdateCountryArgs args);
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										40
									
								
								src/Connected.Common.Types.Model/Currencies/CurrencyArgs.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								src/Connected.Common.Types.Model/Currencies/CurrencyArgs.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,40 @@
 | 
			
		||||
using System.ComponentModel.DataAnnotations;
 | 
			
		||||
using Connected.Annotations;
 | 
			
		||||
using Connected.Data;
 | 
			
		||||
using Connected.ServiceModel;
 | 
			
		||||
 | 
			
		||||
namespace Connected.Common.Types.Currencies;
 | 
			
		||||
 | 
			
		||||
public class CurrencyInsertArgs : Dto
 | 
			
		||||
{
 | 
			
		||||
	[Required]
 | 
			
		||||
	[MaxLength(128)]
 | 
			
		||||
	public string? Name { get; set; }
 | 
			
		||||
 | 
			
		||||
	[Required]
 | 
			
		||||
	[MaxLength(32)]
 | 
			
		||||
	public string? Code { get; set; }
 | 
			
		||||
 | 
			
		||||
	[Required]
 | 
			
		||||
	[MaxLength(8)]
 | 
			
		||||
	public string? Symbol { get; set; }
 | 
			
		||||
 | 
			
		||||
	[MinValue(0)]
 | 
			
		||||
	public int Lcid { get; set; }
 | 
			
		||||
 | 
			
		||||
	public Status Status { get; set; } = Status.Enabled;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
public sealed class CurrencyUpdateArgs : CurrencyInsertArgs
 | 
			
		||||
{
 | 
			
		||||
	[MinValue(1)]
 | 
			
		||||
	public int Id { get; set; }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
public sealed class CurrencyFormatArgs : Dto
 | 
			
		||||
{
 | 
			
		||||
	[Range(0, int.MaxValue)]
 | 
			
		||||
	public int Currency { get; set; }
 | 
			
		||||
 | 
			
		||||
	public double Value { get; set; }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										12
									
								
								src/Connected.Common.Types.Model/Currencies/ICurrency.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								src/Connected.Common.Types.Model/Currencies/ICurrency.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,12 @@
 | 
			
		||||
using Connected.Data;
 | 
			
		||||
 | 
			
		||||
namespace Connected.Common.Types.Currencies;
 | 
			
		||||
 | 
			
		||||
public interface ICurrency : IPrimaryKey<int>
 | 
			
		||||
{
 | 
			
		||||
	string Name { get; init; }
 | 
			
		||||
	string Code { get; init; }
 | 
			
		||||
	string Symbol { get; init; }
 | 
			
		||||
	int Lcid { get; init; }
 | 
			
		||||
	Status Status { get; init; }
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,32 @@
 | 
			
		||||
using System.Collections.Immutable;
 | 
			
		||||
using Connected.Annotations;
 | 
			
		||||
using Connected.Notifications;
 | 
			
		||||
using Connected.ServiceModel;
 | 
			
		||||
 | 
			
		||||
namespace Connected.Common.Types.Currencies;
 | 
			
		||||
 | 
			
		||||
[Service]
 | 
			
		||||
[ServiceUrl(Routes.Currencies)]
 | 
			
		||||
public interface ICurrencyService : IServiceNotifications<int>
 | 
			
		||||
{
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Get)]
 | 
			
		||||
	Task<ImmutableList<ICurrency>> Query();
 | 
			
		||||
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Get | ServiceMethodVerbs.Post)]
 | 
			
		||||
	Task<ImmutableList<ICurrency>> Query(PrimaryKeyListArgs<int> args);
 | 
			
		||||
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Get | ServiceMethodVerbs.Post)]
 | 
			
		||||
	Task<ICurrency> Select(PrimaryKeyArgs<int> args);
 | 
			
		||||
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Get | ServiceMethodVerbs.Post)]
 | 
			
		||||
	Task<string> Format(CurrencyFormatArgs args);
 | 
			
		||||
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Post | ServiceMethodVerbs.Put)]
 | 
			
		||||
	Task<int> Insert(CurrencyInsertArgs args);
 | 
			
		||||
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Post | ServiceMethodVerbs.Patch | ServiceMethodVerbs.Put)]
 | 
			
		||||
	Task Update(CurrencyUpdateArgs args);
 | 
			
		||||
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Post | ServiceMethodVerbs.Delete)]
 | 
			
		||||
	Task Delete(PrimaryKeyArgs<int> args);
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,11 @@
 | 
			
		||||
using Connected.Data;
 | 
			
		||||
 | 
			
		||||
namespace Connected.Common.Types.MeasureUnits;
 | 
			
		||||
 | 
			
		||||
public interface IMeasureUnit : IPrimaryKey<int>
 | 
			
		||||
{
 | 
			
		||||
	string Name { get; init; }
 | 
			
		||||
	string Code { get; init; }
 | 
			
		||||
	byte Precision { get; init; }
 | 
			
		||||
	Status Status { get; init; }
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,29 @@
 | 
			
		||||
using System.Collections.Immutable;
 | 
			
		||||
using Connected.Annotations;
 | 
			
		||||
using Connected.Notifications;
 | 
			
		||||
using Connected.ServiceModel;
 | 
			
		||||
 | 
			
		||||
namespace Connected.Common.Types.MeasureUnits;
 | 
			
		||||
 | 
			
		||||
[Service]
 | 
			
		||||
[ServiceUrl(Routes.MeasureUnits)]
 | 
			
		||||
public interface IMeasureUnitService : IServiceNotifications<int>
 | 
			
		||||
{
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Get)]
 | 
			
		||||
	Task<ImmutableList<IMeasureUnit>?> Query();
 | 
			
		||||
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Get | ServiceMethodVerbs.Post)]
 | 
			
		||||
	Task<ImmutableList<IMeasureUnit>?> Query(PrimaryKeyListArgs<int> args);
 | 
			
		||||
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Get | ServiceMethodVerbs.Post)]
 | 
			
		||||
	Task<IMeasureUnit?> Select(PrimaryKeyArgs<int> args);
 | 
			
		||||
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Post | ServiceMethodVerbs.Delete)]
 | 
			
		||||
	Task Delete(PrimaryKeyArgs<int> args);
 | 
			
		||||
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Post | ServiceMethodVerbs.Put)]
 | 
			
		||||
	Task<int> Insert(MeasureUnitInsertArgs args);
 | 
			
		||||
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Post | ServiceMethodVerbs.Put | ServiceMethodVerbs.Patch)]
 | 
			
		||||
	Task Update(MeasureUnitUpdateArgs args);
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,27 @@
 | 
			
		||||
using System.ComponentModel.DataAnnotations;
 | 
			
		||||
using Connected.Data;
 | 
			
		||||
using Connected.ServiceModel;
 | 
			
		||||
 | 
			
		||||
namespace Connected.Common.Types.MeasureUnits;
 | 
			
		||||
 | 
			
		||||
public class MeasureUnitInsertArgs : Dto
 | 
			
		||||
{
 | 
			
		||||
	[Required]
 | 
			
		||||
	[MaxLength(128)]
 | 
			
		||||
	public string? Name { get; set; }
 | 
			
		||||
 | 
			
		||||
	[Required]
 | 
			
		||||
	[MaxLength(8)]
 | 
			
		||||
	public string? Code { get; set; }
 | 
			
		||||
 | 
			
		||||
	[Range(0, 32)]
 | 
			
		||||
	public byte Precision { get; set; }
 | 
			
		||||
 | 
			
		||||
	public Status Status { get; set; } = Status.Enabled;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
public sealed class MeasureUnitUpdateArgs : MeasureUnitInsertArgs
 | 
			
		||||
{
 | 
			
		||||
	[Range(1, int.MaxValue)]
 | 
			
		||||
	public int Id { get; set; }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										7
									
								
								src/Connected.Common.Types.Model/MicroService.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								src/Connected.Common.Types.Model/MicroService.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,7 @@
 | 
			
		||||
using System.Runtime.CompilerServices;
 | 
			
		||||
 | 
			
		||||
using Connected.Annotations;
 | 
			
		||||
 | 
			
		||||
[assembly: MicroService(MicroServiceType.Contract)]
 | 
			
		||||
[assembly: InternalsVisibleTo("Common.Types.Tests")]
 | 
			
		||||
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]
 | 
			
		||||
							
								
								
									
										11
									
								
								src/Connected.Common.Types.Model/PostalCodes/IPostalCode.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								src/Connected.Common.Types.Model/PostalCodes/IPostalCode.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,11 @@
 | 
			
		||||
using Connected.Data;
 | 
			
		||||
 | 
			
		||||
namespace Connected.Common.Types.PostalCodes;
 | 
			
		||||
 | 
			
		||||
public interface IPostalCode : IPrimaryKey<int>
 | 
			
		||||
{
 | 
			
		||||
	int Country { get; init; }
 | 
			
		||||
	string Name { get; init; }
 | 
			
		||||
	string Code { get; init; }
 | 
			
		||||
	Status Status { get; init; }
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,35 @@
 | 
			
		||||
using System.Collections.Immutable;
 | 
			
		||||
using Connected.Annotations;
 | 
			
		||||
using Connected.Notifications;
 | 
			
		||||
using Connected.ServiceModel;
 | 
			
		||||
 | 
			
		||||
namespace Connected.Common.Types.PostalCodes;
 | 
			
		||||
 | 
			
		||||
[Service]
 | 
			
		||||
[ServiceUrl(Routes.PostalCodes)]
 | 
			
		||||
public interface IPostalCodeService : IServiceNotifications<int>
 | 
			
		||||
{
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Get)]
 | 
			
		||||
	Task<ImmutableList<IPostalCode>?> Query();
 | 
			
		||||
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Get | ServiceMethodVerbs.Post)]
 | 
			
		||||
	Task<ImmutableList<IPostalCode>?> Query(PrimaryKeyListArgs<int> args);
 | 
			
		||||
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Get | ServiceMethodVerbs.Post)]
 | 
			
		||||
	Task<ImmutableList<IPostalCode>?> Query(PrimaryKeyArgs<int> args);
 | 
			
		||||
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Get | ServiceMethodVerbs.Post)]
 | 
			
		||||
	Task<ImmutableList<IPostalCode>?> Search(PostalCodeSearchArgs args);
 | 
			
		||||
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Get | ServiceMethodVerbs.Post)]
 | 
			
		||||
	Task<IPostalCode> Select(PrimaryKeyArgs<int> args);
 | 
			
		||||
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Post | ServiceMethodVerbs.Delete)]
 | 
			
		||||
	Task Delete(PrimaryKeyArgs<int> args);
 | 
			
		||||
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Post | ServiceMethodVerbs.Put)]
 | 
			
		||||
	Task<int> Insert(PostalCodeInsertArgs args);
 | 
			
		||||
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Post | ServiceMethodVerbs.Put | ServiceMethodVerbs.Patch)]
 | 
			
		||||
	Task Update(PostalCodeInsertArgs args);
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,40 @@
 | 
			
		||||
using System.ComponentModel.DataAnnotations;
 | 
			
		||||
using Connected.Annotations;
 | 
			
		||||
using Connected.Data;
 | 
			
		||||
using Connected.ServiceModel;
 | 
			
		||||
 | 
			
		||||
namespace Connected.Common.Types.PostalCodes;
 | 
			
		||||
 | 
			
		||||
public class PostalCodeInsertArgs : Dto
 | 
			
		||||
{
 | 
			
		||||
	[MinValue(1)]
 | 
			
		||||
	public int Country { get; set; }
 | 
			
		||||
 | 
			
		||||
	[Required]
 | 
			
		||||
	[MaxLength(128)]
 | 
			
		||||
	public string? Name { get; set; }
 | 
			
		||||
 | 
			
		||||
	[Required]
 | 
			
		||||
	[MaxLength(16)]
 | 
			
		||||
	public string? Code { get; set; }
 | 
			
		||||
 | 
			
		||||
	public Status Status { get; set; } = Status.Enabled;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
public sealed class PostalCodeUpdateArgs : PostalCodeInsertArgs
 | 
			
		||||
{
 | 
			
		||||
	[Range(1, int.MaxValue)]
 | 
			
		||||
	public int Id { get; set; }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
public sealed class PostalCodeSearchArgs : Dto
 | 
			
		||||
{
 | 
			
		||||
	[Range(0, int.MaxValue)]
 | 
			
		||||
	public int Country { get; set; }
 | 
			
		||||
 | 
			
		||||
	[MaxLength(128)]
 | 
			
		||||
	public string? Name { get; set; }
 | 
			
		||||
 | 
			
		||||
	[MaxLength(16)]
 | 
			
		||||
	public string? Code { get; set; }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										18
									
								
								src/Connected.Common.Types.Model/Routes.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								src/Connected.Common.Types.Model/Routes.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,18 @@
 | 
			
		||||
using C = Connected.Common.CommonRoutes;
 | 
			
		||||
 | 
			
		||||
namespace Connected.Common.Types;
 | 
			
		||||
 | 
			
		||||
public static class Routes
 | 
			
		||||
{
 | 
			
		||||
	public const string CommonTypes = "commonTypes";
 | 
			
		||||
 | 
			
		||||
	public const string TaxRates = $"{C.Management}/{CommonTypes}/taxRates";
 | 
			
		||||
	public const string Countries = $"{C.Management}/{CommonTypes}/countries";
 | 
			
		||||
	public const string Continents = $"{C.Management}/{CommonTypes}/continents";
 | 
			
		||||
	public const string ContinentCountries = $"{C.Management}/{CommonTypes}/continents/countries";
 | 
			
		||||
	public const string Banks = $"{C.Management}/{CommonTypes}/banks";
 | 
			
		||||
	public const string BankAccounts = $"{C.Management}/{CommonTypes}/bankAccounts";
 | 
			
		||||
	public const string Currencies = $"{C.Management}/{CommonTypes}/currencies";
 | 
			
		||||
	public const string PostalCodes = $"{C.Management}/{CommonTypes}/postalCodes";
 | 
			
		||||
	public const string MeasureUnits = $"{C.Management}/{CommonTypes}/measureUnits";
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										36
									
								
								src/Connected.Common.Types.Model/TaxRates/ITaxRate.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								src/Connected.Common.Types.Model/TaxRates/ITaxRate.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,36 @@
 | 
			
		||||
using Connected.Data;
 | 
			
		||||
 | 
			
		||||
namespace Connected.Common.Types.TaxRates;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Represents an entity which contains information about tax rate. 
 | 
			
		||||
/// </summary>
 | 
			
		||||
/// <remarks>
 | 
			
		||||
/// Every Tax system has one or more tax rates, for example one tax rate is for
 | 
			
		||||
/// products and the other is for servies. This entity enables the environment
 | 
			
		||||
/// to manage different tax rates.
 | 
			
		||||
/// </remarks>
 | 
			
		||||
public interface ITaxRate : IPrimaryKey<int>
 | 
			
		||||
{
 | 
			
		||||
	/// <summary>
 | 
			
		||||
	/// The name of the tax rate.
 | 
			
		||||
	/// </summary>
 | 
			
		||||
	/// <remarks>
 | 
			
		||||
	/// Define this value as descriptive as possible so users can
 | 
			
		||||
	/// quickly recognize whyt kind of tax rate defines each record.
 | 
			
		||||
	/// </remarks>
 | 
			
		||||
	string? Name { get; init; }
 | 
			
		||||
	/// <summary>
 | 
			
		||||
	/// The rate or value of the tax rate. Should be a positive number.
 | 
			
		||||
	/// </summary>
 | 
			
		||||
	/// <remarks>
 | 
			
		||||
	/// Avoid updating this value. Create a new <see cref="ITaxRate"/> entity instead
 | 
			
		||||
	/// and disable the previous entity by setting its <see cref="Status"/> value to <see cref="Status.Disabled"/>.
 | 
			
		||||
	/// </remarks>
 | 
			
		||||
	float Rate { get; init; }
 | 
			
		||||
	/// <summary>
 | 
			
		||||
	/// The status of tax rate. Tax rates that are not used in the environment should be marked
 | 
			
		||||
	/// as <see cref="Status.Disabled"/> so users can use only valid records.
 | 
			
		||||
	/// </summary>
 | 
			
		||||
	Status Status { get; init; }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										63
									
								
								src/Connected.Common.Types.Model/TaxRates/ITaxRateService.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										63
									
								
								src/Connected.Common.Types.Model/TaxRates/ITaxRateService.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,63 @@
 | 
			
		||||
using System.Collections.Immutable;
 | 
			
		||||
using Connected.Annotations;
 | 
			
		||||
using Connected.Notifications;
 | 
			
		||||
using Connected.ServiceModel;
 | 
			
		||||
 | 
			
		||||
namespace Connected.Common.Types.TaxRates;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// The service used to manipulate with the <see cref="ITaxRate"/> entity.
 | 
			
		||||
/// </summary>
 | 
			
		||||
[Service]
 | 
			
		||||
[ServiceUrl(Routes.TaxRates)]
 | 
			
		||||
public interface ITaxRateService : IServiceNotifications<int>
 | 
			
		||||
{
 | 
			
		||||
	/// <summary>
 | 
			
		||||
	/// Queries all valid <see cref="ITaxRate"/> entities.
 | 
			
		||||
	/// </summary>
 | 
			
		||||
	/// <returns>An <see cref="ImmutableList{T}"/> representing all valid entities.</returns>
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Get | ServiceMethodVerbs.Post)]
 | 
			
		||||
	Task<ImmutableList<ITaxRate>?> Query(QueryArgs? args);
 | 
			
		||||
	/// <summary>
 | 
			
		||||
	/// Performs a lookup on <see cref="ITaxRate"/> entities for the specified list of ids.
 | 
			
		||||
	/// </summary>
 | 
			
		||||
	/// <param name="e">The List of the ids for which the perform a query.</param>
 | 
			
		||||
	/// <returns>An <see cref="ImmutableList{T}"/> of <see cref="ITaxRate"/> entities that matches
 | 
			
		||||
	/// the passed ids.</returns>
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Get | ServiceMethodVerbs.Post)]
 | 
			
		||||
	Task<ImmutableList<ITaxRate>?> Query(PrimaryKeyListArgs<int> e);
 | 
			
		||||
	/// <summary>
 | 
			
		||||
	/// Selects an <see cref="ITaxRate"/> entity for the specified id.
 | 
			
		||||
	/// </summary>
 | 
			
		||||
	/// <param name="e">The <see cref="IPrimaryKeyArgs{T}"/> which contains id.</param>
 | 
			
		||||
	/// <returns>First <see cref="ITaxRate"/> that matches the arguments. </returns>
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Get | ServiceMethodVerbs.Post)]
 | 
			
		||||
	Task<ITaxRate?> Select(PrimaryKeyArgs<int> e);
 | 
			
		||||
	/// <summary>
 | 
			
		||||
	/// Selects an <see cref="ITaxRate"/> for the specified <see cref="TaxRateArgs"/> arguments.
 | 
			
		||||
	/// </summary>
 | 
			
		||||
	/// <param name="e">The <see cref="TaxRateArgs"/> arguments for which the <see cref="ITaxRate"/> entity
 | 
			
		||||
	/// will be returned.</param>
 | 
			
		||||
	/// <returns>First <see cref="ITaxRate"/> that matches the arguments.</returns>
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Get | ServiceMethodVerbs.Post)]
 | 
			
		||||
	Task<ITaxRate?> Select(TaxRateArgs e);
 | 
			
		||||
	/// <summary>
 | 
			
		||||
	/// Inserts a new <see cref="ITaxRate"/> entity.
 | 
			
		||||
	/// </summary>
 | 
			
		||||
	/// <returns>
 | 
			
		||||
	/// An Id of the newly inserted entity.
 | 
			
		||||
	/// </returns>
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Post)]
 | 
			
		||||
	Task<int> Insert(InsertTaxRateArgs e);
 | 
			
		||||
	/// <summary>
 | 
			
		||||
	/// Updates <see cref="ITaxRate"/> entity.
 | 
			
		||||
	/// </summary>
 | 
			
		||||
	/// <param name="e">The <see cref="TaxRateArgs"/> containing values to be updated.</param>
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Post)]
 | 
			
		||||
	Task Update(UpdateTaxRateArgs e);
 | 
			
		||||
	/// <summary>
 | 
			
		||||
	/// Deletes <see cref="ITaxRate"/> entity.
 | 
			
		||||
	/// </summary>
 | 
			
		||||
	[ServiceMethod(ServiceMethodVerbs.Delete | ServiceMethodVerbs.Post)]
 | 
			
		||||
	Task Delete(PrimaryKeyArgs<int> e);
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										45
									
								
								src/Connected.Common.Types.Model/TaxRates/TaxRateArgs.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								src/Connected.Common.Types.Model/TaxRates/TaxRateArgs.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,45 @@
 | 
			
		||||
using System.ComponentModel.DataAnnotations;
 | 
			
		||||
using Connected.Annotations;
 | 
			
		||||
using Connected.ServiceModel;
 | 
			
		||||
 | 
			
		||||
namespace Connected.Common.Types.TaxRates;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// The arguments class for <see cref="ITaxRateService"/> methods.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public class TaxRateArgs : Dto
 | 
			
		||||
{
 | 
			
		||||
	/// <summary>
 | 
			
		||||
	/// The <see cref="ITaxRate"/> name.
 | 
			
		||||
	/// </summary>
 | 
			
		||||
	/// <remarks>
 | 
			
		||||
	/// This is a required property with its max length of 128 characters.
 | 
			
		||||
	/// </remarks>
 | 
			
		||||
	[Required]
 | 
			
		||||
	[MaxLength(128)]
 | 
			
		||||
	public string? Name { get; set; }
 | 
			
		||||
	/// <summary>
 | 
			
		||||
	/// The <see cref="ITaxRate"/> rate.
 | 
			
		||||
	/// </summary>
 | 
			
		||||
	/// <remarks>
 | 
			
		||||
	/// This is a required property with it min value of 0.
 | 
			
		||||
	/// </remarks>
 | 
			
		||||
	[MinValue(0)]
 | 
			
		||||
	public float Rate { get; set; }
 | 
			
		||||
}
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// The arguments used when inserting a new <see cref="ITaxRate"/> entity.
 | 
			
		||||
/// This is only a markup class serving primary for validation distinction.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public sealed class InsertTaxRateArgs : TaxRateArgs
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// The arguments class used when updating <see cref="ITaxRate"/> entity.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public class UpdateTaxRateArgs : TaxRateArgs
 | 
			
		||||
{
 | 
			
		||||
	[MinValue(0)]
 | 
			
		||||
	public int Id { get; set; }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										14
									
								
								src/Connected.Common.Types.Model/version.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								src/Connected.Common.Types.Model/version.json
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,14 @@
 | 
			
		||||
{
 | 
			
		||||
  "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/main/src/NerdBank.GitVersioning/version.schema.json",
 | 
			
		||||
  "version": "1.0-prerelease",
 | 
			
		||||
  "semVer1NumericIdentifierPadding": 4,
 | 
			
		||||
  "nugetPackageVersion": {
 | 
			
		||||
    "semVer": 2, // optional. Set to either 1 or 2 to control how the NuGet package version string is generated. Default is 1.
 | 
			
		||||
    "precision": "build" // optional. Use when you want to use a more or less precise package version than the default major.minor.build.
 | 
			
		||||
  },
 | 
			
		||||
  "cloudBuild": {
 | 
			
		||||
    "buildNumber": {
 | 
			
		||||
      "enabled": true
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										18
									
								
								src/Connected.Common.Types.UI/Bootstrapper.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								src/Connected.Common.Types.UI/Bootstrapper.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,18 @@
 | 
			
		||||
using Connected.Startup;
 | 
			
		||||
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
 | 
			
		||||
using Microsoft.Extensions.DependencyInjection;
 | 
			
		||||
 | 
			
		||||
namespace Connected.Common.Types;
 | 
			
		||||
 | 
			
		||||
public class Bootstrapper : IStartup
 | 
			
		||||
{
 | 
			
		||||
	public async Task Configure(WebAssemblyHost host)
 | 
			
		||||
	{
 | 
			
		||||
		await Task.CompletedTask;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public async Task ConfigureServices(IServiceCollection services)
 | 
			
		||||
	{
 | 
			
		||||
		await Task.CompletedTask;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,66 @@
 | 
			
		||||
<Project Sdk="Microsoft.NET.Sdk.Razor">
 | 
			
		||||
 | 
			
		||||
	<PropertyGroup>
 | 
			
		||||
		<TargetFramework>net7.0</TargetFramework>
 | 
			
		||||
		<Nullable>enable</Nullable>
 | 
			
		||||
		<ImplicitUsings>enable</ImplicitUsings>
 | 
			
		||||
		<RootNamespace>Connected.Common.Types</RootNamespace>
 | 
			
		||||
		<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
 | 
			
		||||
		<Title>$(AssemblyName)</Title>
 | 
			
		||||
		<Authors>Tom PIT ltd</Authors>
 | 
			
		||||
		<Copyright>2022 Tom PIT ltd</Copyright>
 | 
			
		||||
		<PackageProjectUrl>https://git.tompit.com/Connected/Info</PackageProjectUrl>
 | 
			
		||||
		<PackageReadmeFile>README.md</PackageReadmeFile>
 | 
			
		||||
		<PackageTags>connected;platform;</PackageTags>
 | 
			
		||||
		<IncludeSymbols>True</IncludeSymbols>
 | 
			
		||||
		<SymbolPackageFormat>snupkg</SymbolPackageFormat>
 | 
			
		||||
		<PackageLicenseFile>LICENSE</PackageLicenseFile>
 | 
			
		||||
		<PackageOutputPath>$(OutputPath)</PackageOutputPath>
 | 
			
		||||
	</PropertyGroup>
 | 
			
		||||
 | 
			
		||||
	<ItemGroup>
 | 
			
		||||
		<Compile Remove="wwwroot\**" />
 | 
			
		||||
		<Content Remove="wwwroot\**" />
 | 
			
		||||
		<EmbeddedResource Remove="wwwroot\**" />
 | 
			
		||||
		<None Remove="wwwroot\**" />
 | 
			
		||||
	</ItemGroup>
 | 
			
		||||
 | 
			
		||||
	<ItemGroup>
 | 
			
		||||
	  <Content Remove="version.json" />
 | 
			
		||||
	</ItemGroup>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	<ItemGroup>
 | 
			
		||||
		<SupportedPlatform Include="browser" />
 | 
			
		||||
	</ItemGroup>
 | 
			
		||||
 | 
			
		||||
	<ItemGroup>
 | 
			
		||||
		<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="7.0.*-*" />
 | 
			
		||||
		<PackageReference Include="Connected.Client" Version="1.0.*-*" />
 | 
			
		||||
		<PackageReference Include="Connected.UI" Version="1.0.*-*" />
 | 
			
		||||
		<PackageReference Include="Connected" Version="1.0.*-*" />
 | 
			
		||||
		<PackageReference Include="Connected.Common.Types.Client" Version="1.0.*-*" />
 | 
			
		||||
		<PackageReference Include="Nerdbank.GitVersioning" Version="3.5.119" PrivateAssets="all" Condition="!Exists('packages.config')" />
 | 
			
		||||
	</ItemGroup>
 | 
			
		||||
 | 
			
		||||
	<ItemGroup>
 | 
			
		||||
		<None Include="..\..\LICENSE">
 | 
			
		||||
			<Pack>True</Pack>
 | 
			
		||||
			<PackagePath>\</PackagePath>
 | 
			
		||||
		</None>
 | 
			
		||||
		<None Include="..\..\README.md">
 | 
			
		||||
			<Pack>True</Pack>
 | 
			
		||||
			<PackagePath>\</PackagePath>
 | 
			
		||||
		</None>
 | 
			
		||||
		<None Include="version.json" />
 | 
			
		||||
	</ItemGroup>
 | 
			
		||||
 | 
			
		||||
	<ItemGroup>
 | 
			
		||||
	  <ProjectReference Include="..\..\dependencies\Connected.Components\src\Connected.Components\Connected.Components.csproj" />
 | 
			
		||||
	</ItemGroup>
 | 
			
		||||
 | 
			
		||||
	<Target Name="CopyPackages" AfterTargets="Pack">
 | 
			
		||||
		<Copy SourceFiles="$(OutputPath)..\$(PackageId).$(PackageVersion).nupkg" DestinationFolder="$([System.Environment]::GetEnvironmentVariable('LOCAL_NUGET'))" />
 | 
			
		||||
		<Copy SourceFiles="$(OutputPath)..\$(PackageId).$(PackageVersion).snupkg" DestinationFolder="$([System.Environment]::GetEnvironmentVariable('LOCAL_NUGET'))" />
 | 
			
		||||
	</Target>
 | 
			
		||||
</Project>
 | 
			
		||||
							
								
								
									
										10
									
								
								src/Connected.Common.Types.UI/Routes.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								src/Connected.Common.Types.UI/Routes.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,10 @@
 | 
			
		||||
namespace Connected.Common.Types;
 | 
			
		||||
 | 
			
		||||
public static class CommonTypesUIRoutes
 | 
			
		||||
{
 | 
			
		||||
	public const string CommonTypes = $"/management/commonTypes";
 | 
			
		||||
 | 
			
		||||
	public const string TaxRates = $"{CommonTypes}/taxRates";
 | 
			
		||||
	public const string TaxRatesAdd = $"{CommonTypes}/taxRates/add";
 | 
			
		||||
	public const string TaxRatesEdit = $"{CommonTypes}/taxRates/edit/{{id:int}}";
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,21 @@
 | 
			
		||||
@using Connected.Components;
 | 
			
		||||
 | 
			
		||||
@inherits UIComposition
 | 
			
		||||
 | 
			
		||||
<h4>
 | 
			
		||||
	Insert new tax rate
 | 
			
		||||
</h4>
 | 
			
		||||
 | 
			
		||||
<div class="grid grid-col-2 gap-3">
 | 
			
		||||
	<div>
 | 
			
		||||
		<InputText @bind-Value="DataSource.Name" Label="Name" HelperText="The tax rate name" Required=true/>
 | 
			
		||||
	</div>
 | 
			
		||||
	
 | 
			
		||||
	<div>
 | 
			
		||||
		<InputNumber DisableMouseWheel=true @bind-Value="DataSource.Rate" Label="Rate" Required=true HelperText="The tax rate" />
 | 
			
		||||
	</div>	
 | 
			
		||||
</div>
 | 
			
		||||
<div class="py-3">
 | 
			
		||||
	<Button Size="Size.Small" @onclick="OnInsert" Class="mr-3">Submit</Button>
 | 
			
		||||
	<Button Size="Size.Small" @onclick="OnCancel">Cancel</Button>
 | 
			
		||||
</div>
 | 
			
		||||
@ -0,0 +1,39 @@
 | 
			
		||||
using Connected.Components;
 | 
			
		||||
using Microsoft.AspNetCore.Components;
 | 
			
		||||
 | 
			
		||||
namespace Connected.Common.Types.TaxRates.Components;
 | 
			
		||||
 | 
			
		||||
public partial class TaxRateAdd : UIComposition
 | 
			
		||||
{
 | 
			
		||||
	public TaxRateAdd()
 | 
			
		||||
	{
 | 
			
		||||
		DataSource = new InsertTaxRateArgs();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private InsertTaxRateArgs DataSource { get; }
 | 
			
		||||
 | 
			
		||||
	[Inject]
 | 
			
		||||
	private ITaxRateService? TaxRateService { get; set; }
 | 
			
		||||
 | 
			
		||||
	[Inject]
 | 
			
		||||
	private NavigationManager? Navigation { get; set; }
 | 
			
		||||
 | 
			
		||||
	protected override async Task OnParametersSetAsync()
 | 
			
		||||
	{
 | 
			
		||||
		if (TaxRateService is null)
 | 
			
		||||
			throw new ArgumentException(null, nameof(TaxRateService));
 | 
			
		||||
 | 
			
		||||
		await base.OnParametersSetAsync();
 | 
			
		||||
	}
 | 
			
		||||
	protected virtual async void OnInsert()
 | 
			
		||||
	{
 | 
			
		||||
		await TaxRateService.Insert(DataSource);
 | 
			
		||||
 | 
			
		||||
		Navigation.NavigateTo(Routes.TaxRates);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	protected virtual void OnCancel()
 | 
			
		||||
	{
 | 
			
		||||
		Navigation.NavigateTo(Routes.TaxRates);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,21 @@
 | 
			
		||||
@using Connected.Components;
 | 
			
		||||
 | 
			
		||||
@inherits UIComposition
 | 
			
		||||
 | 
			
		||||
<h4>
 | 
			
		||||
	Update tax rate
 | 
			
		||||
</h4>
 | 
			
		||||
 | 
			
		||||
<div class="grid grid-col-2 gap-3">
 | 
			
		||||
	<div>
 | 
			
		||||
		<InputText @bind-Value="DataSource.Name" Label="Name" HelperText="The tax rate name" Required=true/>
 | 
			
		||||
	</div>
 | 
			
		||||
 | 
			
		||||
	<div>
 | 
			
		||||
		<InputNumber DisableMouseWheel=true @bind-Value="DataSource.Rate" Label="Rate" Required=true HelperText="The tax rate" />
 | 
			
		||||
</div>	
 | 
			
		||||
</div>
 | 
			
		||||
<div class="py-3">
 | 
			
		||||
	<Button Size="Size.Small" @onclick="OnUpdate" Class="mr-3">Submit</Button>
 | 
			
		||||
	<Button Size="Size.Small" @onclick="OnCancel">Cancel</Button>
 | 
			
		||||
</div>
 | 
			
		||||
@ -0,0 +1,42 @@
 | 
			
		||||
using Connected.Components;
 | 
			
		||||
using Connected.ServiceModel;
 | 
			
		||||
using Microsoft.AspNetCore.Components;
 | 
			
		||||
 | 
			
		||||
namespace Connected.Common.Types.TaxRates.Components;
 | 
			
		||||
 | 
			
		||||
public partial class TaxRateEdit : UIComposition
 | 
			
		||||
{
 | 
			
		||||
	[Parameter]
 | 
			
		||||
	public int Id { get; set; }
 | 
			
		||||
	private UpdateTaxRateArgs? DataSource { get; set; }
 | 
			
		||||
 | 
			
		||||
	[Inject]
 | 
			
		||||
	private ITaxRateService? TaxRateService { get; set; }
 | 
			
		||||
 | 
			
		||||
	[Inject]
 | 
			
		||||
	private NavigationManager? Navigation { get; set; }
 | 
			
		||||
 | 
			
		||||
	protected override async Task OnParametersSetAsync()
 | 
			
		||||
	{
 | 
			
		||||
		var taxRate = await TaxRateService.Select(new PrimaryKeyArgs<int> { Id = Convert.ToInt32(Id) });
 | 
			
		||||
 | 
			
		||||
		DataSource = new UpdateTaxRateArgs
 | 
			
		||||
		{
 | 
			
		||||
			Id = taxRate.Id,
 | 
			
		||||
			Name = taxRate.Name,
 | 
			
		||||
			Rate = taxRate.Rate
 | 
			
		||||
		};
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private async void OnUpdate()
 | 
			
		||||
	{
 | 
			
		||||
		await TaxRateService.Update(DataSource);
 | 
			
		||||
 | 
			
		||||
		Navigation.NavigateTo(CommonTypesUIRoutes.TaxRates);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private void OnCancel()
 | 
			
		||||
	{
 | 
			
		||||
		Navigation.NavigateTo(CommonTypesUIRoutes.TaxRates);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,46 @@
 | 
			
		||||
@using Connected.Components;
 | 
			
		||||
 | 
			
		||||
@inherits UIComposition
 | 
			
		||||
 | 
			
		||||
@if (DataSource is null)
 | 
			
		||||
{
 | 
			
		||||
	<div>
 | 
			
		||||
		loading tax rates...
 | 
			
		||||
	</div>
 | 
			
		||||
	return;
 | 
			
		||||
}
 | 
			
		||||
<button @onclick="OnAdd">Add</button>
 | 
			
		||||
 | 
			
		||||
<div>
 | 
			
		||||
	<label>Last insert</label>
 | 
			
		||||
	<br />
 | 
			
		||||
	<label>@LastInsert</label>
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
<table>
 | 
			
		||||
	<tr>
 | 
			
		||||
		<th>Id</th>
 | 
			
		||||
		<th>Name</th>
 | 
			
		||||
		<th>Rate</th>
 | 
			
		||||
		<th>...</th>
 | 
			
		||||
	</tr>
 | 
			
		||||
	@foreach (var taxRate in DataSource)
 | 
			
		||||
	{
 | 
			
		||||
		<tr @key="taxRate.Id">
 | 
			
		||||
			<td>
 | 
			
		||||
				@taxRate.Id
 | 
			
		||||
			</td>
 | 
			
		||||
			<td>
 | 
			
		||||
				@taxRate.Name
 | 
			
		||||
			</td>
 | 
			
		||||
			<td>
 | 
			
		||||
				@taxRate.Rate
 | 
			
		||||
				<br>
 | 
			
		||||
				<Inline></Inline>
 | 
			
		||||
			</td>
 | 
			
		||||
			<td>
 | 
			
		||||
				<button @onclick="(()=>OnEdit(taxRate.Id))">Edit</button>
 | 
			
		||||
			</td>
 | 
			
		||||
		</tr>
 | 
			
		||||
	}
 | 
			
		||||
</table>
 | 
			
		||||
@ -0,0 +1,44 @@
 | 
			
		||||
using System.Collections.Immutable;
 | 
			
		||||
using Connected.Components;
 | 
			
		||||
using Connected.Notifications;
 | 
			
		||||
using Connected.ServiceModel;
 | 
			
		||||
using Microsoft.AspNetCore.Components;
 | 
			
		||||
 | 
			
		||||
namespace Connected.Common.Types.TaxRates.Components;
 | 
			
		||||
 | 
			
		||||
public partial class TaxRatesList : UIComposition
 | 
			
		||||
{
 | 
			
		||||
	private ImmutableList<ITaxRate>? DataSource { get; set; }
 | 
			
		||||
 | 
			
		||||
	[Inject]
 | 
			
		||||
	private ITaxRateService? TaxRateService { get; set; }
 | 
			
		||||
	[Inject]
 | 
			
		||||
	private NavigationManager? Navigation { get; set; }
 | 
			
		||||
 | 
			
		||||
	private string LastInsert { get; set; } = "waiting...";
 | 
			
		||||
 | 
			
		||||
	protected override async Task OnParametersSetAsync()
 | 
			
		||||
	{
 | 
			
		||||
		await base.OnParametersSetAsync();
 | 
			
		||||
 | 
			
		||||
		TaxRateService.Inserted += OnInserted;
 | 
			
		||||
 | 
			
		||||
		DataSource = await TaxRateService.Query(QueryArgs.Default);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private void OnInserted(object? sender, PrimaryKeyEventArgs<int> e)
 | 
			
		||||
	{
 | 
			
		||||
		LastInsert = $"{e.Id} -> {DateTime.UtcNow:F}";
 | 
			
		||||
		StateHasChanged();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private void OnEdit(int id)
 | 
			
		||||
	{
 | 
			
		||||
		Navigation.NavigateTo(CommonTypesUIRoutes.TaxRatesEdit.Replace("{id:int}", id.ToString()));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private void OnAdd()
 | 
			
		||||
	{
 | 
			
		||||
		Navigation.NavigateTo(CommonTypesUIRoutes.TaxRatesAdd);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,5 @@
 | 
			
		||||
@attribute [Route(CommonTypesUIRoutes.TaxRatesAdd)]
 | 
			
		||||
 | 
			
		||||
@using Connected.Common.Types.TaxRates.Components
 | 
			
		||||
 | 
			
		||||
<TaxRateAdd></TaxRateAdd>
 | 
			
		||||
@ -0,0 +1,12 @@
 | 
			
		||||
@using Connected.Common.Types.TaxRates.Components
 | 
			
		||||
 | 
			
		||||
@attribute [Route(CommonTypesUIRoutes.TaxRatesEdit)]
 | 
			
		||||
 | 
			
		||||
<h3>TaxRateEdit</h3>
 | 
			
		||||
 | 
			
		||||
<TaxRateEdit Id="@Id"></TaxRateEdit>
 | 
			
		||||
 | 
			
		||||
@code {
 | 
			
		||||
	[Parameter]
 | 
			
		||||
	public int Id { get; set; }
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,12 @@
 | 
			
		||||
@attribute [Route(CommonTypesUIRoutes.TaxRates)]
 | 
			
		||||
 | 
			
		||||
@using Connected.Common.Types.TaxRates.Components;
 | 
			
		||||
@using Connected.Components;
 | 
			
		||||
@using Connected.UI.Layouts;
 | 
			
		||||
 | 
			
		||||
@inherits UIComposition
 | 
			
		||||
@layout DefaultLayout
 | 
			
		||||
 | 
			
		||||
<h3>Tax rates</h3>
 | 
			
		||||
 | 
			
		||||
<DynamicComponent Type="ResolveComponent<TaxRatesList>()"></DynamicComponent>
 | 
			
		||||
							
								
								
									
										5
									
								
								src/Connected.Common.Types.UI/_Imports.razor
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								src/Connected.Common.Types.UI/_Imports.razor
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,5 @@
 | 
			
		||||
@using System.Net.Http
 | 
			
		||||
@using Microsoft.AspNetCore.Authorization
 | 
			
		||||
@using Microsoft.AspNetCore.Components.Routing
 | 
			
		||||
@using Microsoft.AspNetCore.Components.Web
 | 
			
		||||
@using Microsoft.JSInterop
 | 
			
		||||
							
								
								
									
										14
									
								
								src/Connected.Common.Types.UI/version.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								src/Connected.Common.Types.UI/version.json
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,14 @@
 | 
			
		||||
{
 | 
			
		||||
  "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/main/src/NerdBank.GitVersioning/version.schema.json",
 | 
			
		||||
  "version": "1.0-prerelease",
 | 
			
		||||
  "semVer1NumericIdentifierPadding": 4,
 | 
			
		||||
  "nugetPackageVersion": {
 | 
			
		||||
    "semVer": 2, // optional. Set to either 1 or 2 to control how the NuGet package version string is generated. Default is 1.
 | 
			
		||||
    "precision": "build" // optional. Use when you want to use a more or less precise package version than the default major.minor.build.
 | 
			
		||||
  },
 | 
			
		||||
  "cloudBuild": {
 | 
			
		||||
    "buildNumber": {
 | 
			
		||||
      "enabled": true
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										48
									
								
								src/Connected.Common.Types/Connected.Common.Types.csproj
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								src/Connected.Common.Types/Connected.Common.Types.csproj
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,48 @@
 | 
			
		||||
<Project Sdk="Microsoft.NET.Sdk">
 | 
			
		||||
 | 
			
		||||
	<PropertyGroup>
 | 
			
		||||
		<TargetFramework>net7.0</TargetFramework>
 | 
			
		||||
		<ImplicitUsings>enable</ImplicitUsings>
 | 
			
		||||
		<Nullable>enable</Nullable>
 | 
			
		||||
		<RootNamespace>$(MSBuildProjectName.Replace(" ", "_"))</RootNamespace>
 | 
			
		||||
		<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
 | 
			
		||||
		<Title>$(AssemblyName)</Title>
 | 
			
		||||
		<Authors>Tom PIT ltd</Authors>
 | 
			
		||||
		<Copyright>2022 Tom PIT ltd</Copyright>
 | 
			
		||||
		<PackageProjectUrl>https://git.tompit.com/Connected/Info</PackageProjectUrl>
 | 
			
		||||
		<PackageReadmeFile>README.md</PackageReadmeFile>
 | 
			
		||||
		<PackageTags>connected;platform;</PackageTags>
 | 
			
		||||
		<IncludeSymbols>True</IncludeSymbols>
 | 
			
		||||
		<SymbolPackageFormat>snupkg</SymbolPackageFormat>
 | 
			
		||||
		<PackageLicenseFile>LICENSE</PackageLicenseFile>
 | 
			
		||||
		<PackageOutputPath>$(OutputPath)</PackageOutputPath>
 | 
			
		||||
	</PropertyGroup>
 | 
			
		||||
 | 
			
		||||
	<ItemGroup>
 | 
			
		||||
		<PackageReference Include="Connected.Data" Version="1.0.*-*" />
 | 
			
		||||
		<PackageReference Include="Connected.Runtime" Version="1.0.*-*" />
 | 
			
		||||
		<PackageReference Include="Connected.Services" Version="1.0.*-*" />
 | 
			
		||||
		<PackageReference Include="Connected.Common.Types.Middleware" Version="1.0.*-*" />
 | 
			
		||||
		<PackageReference Include="Connected.Common.Types.Model" Version="1.0.*-*" />
 | 
			
		||||
		<PackageReference Include="Nerdbank.GitVersioning"
 | 
			
		||||
									Version="3.5.119"
 | 
			
		||||
									PrivateAssets="all"
 | 
			
		||||
									Condition="!Exists('packages.config')" />
 | 
			
		||||
	</ItemGroup>
 | 
			
		||||
 | 
			
		||||
	<ItemGroup>
 | 
			
		||||
		<None Include="..\..\LICENSE">
 | 
			
		||||
			<Pack>True</Pack>
 | 
			
		||||
			<PackagePath>\</PackagePath>
 | 
			
		||||
		</None>
 | 
			
		||||
		<None Include="..\..\README.md">
 | 
			
		||||
			<Pack>True</Pack>
 | 
			
		||||
			<PackagePath>\</PackagePath>
 | 
			
		||||
		</None>
 | 
			
		||||
	</ItemGroup>
 | 
			
		||||
 | 
			
		||||
	<Target Name="CopyPackages" AfterTargets="Pack">
 | 
			
		||||
		<Copy SourceFiles="$(OutputPath)..\$(PackageId).$(PackageVersion).nupkg" DestinationFolder="$([System.Environment]::GetEnvironmentVariable('LOCAL_NUGET'))" />
 | 
			
		||||
		<Copy SourceFiles="$(OutputPath)..\$(PackageId).$(PackageVersion).snupkg" DestinationFolder="$([System.Environment]::GetEnvironmentVariable('LOCAL_NUGET'))" />
 | 
			
		||||
	</Target>
 | 
			
		||||
</Project>
 | 
			
		||||
@ -0,0 +1,16 @@
 | 
			
		||||
using Connected.Annotations;
 | 
			
		||||
using Connected.Common.Types.Continent.Countries;
 | 
			
		||||
using Connected.Entities;
 | 
			
		||||
using Connected.Entities.Annotations;
 | 
			
		||||
 | 
			
		||||
namespace Connected.Common.Types.Continents.Countries;
 | 
			
		||||
 | 
			
		||||
[Table(Schema = SchemaAttribute.TypesSchema)]
 | 
			
		||||
internal record ContinentCountry : Entity<int>, IContinentCountry
 | 
			
		||||
{
 | 
			
		||||
	[Ordinal(0)]
 | 
			
		||||
	public int Continent { get; init; }
 | 
			
		||||
 | 
			
		||||
	[Ordinal(1)]
 | 
			
		||||
	public int Country { get; init; }
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,11 @@
 | 
			
		||||
using Connected.Entities.Caching;
 | 
			
		||||
 | 
			
		||||
namespace Connected.Common.Types.Continents.Countries;
 | 
			
		||||
 | 
			
		||||
internal interface IContinentCountryCache : IEntityCacheClient<ContinentCountry, int> { }
 | 
			
		||||
internal class ContinentCountryCache : EntityCacheClient<ContinentCountry, int>, IContinentCountryCache
 | 
			
		||||
{
 | 
			
		||||
	public ContinentCountryCache(IEntityCacheContext context) : base(context, "_")
 | 
			
		||||
	{
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,38 @@
 | 
			
		||||
using System.Collections.Immutable;
 | 
			
		||||
using Connected.Common.Types.Continent.Countries;
 | 
			
		||||
using Connected.ServiceModel;
 | 
			
		||||
using Connected.Services;
 | 
			
		||||
 | 
			
		||||
namespace Connected.Common.Types.Continents.Countries;
 | 
			
		||||
 | 
			
		||||
internal class ContinentCountryService : EntityService<int>, IContinentCountryService
 | 
			
		||||
{
 | 
			
		||||
	public ContinentCountryService(IContext context) : base(context)
 | 
			
		||||
	{
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public Task Delete(PrimaryKeyArgs<int> args)
 | 
			
		||||
	{
 | 
			
		||||
		throw new NotImplementedException();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public Task<int> Insert(InsertContinentCountryArgs args)
 | 
			
		||||
	{
 | 
			
		||||
		throw new NotImplementedException();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public Task<ImmutableList<IContinentCountry>?> Query()
 | 
			
		||||
	{
 | 
			
		||||
		throw new NotImplementedException();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public Task<ImmutableList<IContinentCountry>?> QueryCountries(PrimaryKeyArgs<int> args)
 | 
			
		||||
	{
 | 
			
		||||
		throw new NotImplementedException();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public Task<IContinentCountry> SelectCountry(PrimaryKeyArgs<int> args)
 | 
			
		||||
	{
 | 
			
		||||
		throw new NotImplementedException();
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,25 @@
 | 
			
		||||
using Connected.Common.Types.Continent;
 | 
			
		||||
using Connected.Common.Types.Countries;
 | 
			
		||||
using Connected.Data.DataProtection;
 | 
			
		||||
using Connected.Data.EntityProtection;
 | 
			
		||||
using Connected.Entities;
 | 
			
		||||
using Connected.Middleware;
 | 
			
		||||
using Connected.Validation;
 | 
			
		||||
 | 
			
		||||
namespace Connected.Common.Types.Continents.Countries;
 | 
			
		||||
 | 
			
		||||
internal class ContinentProtector : MiddlewareComponent, IEntityProtector<IContinent>
 | 
			
		||||
{
 | 
			
		||||
	public ContinentProtector(IContinentCountryCache cache)
 | 
			
		||||
	{
 | 
			
		||||
		Cache = cache;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private IContinentCountryCache Cache { get; }
 | 
			
		||||
 | 
			
		||||
	public async Task Invoke(EntityProtectionArgs<IContinent> args)
 | 
			
		||||
	{
 | 
			
		||||
		if ((await (from dc in Cache where dc.Continent == args.Entity.Id select dc).AsEntity()) is not null)
 | 
			
		||||
			throw ValidationExceptions.ReferenceExists(typeof(ICountry), args.Entity.Id);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										22
									
								
								src/Connected.Common.Types/Countries/Country.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								src/Connected.Common.Types/Countries/Country.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,22 @@
 | 
			
		||||
using Connected.Data;
 | 
			
		||||
using Connected.Entities.Annotations;
 | 
			
		||||
using Connected.Entities.Consistency;
 | 
			
		||||
 | 
			
		||||
namespace Connected.Common.Types.Countries;
 | 
			
		||||
 | 
			
		||||
[Table(Schema = SchemaAttribute.TypesSchema)]
 | 
			
		||||
internal record Country : ConsistentEntity<int>, ICountry
 | 
			
		||||
{
 | 
			
		||||
	public const string CacheKey = $"{SchemaAttribute.TypesSchema}.{nameof(Country)}";
 | 
			
		||||
 | 
			
		||||
	[Length(128)]
 | 
			
		||||
	public string Name { get; init; }
 | 
			
		||||
 | 
			
		||||
	public int Lcid { get; init; }
 | 
			
		||||
 | 
			
		||||
	[Length(128)]
 | 
			
		||||
	public string IsoCode { get; init; }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	public Status Status { get; init; } = Status.Enabled;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										14
									
								
								src/Connected.Common.Types/Countries/CountryCache.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								src/Connected.Common.Types/Countries/CountryCache.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,14 @@
 | 
			
		||||
using Connected.Entities.Caching;
 | 
			
		||||
 | 
			
		||||
namespace Connected.Common.Types.Countries;
 | 
			
		||||
 | 
			
		||||
internal interface ICountryCache : IEntityCacheClient<Country, int> { }
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Cache for the <see cref="ICountry"/> entity.
 | 
			
		||||
/// </summary>
 | 
			
		||||
internal sealed class CountryCache : EntityCacheClient<Country, int>, ICountryCache
 | 
			
		||||
{
 | 
			
		||||
	public CountryCache(IEntityCacheContext context) : base(context, Country.CacheKey)
 | 
			
		||||
	{
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										155
									
								
								src/Connected.Common.Types/Countries/CountryOps.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										155
									
								
								src/Connected.Common.Types/Countries/CountryOps.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,155 @@
 | 
			
		||||
using System.Collections.Immutable;
 | 
			
		||||
using Connected.Entities;
 | 
			
		||||
using Connected.Entities.Storage;
 | 
			
		||||
using Connected.Notifications.Events;
 | 
			
		||||
using Connected.ServiceModel;
 | 
			
		||||
using Connected.Services;
 | 
			
		||||
 | 
			
		||||
namespace Connected.Common.Types.Countries;
 | 
			
		||||
 | 
			
		||||
internal sealed class QueryCountries : ServiceFunction<IDto, ImmutableList<ICountry>?>
 | 
			
		||||
{
 | 
			
		||||
	public QueryCountries(ICountryCache cache)
 | 
			
		||||
	{
 | 
			
		||||
		Cache = cache;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private ICountryCache Cache { get; }
 | 
			
		||||
	protected override async Task<ImmutableList<ICountry>?> OnInvoke()
 | 
			
		||||
	{
 | 
			
		||||
		return await (from dc in Cache select dc).AsEntities<ICountry>();
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
internal sealed class SelectCountry : ServiceFunction<PrimaryKeyArgs<int>, ICountry?>
 | 
			
		||||
{
 | 
			
		||||
	public SelectCountry(ICountryCache cache)
 | 
			
		||||
	{
 | 
			
		||||
		Cache = cache;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private ICountryCache Cache { get; }
 | 
			
		||||
	protected override async Task<ICountry?> OnInvoke()
 | 
			
		||||
	{
 | 
			
		||||
		return await (from dc in Cache where dc.Id == Arguments.Id select dc).AsEntity();
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
internal sealed class SelectCountryByName : ServiceFunction<NameArgs, ICountry?>
 | 
			
		||||
{
 | 
			
		||||
	public SelectCountryByName(ICountryCache cache)
 | 
			
		||||
	{
 | 
			
		||||
		Cache = cache;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private ICountryCache Cache { get; }
 | 
			
		||||
	protected override async Task<ICountry?> OnInvoke()
 | 
			
		||||
	{
 | 
			
		||||
		return await (from dc in Cache where string.Equals(dc.Name, Arguments.Name, StringComparison.OrdinalIgnoreCase) select dc).AsEntity();
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
internal sealed class LookupCountries : ServiceFunction<PrimaryKeyListArgs<int>, ImmutableList<ICountry>?>
 | 
			
		||||
{
 | 
			
		||||
	public LookupCountries(ICountryCache cache)
 | 
			
		||||
	{
 | 
			
		||||
		Cache = cache;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private ICountryCache Cache { get; }
 | 
			
		||||
	protected override async Task<ImmutableList<ICountry>?> OnInvoke()
 | 
			
		||||
	{
 | 
			
		||||
		if (Arguments.IdList is null)
 | 
			
		||||
			return null;
 | 
			
		||||
 | 
			
		||||
		return await (from dc in Cache where Arguments.IdList.Contains(dc.Id) select dc).AsEntities<ICountry>();
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
internal sealed class DeleteCountry : ServiceAction<PrimaryKeyArgs<int>>
 | 
			
		||||
{
 | 
			
		||||
	public DeleteCountry(ICountryService countryService, IStorageProvider storage, ICountryCache cache, IEventService events)
 | 
			
		||||
	{
 | 
			
		||||
		CountryService = countryService;
 | 
			
		||||
		Storage = storage;
 | 
			
		||||
		Cache = cache;
 | 
			
		||||
		Events = events;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private ICountryService CountryService { get; }
 | 
			
		||||
	private IStorageProvider Storage { get; }
 | 
			
		||||
	private ICountryCache Cache { get; }
 | 
			
		||||
	private IEventService Events { get; }
 | 
			
		||||
 | 
			
		||||
	protected override async Task OnInvoke()
 | 
			
		||||
	{
 | 
			
		||||
		await Storage.Open<Country>().Update(new Country { Id = Arguments.Id, State = State.Deleted });
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	protected override async Task OnCommitted()
 | 
			
		||||
	{
 | 
			
		||||
		await Cache.Remove(Arguments.Id);
 | 
			
		||||
		await Events.Enqueue(this, CountryService, ServiceEvents.Deleted, Arguments.Id);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
internal sealed class InsertCountry : ServiceFunction<InsertCountryArgs, int>
 | 
			
		||||
{
 | 
			
		||||
	public InsertCountry(ICountryService countryService, IStorageProvider database, IEventService events, ICountryCache cache)
 | 
			
		||||
	{
 | 
			
		||||
		CountryService = countryService;
 | 
			
		||||
		Database = database;
 | 
			
		||||
		Events = events;
 | 
			
		||||
		Cache = cache;
 | 
			
		||||
	}
 | 
			
		||||
	private ICountryService CountryService { get; }
 | 
			
		||||
	private IStorageProvider Database { get; }
 | 
			
		||||
	private IEventService Events { get; }
 | 
			
		||||
	private ICountryCache Cache { get; }
 | 
			
		||||
 | 
			
		||||
	protected override async Task<int> OnInvoke()
 | 
			
		||||
	{
 | 
			
		||||
		var entity = Arguments.AsEntity<Country>(State.New);
 | 
			
		||||
		var result = await Database.Open<Country>().Update(entity);
 | 
			
		||||
 | 
			
		||||
		return result is null ? 0 : result.Id;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	protected override async Task OnCommitted()
 | 
			
		||||
	{
 | 
			
		||||
		await Cache.Refresh(Result);
 | 
			
		||||
		await Events.Enqueue(this, CountryService, ServiceEvents.Inserted, Result);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
internal sealed class UpdateCountry : ServiceAction<UpdateCountryArgs>
 | 
			
		||||
{
 | 
			
		||||
	public UpdateCountry(ICountryService countryService, IStorageProvider database, ICountryCache cache, IEventService events)
 | 
			
		||||
	{
 | 
			
		||||
		CountryService = countryService;
 | 
			
		||||
		Database = database;
 | 
			
		||||
		Cache = cache;
 | 
			
		||||
		Events = events;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private IStorageProvider Database { get; }
 | 
			
		||||
	private ICountryCache Cache { get; }
 | 
			
		||||
	private IEventService Events { get; }
 | 
			
		||||
	private ICountryService CountryService { get; }
 | 
			
		||||
 | 
			
		||||
	protected override async Task OnInvoke()
 | 
			
		||||
	{
 | 
			
		||||
		await Database.Open<Country>().Update(await Load(), Arguments, async () =>
 | 
			
		||||
		{
 | 
			
		||||
			await Cache.Refresh(Arguments.Id);
 | 
			
		||||
 | 
			
		||||
			return await Load();
 | 
			
		||||
		});
 | 
			
		||||
	}
 | 
			
		||||
	private async Task<Country?> Load() => await (from dc in Cache where dc.Id == Arguments.Id select dc).AsEntity();
 | 
			
		||||
 | 
			
		||||
	protected override async Task OnCommitted()
 | 
			
		||||
	{
 | 
			
		||||
		await Cache.Refresh(Arguments.Id);
 | 
			
		||||
		await Events.Enqueue(this, CountryService, ServiceEvents.Updated, Arguments.Id);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										56
									
								
								src/Connected.Common.Types/Countries/CountryService.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										56
									
								
								src/Connected.Common.Types/Countries/CountryService.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,56 @@
 | 
			
		||||
using System.Collections.Immutable;
 | 
			
		||||
using Connected.Common.Types.Security;
 | 
			
		||||
using Connected.ServiceModel;
 | 
			
		||||
using Connected.Services;
 | 
			
		||||
using Connected.Services.Annotations;
 | 
			
		||||
 | 
			
		||||
namespace Connected.Common.Types.Countries;
 | 
			
		||||
 | 
			
		||||
internal sealed class CountryService : EntityService<int>, ICountryService
 | 
			
		||||
{
 | 
			
		||||
	public CountryService(IContext context) : base(context)
 | 
			
		||||
	{
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	[ServiceAuthorization(Claims.Delete)]
 | 
			
		||||
	public async Task Delete(PrimaryKeyArgs<int> args)
 | 
			
		||||
	{
 | 
			
		||||
		await Invoke(GetOperation<DeleteCountry>(), args);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	[ServiceAuthorization(Claims.Add)]
 | 
			
		||||
	public async Task<int> Insert(InsertCountryArgs args)
 | 
			
		||||
	{
 | 
			
		||||
		return await Invoke(GetOperation<InsertCountry>(), args);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	[ServiceAuthorization(Claims.Read)]
 | 
			
		||||
	public async Task<ImmutableList<ICountry>?> Query()
 | 
			
		||||
	{
 | 
			
		||||
		return await Invoke(GetOperation<QueryCountries>(), Dto.Empty);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	[ServiceAuthorization(Claims.Read)]
 | 
			
		||||
	public async Task<ImmutableList<ICountry>?> Query(PrimaryKeyListArgs<int> args)
 | 
			
		||||
	{
 | 
			
		||||
		return await Invoke(GetOperation<LookupCountries>(), args);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	[ServiceAuthorization(Claims.Read)]
 | 
			
		||||
	public async Task<ICountry?> Select(PrimaryKeyArgs<int> args)
 | 
			
		||||
	{
 | 
			
		||||
		return await Invoke(GetOperation<SelectCountry>(), args);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	[ServiceAuthorization(Claims.Read)]
 | 
			
		||||
	public async Task<ICountry?> Select(NameArgs args)
 | 
			
		||||
	{
 | 
			
		||||
		return await Invoke(GetOperation<SelectCountryByName>(), args);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	[ServiceAuthorization(Claims.Modify)]
 | 
			
		||||
	public async Task Update(UpdateCountryArgs args)
 | 
			
		||||
	{
 | 
			
		||||
		await Invoke(GetOperation<UpdateCountry>(), args);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										53
									
								
								src/Connected.Common.Types/Countries/CountryValidator.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								src/Connected.Common.Types/Countries/CountryValidator.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,53 @@
 | 
			
		||||
using Connected.Middleware;
 | 
			
		||||
using Connected.Validation;
 | 
			
		||||
 | 
			
		||||
namespace Connected.Common.Types.Countries;
 | 
			
		||||
 | 
			
		||||
internal class CountryValidator : MiddlewareComponent, IValidator<InsertCountryArgs>
 | 
			
		||||
{
 | 
			
		||||
	public CountryValidator(ICountryService countryService)
 | 
			
		||||
	{
 | 
			
		||||
		CountryService = countryService;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private ICountryService CountryService { get; }
 | 
			
		||||
	/// <summary>
 | 
			
		||||
	/// 
 | 
			
		||||
	/// </summary>
 | 
			
		||||
	/// <param name="args"></param>
 | 
			
		||||
	/// <returns></returns>
 | 
			
		||||
	public async Task Validate(InsertCountryArgs args)
 | 
			
		||||
	{
 | 
			
		||||
		/*
 | 
			
		||||
		 * Country has the following constraints:
 | 
			
		||||
		 * - name is unique
 | 
			
		||||
		 * - lcid is unique
 | 
			
		||||
		 * - iso2Alpha code is unique
 | 
			
		||||
		 */
 | 
			
		||||
 | 
			
		||||
		/*
 | 
			
		||||
		 * This method handles insert and update country methods.
 | 
			
		||||
		 * The algorithm is different for each method.
 | 
			
		||||
		 * First check if it's an update
 | 
			
		||||
		 */
 | 
			
		||||
		var update = args as UpdateCountryArgs;
 | 
			
		||||
 | 
			
		||||
		foreach (var country in await CountryService.Query())
 | 
			
		||||
		{
 | 
			
		||||
			/*
 | 
			
		||||
			 * Ignore self record.
 | 
			
		||||
			 */
 | 
			
		||||
			if (update is not null && country.Id == update.Id)
 | 
			
		||||
				continue;
 | 
			
		||||
 | 
			
		||||
			if (string.Equals(country.Name, args.Name, StringComparison.OrdinalIgnoreCase))
 | 
			
		||||
				throw ValidationExceptions.ValueExists(nameof(country.Name), args.Name);
 | 
			
		||||
 | 
			
		||||
			if (country.Lcid > 0 && country.Lcid == args.Lcid)
 | 
			
		||||
				throw ValidationExceptions.ValueExists(nameof(country.Lcid), args.Lcid);
 | 
			
		||||
 | 
			
		||||
			if (!string.IsNullOrEmpty(country.IsoCode) && string.Equals(country.IsoCode, args.IsoCode, StringComparison.OrdinalIgnoreCase))
 | 
			
		||||
				throw ValidationExceptions.ValueExists(nameof(country.IsoCode), args.IsoCode);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,25 @@
 | 
			
		||||
using System.Globalization;
 | 
			
		||||
using Connected.Common.Types.Middleware.Currencies;
 | 
			
		||||
using Connected.Interop;
 | 
			
		||||
using Connected.Middleware;
 | 
			
		||||
 | 
			
		||||
namespace Connected.Common.Types.Currencies;
 | 
			
		||||
 | 
			
		||||
internal class DefaultCurrencyFormatterMiddleware<TValue> : MiddlewareComponent, ICurrencyFormatterMiddleware<TValue>
 | 
			
		||||
{
 | 
			
		||||
	public Task<string?> Format(TValue value, ICurrency currency, string format)
 | 
			
		||||
	{
 | 
			
		||||
		if (value is null)
 | 
			
		||||
			return Task.FromResult<string?>(null);
 | 
			
		||||
 | 
			
		||||
		if (string.IsNullOrWhiteSpace(format))
 | 
			
		||||
			format = "N2";
 | 
			
		||||
 | 
			
		||||
		var culture = currency.Lcid == 0 ? CultureInfo.CurrentUICulture : CultureInfo.GetCultureInfo(currency.Lcid);
 | 
			
		||||
 | 
			
		||||
		if (!TypeConversion.TryConvert(value, out double converted, culture))
 | 
			
		||||
			return Task.FromResult(value.ToString());
 | 
			
		||||
 | 
			
		||||
		return Task.FromResult<string?>(converted.ToString(format, culture));
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										9
									
								
								src/Connected.Common.Types/Security/Claims.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								src/Connected.Common.Types/Security/Claims.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,9 @@
 | 
			
		||||
namespace Connected.Common.Types.Security;
 | 
			
		||||
 | 
			
		||||
internal static class Claims
 | 
			
		||||
{
 | 
			
		||||
	public const string Delete = "Common Delete";
 | 
			
		||||
	public const string Read = "Common Read";
 | 
			
		||||
	public const string Add = "Common Add";
 | 
			
		||||
	public const string Modify = "Common Modify";
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										12
									
								
								src/Connected.Common.Types/ServerStartup.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								src/Connected.Common.Types/ServerStartup.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,12 @@
 | 
			
		||||
using System.Runtime.CompilerServices;
 | 
			
		||||
using Connected.Annotations;
 | 
			
		||||
 | 
			
		||||
[assembly: MicroService(MicroServiceType.Service)]
 | 
			
		||||
[assembly: InternalsVisibleTo("Connected.Common.Types.Tests")]
 | 
			
		||||
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]
 | 
			
		||||
 | 
			
		||||
namespace Connected.Common.Types;
 | 
			
		||||
 | 
			
		||||
internal class ServerStartup : Startup
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										33
									
								
								src/Connected.Common.Types/TaxRates/TaxRate.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								src/Connected.Common.Types/TaxRates/TaxRate.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,33 @@
 | 
			
		||||
using Connected.Data;
 | 
			
		||||
using Connected.Entities.Annotations;
 | 
			
		||||
using Connected.Entities.Concurrency;
 | 
			
		||||
 | 
			
		||||
namespace Connected.Common.Types.TaxRates;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// The <see cref="ITaxRate"/> entity.
 | 
			
		||||
/// </summary>
 | 
			
		||||
[Table(Schema = SchemaAttribute.TypesSchema)]
 | 
			
		||||
internal sealed record TaxRate : ConcurrentEntity<int>, ITaxRate
 | 
			
		||||
{
 | 
			
		||||
	/// <summary>
 | 
			
		||||
	/// The cache key under which all TaxRate entities are stored.
 | 
			
		||||
	/// </summary>
 | 
			
		||||
	public const string CacheKey = $"{SchemaAttribute.TypesSchema}.{nameof(TaxRate)}";
 | 
			
		||||
	/// <summary>
 | 
			
		||||
	/// The name of the <see cref="ITaxRate"/>. 
 | 
			
		||||
	/// </summary>
 | 
			
		||||
	[Length(128)]
 | 
			
		||||
	public string? Name { get; init; }
 | 
			
		||||
	/// <summary>
 | 
			
		||||
	/// The rate of the <see cref="ITaxRate"/>.
 | 
			
		||||
	/// </summary>
 | 
			
		||||
	public float Rate { get; init; }
 | 
			
		||||
	/// <summary>
 | 
			
		||||
	/// The <see cref="ITaxRate"/> status. Only <see cref="Status.Enabled"/> entities
 | 
			
		||||
	/// should be used on front ends.
 | 
			
		||||
	/// </summary>
 | 
			
		||||
	[Default(Status.Enabled)]
 | 
			
		||||
	public Status Status { get; init; }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										26
									
								
								src/Connected.Common.Types/TaxRates/TaxRateCache.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								src/Connected.Common.Types/TaxRates/TaxRateCache.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,26 @@
 | 
			
		||||
using Connected.Entities.Caching;
 | 
			
		||||
 | 
			
		||||
namespace Connected.Common.Types.TaxRates;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// This is the contract for the typed cache. Using contracts for
 | 
			
		||||
/// caching is useful when writing unit tests so a developer
 | 
			
		||||
/// can mock the entire cache.
 | 
			
		||||
/// </summary>
 | 
			
		||||
internal interface ITaxRateCache : IEntityCacheClient<TaxRate, int> { }
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Cache for the <see cref="ITaxRate"/> entity.
 | 
			
		||||
/// </summary>
 | 
			
		||||
/// <remarks>
 | 
			
		||||
/// <see cref="EntityCacheClient{TEntity, TPrimaryKey}"/> stores the entire set
 | 
			
		||||
/// of records in the database. This is useful for data which doesn't change
 | 
			
		||||
/// frequently because invalidating it ofter can have performance penalties.
 | 
			
		||||
/// The platform knows how to load and invalidate the entity so developer
 | 
			
		||||
/// doesn't nedd to write any code at all.
 | 
			
		||||
/// </remarks>
 | 
			
		||||
internal sealed class TaxRateCache : EntityCacheClient<TaxRate, int>, ITaxRateCache
 | 
			
		||||
{
 | 
			
		||||
	public TaxRateCache(IEntityCacheContext context) : base(context, TaxRate.CacheKey)
 | 
			
		||||
	{
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										252
									
								
								src/Connected.Common.Types/TaxRates/TaxRateOps.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										252
									
								
								src/Connected.Common.Types/TaxRates/TaxRateOps.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,252 @@
 | 
			
		||||
using System.Collections.Immutable;
 | 
			
		||||
using Connected.Entities;
 | 
			
		||||
using Connected.Entities.Storage;
 | 
			
		||||
using Connected.Notifications.Events;
 | 
			
		||||
using Connected.ServiceModel;
 | 
			
		||||
using Connected.Services;
 | 
			
		||||
 | 
			
		||||
namespace Connected.Common.Types.TaxRates;
 | 
			
		||||
 | 
			
		||||
internal class TaxRateOps
 | 
			
		||||
{
 | 
			
		||||
	/// <summary>
 | 
			
		||||
	/// Queries all <see cref="ITaxRate"/> records.
 | 
			
		||||
	/// </summary>
 | 
			
		||||
	internal sealed class Query : ServiceFunction<QueryArgs, ImmutableList<ITaxRate>?>
 | 
			
		||||
	{
 | 
			
		||||
		/// <summary>
 | 
			
		||||
		/// Creates a new instance of the <see cref="Query"/> class.
 | 
			
		||||
		/// </summary>
 | 
			
		||||
		/// <param name="cache">The cache where the records are stored.</param>
 | 
			
		||||
		public Query(ITaxRateCache cache, IStorageProvider storage)
 | 
			
		||||
		{
 | 
			
		||||
			Cache = cache;
 | 
			
		||||
			Storage = storage;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		private ITaxRateCache Cache { get; }
 | 
			
		||||
		public IStorageProvider Storage { get; }
 | 
			
		||||
 | 
			
		||||
		protected override async Task<ImmutableList<ITaxRate>?> OnInvoke()
 | 
			
		||||
		{
 | 
			
		||||
			var r = await (from dc in Storage.Open<TaxRate>() select dc).WithArguments(Arguments).AsEntities<ITaxRate>();
 | 
			
		||||
			/*
 | 
			
		||||
			 * We simply return all records that exist in the system.
 | 
			
		||||
			 */
 | 
			
		||||
			return await (from dc in Cache select dc).WithArguments(Arguments).AsEntities<ITaxRate>();
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/// <summary>
 | 
			
		||||
	/// Returns <see cref="ITaxRate"/> with the specified id or null
 | 
			
		||||
	/// if the record for the specified id does not exist.
 | 
			
		||||
	/// </summary>
 | 
			
		||||
	internal sealed class Select : ServiceFunction<PrimaryKeyArgs<int>, ITaxRate?>
 | 
			
		||||
	{
 | 
			
		||||
		public Select(ITaxRateCache cache)
 | 
			
		||||
		{
 | 
			
		||||
			Cache = cache;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		private ITaxRateCache Cache { get; }
 | 
			
		||||
 | 
			
		||||
		protected override async Task<ITaxRate?> OnInvoke()
 | 
			
		||||
		{
 | 
			
		||||
			/*
 | 
			
		||||
			 * Filter cache by the id.
 | 
			
		||||
			 */
 | 
			
		||||
 | 
			
		||||
			return await (from dc in Cache where dc.Id == Arguments.Id select dc).AsEntity();
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	/// <summary>
 | 
			
		||||
	/// Returns <see cref="ITaxRate"/> with the specified name and rate or null if
 | 
			
		||||
	/// the record with the specified arguments does not exist.
 | 
			
		||||
	/// </summary>
 | 
			
		||||
	internal sealed class SelectByRate : ServiceFunction<TaxRateArgs, ITaxRate?>
 | 
			
		||||
	{
 | 
			
		||||
		public SelectByRate(ITaxRateCache cache)
 | 
			
		||||
		{
 | 
			
		||||
			Cache = cache;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		private ITaxRateCache Cache { get; }
 | 
			
		||||
		protected override async Task<ITaxRate?> OnInvoke()
 | 
			
		||||
		{
 | 
			
		||||
			return await (from dc in Cache
 | 
			
		||||
						  where string.Equals(dc.Name, Arguments.Name, StringComparison.OrdinalIgnoreCase) && dc.Rate == Arguments.Rate
 | 
			
		||||
						  select dc).AsEntity();
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	/// <summary>
 | 
			
		||||
	/// Returns List of <see cref="ITaxRate"/> for the specified set of ids. Use this method when joining data
 | 
			
		||||
	/// to other entities.
 | 
			
		||||
	/// </summary>
 | 
			
		||||
	internal sealed class Lookup : ServiceFunction<PrimaryKeyListArgs<int>, ImmutableList<ITaxRate>?>
 | 
			
		||||
	{
 | 
			
		||||
		public Lookup(ITaxRateCache cache)
 | 
			
		||||
		{
 | 
			
		||||
			Cache = cache;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		private ITaxRateCache Cache { get; }
 | 
			
		||||
		protected override async Task<ImmutableList<ITaxRate>?> OnInvoke()
 | 
			
		||||
		{
 | 
			
		||||
			/*
 | 
			
		||||
			 * Use simple linq join for the specified set of ids.
 | 
			
		||||
			 */
 | 
			
		||||
			return await (from dc in Cache where Arguments.IdList.Contains(dc.Id) select dc).AsEntities<ITaxRate>();
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	/// <summary>
 | 
			
		||||
	/// Inserts a new <see cref="ITaxRate"/> and returns its Id.
 | 
			
		||||
	/// </summary>
 | 
			
		||||
	internal sealed class Insert : ServiceFunction<InsertTaxRateArgs, int>
 | 
			
		||||
	{
 | 
			
		||||
		public Insert(ITaxRateService taxRateService, IStorageProvider storage, IEventService events, ITaxRateCache cache)
 | 
			
		||||
		{
 | 
			
		||||
			TaxRateService = taxRateService;
 | 
			
		||||
			Storage = storage;
 | 
			
		||||
			Events = events;
 | 
			
		||||
			Cache = cache;
 | 
			
		||||
		}
 | 
			
		||||
		private ITaxRateService TaxRateService { get; }
 | 
			
		||||
		private IStorageProvider Storage { get; }
 | 
			
		||||
		private IEventService Events { get; }
 | 
			
		||||
		private ITaxRateCache Cache { get; }
 | 
			
		||||
 | 
			
		||||
		protected override async Task<int> OnInvoke()
 | 
			
		||||
		{
 | 
			
		||||
			/*
 | 
			
		||||
			 * First, create a new entity from the passed arguments and mark its state as new. This will
 | 
			
		||||
			 * signal the DatabaseContext to perform an insert operation when calling the Update.
 | 
			
		||||
			 */
 | 
			
		||||
			var entity = Arguments.AsEntity<TaxRate>(State.New);
 | 
			
		||||
			/*
 | 
			
		||||
			 * Call update on the DatabaseContext. This call will return a new ITaxRate of the inserted
 | 
			
		||||
			 * entity.
 | 
			
		||||
			 */
 | 
			
		||||
			return (await Storage.Open<TaxRate>().Update(entity)).Id;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		protected override async Task OnCommitted()
 | 
			
		||||
		{
 | 
			
		||||
			/*
 | 
			
		||||
			 * At this stage, the transaction has been commited which means
 | 
			
		||||
			 * record is definitely permanently stored in the database.
 | 
			
		||||
			 * We are making a simple call to the cache to refresh the item with the
 | 
			
		||||
			 * new id. Cache will query a database for new record and will store it 
 | 
			
		||||
			 * in memory.
 | 
			
		||||
			 */
 | 
			
		||||
			await Cache.Refresh(Result);
 | 
			
		||||
			/*
 | 
			
		||||
			 * Now trigger the inserted event which will notify all components hooked in the
 | 
			
		||||
			 * same process, out of process scale out instances and clients (wasm).
 | 
			
		||||
			 */
 | 
			
		||||
			await Events.Enqueue(this, TaxRateService, ServiceEvents.Inserted, Result);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	/// <summary>
 | 
			
		||||
	/// Permanently deletes a <see cref="ITaxRate"/> from the system.
 | 
			
		||||
	/// </summary>
 | 
			
		||||
	/// <remarks>
 | 
			
		||||
	/// This method gets called after all <see cref="Server.Data.DataProtection.IDataProtectionMiddleware{TArgs}"/>
 | 
			
		||||
	/// middleware passed successfuly.
 | 
			
		||||
	/// </remarks>
 | 
			
		||||
	internal sealed class Delete : ServiceAction<PrimaryKeyArgs<int>>
 | 
			
		||||
	{
 | 
			
		||||
		public Delete(ITaxRateService taxRateService, IStorageProvider storage, ITaxRateCache cache, IEventService events)
 | 
			
		||||
		{
 | 
			
		||||
			TaxRateService = taxRateService;
 | 
			
		||||
			Storage = storage;
 | 
			
		||||
			Cache = cache;
 | 
			
		||||
			Events = events;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		private ITaxRateService TaxRateService { get; }
 | 
			
		||||
		private IStorageProvider Storage { get; }
 | 
			
		||||
		private ITaxRateCache Cache { get; }
 | 
			
		||||
		private IEventService Events { get; }
 | 
			
		||||
 | 
			
		||||
		protected override async Task OnInvoke()
 | 
			
		||||
		{
 | 
			
		||||
			/*
 | 
			
		||||
			 * we don't need a reference to a record here because delete uses only
 | 
			
		||||
			 * an id. The overhead would only occur in cases if the record wouldn't exist
 | 
			
		||||
			 * but this is not the job of the operation. The Validators should theoretically 
 | 
			
		||||
			 * reject such an operation.
 | 
			
		||||
			 */
 | 
			
		||||
			await Storage.Open<TaxRate>().Update(new TaxRate { Id = Arguments.Id, State = State.Deleted });
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		protected override async Task OnCommitted()
 | 
			
		||||
		{
 | 
			
		||||
			/*
 | 
			
		||||
			 * Once all the transactions have been commited remove the non existing record
 | 
			
		||||
			 * from the cache.
 | 
			
		||||
			 */
 | 
			
		||||
			await Cache.Remove(Arguments.Id);
 | 
			
		||||
			/*
 | 
			
		||||
			 * And notify audience about the event.
 | 
			
		||||
			 */
 | 
			
		||||
			await Events.Enqueue(this, TaxRateService, ServiceEvents.Deleted, Arguments.Id);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	/// <summary>
 | 
			
		||||
	/// Updates the <see cref="ITaxRate"/> entity.
 | 
			
		||||
	/// </summary>
 | 
			
		||||
	internal sealed class Update : ServiceAction<UpdateTaxRateArgs>
 | 
			
		||||
	{
 | 
			
		||||
		public Update(ITaxRateService taxRateService, IStorageProvider storage, ITaxRateCache cache, IEventService events)
 | 
			
		||||
		{
 | 
			
		||||
			TaxRateService = taxRateService;
 | 
			
		||||
			Storage = storage;
 | 
			
		||||
			Cache = cache;
 | 
			
		||||
			Events = events;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		private IStorageProvider Storage { get; }
 | 
			
		||||
		private ITaxRateCache Cache { get; }
 | 
			
		||||
		private IEventService Events { get; }
 | 
			
		||||
		private ITaxRateService TaxRateService { get; }
 | 
			
		||||
 | 
			
		||||
		protected override async Task OnInvoke()
 | 
			
		||||
		{
 | 
			
		||||
			/*
 | 
			
		||||
			 * TaxRate is concurrency entity which means the platform takes care of
 | 
			
		||||
			 * data consistency. Data consistency means we can't overwrite updates made
 | 
			
		||||
			 * by others.
 | 
			
		||||
			 * Updating Concurrency entity thus requires a bit more logic. We must use a retry logic 
 | 
			
		||||
			 * in case of Concurrency failure. We'll call Update method with reload lambda function.
 | 
			
		||||
			 */
 | 
			
		||||
			var entity = SetState(await Load());
 | 
			
		||||
 | 
			
		||||
			await Storage.Open<TaxRate>().Update(entity, Arguments, async () =>
 | 
			
		||||
			{
 | 
			
		||||
				/*
 | 
			
		||||
				 * The concurrency exception occured.
 | 
			
		||||
				 * Refresh the entry from the cache. This will load a new version from 
 | 
			
		||||
				 * a database.
 | 
			
		||||
				 */
 | 
			
		||||
				await Cache.Refresh(Arguments.Id);
 | 
			
		||||
 | 
			
		||||
				return SetState(await Load());
 | 
			
		||||
			});
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		private async Task<TaxRate?> Load() => await (from dc in Cache where dc.Id == Arguments.Id select dc).AsEntity();
 | 
			
		||||
 | 
			
		||||
		protected override async Task OnCommitted()
 | 
			
		||||
		{
 | 
			
		||||
			/*
 | 
			
		||||
			 * Once the update is complete refresh the cache because the database assigned a new timestamp
 | 
			
		||||
			 * to an entity and any sunsequent update would fail anyway.
 | 
			
		||||
			 */
 | 
			
		||||
			await Cache.Refresh(Arguments.Id);
 | 
			
		||||
			/*
 | 
			
		||||
			 * Now trigger the distributed event notifying the update has completed. 
 | 
			
		||||
			 */
 | 
			
		||||
			await Events.Enqueue(this, TaxRateService, ServiceEvents.Updated, Arguments.Id);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										94
									
								
								src/Connected.Common.Types/TaxRates/TaxRateService.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										94
									
								
								src/Connected.Common.Types/TaxRates/TaxRateService.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,94 @@
 | 
			
		||||
using System.Collections.Immutable;
 | 
			
		||||
using Connected.Common.Types.Security;
 | 
			
		||||
using Connected.ServiceModel;
 | 
			
		||||
using Connected.Services;
 | 
			
		||||
using Connected.Services.Annotations;
 | 
			
		||||
 | 
			
		||||
namespace Connected.Common.Types.TaxRates;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// The implementation class for <see cref="ITaxRateService"/> service.
 | 
			
		||||
/// </summary>
 | 
			
		||||
internal sealed class TaxRateService : EntityService<int>, ITaxRateService
 | 
			
		||||
{
 | 
			
		||||
	public TaxRateService(IContext context) : base(context)
 | 
			
		||||
	{
 | 
			
		||||
	}
 | 
			
		||||
	/// <summary>
 | 
			
		||||
	/// Perorfms a lookup on <see cref="ITaxRate"/> records based on a specified
 | 
			
		||||
	/// set of ids.
 | 
			
		||||
	/// </summary>
 | 
			
		||||
	/// <param name="e">The list of ids for which records should be returned.</param>
 | 
			
		||||
	/// <returns>The list if <see cref="ITaxRate"/> records.</returns>
 | 
			
		||||
	[ServiceAuthorization(Claims.Read)]
 | 
			
		||||
	public async Task<ImmutableList<ITaxRate>?> Query(PrimaryKeyListArgs<int> e)
 | 
			
		||||
	{
 | 
			
		||||
		return await Invoke(GetOperation<TaxRateOps.Lookup>(), e);
 | 
			
		||||
	}
 | 
			
		||||
	/// <summary>
 | 
			
		||||
	/// Queries the entire <see cref="ITaxRate"/> entity set.
 | 
			
		||||
	/// </summary>
 | 
			
		||||
	/// <returns>The list of all <see cref="ITaxRate"/> entities.</returns>
 | 
			
		||||
	[ServiceAuthorization(Claims.Read)]
 | 
			
		||||
	public async Task<ImmutableList<ITaxRate>?> Query(QueryArgs? args)
 | 
			
		||||
	{
 | 
			
		||||
		return await Invoke(GetOperation<TaxRateOps.Query>(), args ?? QueryArgs.NoPaging);
 | 
			
		||||
	}
 | 
			
		||||
	/// <summary>
 | 
			
		||||
	/// Searches for the first <see cref="ITaxRate"/> entity which matches
 | 
			
		||||
	/// the specified arguments.
 | 
			
		||||
	/// </summary>
 | 
			
		||||
	/// <param name="args">The arguments representing search criteria.</param>
 | 
			
		||||
	/// <returns>The first <see cref="ITaxRate"/> entity which matches the
 | 
			
		||||
	/// criteria, <code>null</code> otherwise.</returns>
 | 
			
		||||
	[ServiceAuthorization(Claims.Read)]
 | 
			
		||||
	public async Task<ITaxRate?> Select(TaxRateArgs args)
 | 
			
		||||
	{
 | 
			
		||||
		return await Invoke(GetOperation<TaxRateOps.SelectByRate>(), args);
 | 
			
		||||
	}
 | 
			
		||||
	/// <summary>
 | 
			
		||||
	/// Selects the <see cref="ITaxRate"/> for the specified id.
 | 
			
		||||
	/// </summary>
 | 
			
		||||
	/// <param name="args">The id for which a record will
 | 
			
		||||
	/// be returned.</param>
 | 
			
		||||
	/// <returns>The <see cref="ITaxRate"/> entity with the specified id,
 | 
			
		||||
	/// <code>null</code> otherwise.</returns>
 | 
			
		||||
	[ServiceAuthorization(Claims.Read)]
 | 
			
		||||
	public async Task<ITaxRate?> Select(PrimaryKeyArgs<int> args)
 | 
			
		||||
	{
 | 
			
		||||
		return await Invoke(GetOperation<TaxRateOps.Select>(), args);
 | 
			
		||||
	}
 | 
			
		||||
	/// <summary>
 | 
			
		||||
	/// Permanently deletes an <see cref="ITaxRate"/> entity with
 | 
			
		||||
	/// the specified id.
 | 
			
		||||
	/// </summary>
 | 
			
		||||
	/// <remarks>
 | 
			
		||||
	/// This operation can be rejected by an <see cref="IDataProtectionMiddleware{TArgs}"/>
 | 
			
		||||
	/// middleware.
 | 
			
		||||
	/// </remarks>
 | 
			
		||||
	/// <param name="args">The id of the entity which will be deleted.</param>
 | 
			
		||||
	[ServiceAuthorization(Claims.Delete)]
 | 
			
		||||
	public async Task Delete(PrimaryKeyArgs<int> args)
 | 
			
		||||
	{
 | 
			
		||||
		await Invoke(GetOperation<TaxRateOps.Delete>(), args);
 | 
			
		||||
	}
 | 
			
		||||
	/// <summary>
 | 
			
		||||
	/// Inserts a new <see cref="ITaxRate"/> entity into the system.
 | 
			
		||||
	/// </summary>
 | 
			
		||||
	/// <param name="args">The values representing a new entity.</param>
 | 
			
		||||
	/// <returns>An id of the newly inserted entity.</returns>
 | 
			
		||||
	[ServiceAuthorization(Claims.Add)]
 | 
			
		||||
	public async Task<int> Insert(InsertTaxRateArgs args)
 | 
			
		||||
	{
 | 
			
		||||
		return await Invoke(GetOperation<TaxRateOps.Insert>(), args);
 | 
			
		||||
	}
 | 
			
		||||
	/// <summary>
 | 
			
		||||
	/// Updates an existing <see cref="ITaxRate"/> entity.
 | 
			
		||||
	/// </summary>
 | 
			
		||||
	/// <param name="args">The arguments representing a changed values.</param>
 | 
			
		||||
	[ServiceAuthorization(Claims.Modify)]
 | 
			
		||||
	public async Task Update(UpdateTaxRateArgs args)
 | 
			
		||||
	{
 | 
			
		||||
		await Invoke(GetOperation<TaxRateOps.Update>(), args);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										48
									
								
								src/Connected.Common.Types/TaxRates/TaxRatesValidators.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								src/Connected.Common.Types/TaxRates/TaxRatesValidators.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,48 @@
 | 
			
		||||
using Connected.Entities;
 | 
			
		||||
using Connected.Middleware;
 | 
			
		||||
using Connected.Validation;
 | 
			
		||||
 | 
			
		||||
namespace Connected.Common.Types.TaxRates;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Business logic validator for the <see cref="InsertTaxRateArgs"/> arguments.
 | 
			
		||||
/// </summary>
 | 
			
		||||
internal sealed class InsertTaxRateValidator : MiddlewareComponent, IValidator<InsertTaxRateArgs>
 | 
			
		||||
{
 | 
			
		||||
	public InsertTaxRateValidator(ITaxRateCache cache)
 | 
			
		||||
	{
 | 
			
		||||
		Service = cache;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private ITaxRateCache Service { get; }
 | 
			
		||||
 | 
			
		||||
	public async Task Validate(InsertTaxRateArgs args)
 | 
			
		||||
	{
 | 
			
		||||
		/*
 | 
			
		||||
		 * We have a constraint on a name property. 
 | 
			
		||||
		 */
 | 
			
		||||
		if (await (from dc in Service where string.Equals(dc.Name, args.Name, StringComparison.OrdinalIgnoreCase) select dc).AsEntity() is ITaxRate existing)
 | 
			
		||||
			throw ValidationExceptions.ValueExists(nameof(args.Name), args.Name);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Business logic validator for the <see cref="UpdateTaxRateArgs"/> arguments.
 | 
			
		||||
/// </summary>
 | 
			
		||||
internal sealed class UpdateTaxRateValidator : MiddlewareComponent, IValidator<UpdateTaxRateArgs>
 | 
			
		||||
{
 | 
			
		||||
	public UpdateTaxRateValidator(ITaxRateCache cache)
 | 
			
		||||
	{
 | 
			
		||||
		Service = cache;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private ITaxRateCache Service { get; }
 | 
			
		||||
 | 
			
		||||
	public async Task Validate(UpdateTaxRateArgs args)
 | 
			
		||||
	{
 | 
			
		||||
		/*
 | 
			
		||||
		 * A difference from the insert validator is to exclude the id of the updating record.
 | 
			
		||||
		 */
 | 
			
		||||
		if (await (from dc in Service where string.Equals(dc.Name, args.Name, StringComparison.OrdinalIgnoreCase) && dc.Id != args.Id select dc).AsEntity() is ITaxRate existing)
 | 
			
		||||
			throw ValidationExceptions.ValueExists(nameof(args.Name), args.Name);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										14
									
								
								src/Connected.Common.Types/version.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								src/Connected.Common.Types/version.json
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,14 @@
 | 
			
		||||
{
 | 
			
		||||
  "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/main/src/NerdBank.GitVersioning/version.schema.json",
 | 
			
		||||
  "version": "1.0-prerelease",
 | 
			
		||||
  "semVer1NumericIdentifierPadding": 4,
 | 
			
		||||
  "nugetPackageVersion": {
 | 
			
		||||
    "semVer": 2, // optional. Set to either 1 or 2 to control how the NuGet package version string is generated. Default is 1.
 | 
			
		||||
    "precision": "build" // optional. Use when you want to use a more or less precise package version than the default major.minor.build.
 | 
			
		||||
  },
 | 
			
		||||
  "cloudBuild": {
 | 
			
		||||
    "buildNumber": {
 | 
			
		||||
      "enabled": true
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,25 @@
 | 
			
		||||
<Project Sdk="Microsoft.NET.Sdk">
 | 
			
		||||
 | 
			
		||||
  <PropertyGroup>
 | 
			
		||||
    <TargetFramework>net7.0</TargetFramework>
 | 
			
		||||
    <ImplicitUsings>enable</ImplicitUsings>
 | 
			
		||||
    <Nullable>enable</Nullable>
 | 
			
		||||
 | 
			
		||||
    <IsPackable>false</IsPackable>
 | 
			
		||||
 | 
			
		||||
    <RootNamespace>Connected.Common.Types</RootNamespace>
 | 
			
		||||
  </PropertyGroup>
 | 
			
		||||
 | 
			
		||||
  <ItemGroup>
 | 
			
		||||
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
 | 
			
		||||
    <PackageReference Include="moq" Version="4.18.2" />
 | 
			
		||||
    <PackageReference Include="MSTest.TestAdapter" Version="2.2.10" />
 | 
			
		||||
    <PackageReference Include="MSTest.TestFramework" Version="2.2.10" />
 | 
			
		||||
    <PackageReference Include="coverlet.collector" Version="3.1.2" />
 | 
			
		||||
  </ItemGroup>
 | 
			
		||||
 | 
			
		||||
  <ItemGroup>
 | 
			
		||||
    <ProjectReference Include="..\..\src\Connected.Common.Types\Connected.Common.Types.csproj" />
 | 
			
		||||
  </ItemGroup>
 | 
			
		||||
 | 
			
		||||
</Project>
 | 
			
		||||
							
								
								
									
										61
									
								
								tests/Connected.Common.Types.Tests/InstanceFaker.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										61
									
								
								tests/Connected.Common.Types.Tests/InstanceFaker.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,61 @@
 | 
			
		||||
using Moq;
 | 
			
		||||
 | 
			
		||||
namespace Common.Types;
 | 
			
		||||
 | 
			
		||||
internal class InstanceFaker<T>
 | 
			
		||||
{
 | 
			
		||||
	private readonly Dictionary<Type, Mock> _mocks = new();
 | 
			
		||||
	private bool _mocksGenerated = false;
 | 
			
		||||
 | 
			
		||||
	public InstanceFaker()
 | 
			
		||||
	{
 | 
			
		||||
		if (typeof(T).GetConstructors().Length > 1)
 | 
			
		||||
			throw new Exception($"Multiple constructors for type {typeof(T).FullName} found. Auto resolve not possible.");
 | 
			
		||||
 | 
			
		||||
		GenerateMocks();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private void GenerateMocks()
 | 
			
		||||
	{
 | 
			
		||||
		if (_mocksGenerated)
 | 
			
		||||
			return;
 | 
			
		||||
 | 
			
		||||
		_mocksGenerated = true;
 | 
			
		||||
 | 
			
		||||
		var constructor = typeof(T).GetConstructors()[0];
 | 
			
		||||
 | 
			
		||||
		var parameters = constructor.GetParameters();
 | 
			
		||||
 | 
			
		||||
		foreach (var parameter in parameters)
 | 
			
		||||
		{
 | 
			
		||||
			if (!parameter.ParameterType.IsInterface)
 | 
			
		||||
				throw new Exception($"Constructor parameter {parameter.Name} of type {parameter.ParameterType.FullName} is not an interface, cannot mock.");
 | 
			
		||||
 | 
			
		||||
			_mocks.Add(parameter.ParameterType, CreateMock(parameter.ParameterType));
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private T ProcessType()
 | 
			
		||||
	{
 | 
			
		||||
		GenerateMocks();
 | 
			
		||||
 | 
			
		||||
		var constructor = typeof(T).GetConstructors()[0];
 | 
			
		||||
 | 
			
		||||
		var mocks = _mocks.Select(e => e.Value.Object);
 | 
			
		||||
 | 
			
		||||
		return (T)constructor.Invoke(mocks.Cast<object>().ToArray());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private Mock? CreateMock(Type type)
 | 
			
		||||
	{
 | 
			
		||||
		var creator = typeof(Mock<>).MakeGenericType(type);
 | 
			
		||||
		return Activator.CreateInstance(creator) as Mock;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public Mock<T>? GetMock<T>()
 | 
			
		||||
		where T : class => _mocks.GetValueOrDefault(typeof(T)) as Mock<T>;
 | 
			
		||||
 | 
			
		||||
	private T _instance;
 | 
			
		||||
 | 
			
		||||
	public T Instance => _instance ??= ProcessType();
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										190
									
								
								tests/Connected.Common.Types.Tests/TaxRates/Ops/DeleteTests.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										190
									
								
								tests/Connected.Common.Types.Tests/TaxRates/Ops/DeleteTests.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,190 @@
 | 
			
		||||
using Connected.Common.Types.TaxRates;
 | 
			
		||||
using Connected.Entities;
 | 
			
		||||
using Connected.Entities.Storage;
 | 
			
		||||
using Connected.Notifications.Events;
 | 
			
		||||
using Connected.ServiceModel;
 | 
			
		||||
using Connected.ServiceModel.Transactions;
 | 
			
		||||
 | 
			
		||||
using Moq;
 | 
			
		||||
using static Connected.Common.Types.TaxRates.TaxRateOps;
 | 
			
		||||
 | 
			
		||||
namespace Common.Types.TaxRates.Ops;
 | 
			
		||||
 | 
			
		||||
public class DeleteTests
 | 
			
		||||
{
 | 
			
		||||
	[TestClass]
 | 
			
		||||
	public class OnInvoke
 | 
			
		||||
	{
 | 
			
		||||
		[TestMethod("Delete invoke calls update with state as deleted")]
 | 
			
		||||
		public async Task Delete_Invoke_CallsUpdateWithStateDeleted()
 | 
			
		||||
		{
 | 
			
		||||
			/*
 | 
			
		||||
			 * Setup
 | 
			
		||||
			 */
 | 
			
		||||
			var expectedValue = State.Deleted;
 | 
			
		||||
			var actualValue = (State)0;
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Required services
 | 
			
		||||
			 */
 | 
			
		||||
			var instanceFaker = new InstanceFaker<Delete>();
 | 
			
		||||
 | 
			
		||||
			var databaseContextProviderFake = instanceFaker.GetMock<IStorageProvider>()!;
 | 
			
		||||
 | 
			
		||||
			_ = databaseContextProviderFake
 | 
			
		||||
				.Setup(e => e.Open<TaxRate>().Update(It.IsAny<TaxRate>()))
 | 
			
		||||
				.Callback<TaxRate>(e => actualValue = e.State)
 | 
			
		||||
				.ReturnsAsync(new TaxRate { Id = 1 });
 | 
			
		||||
			/*
 | 
			
		||||
			 * Arguments play no role for this test
 | 
			
		||||
			 */
 | 
			
		||||
			var args = new PrimaryKeyArgs<int>(1);
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Test
 | 
			
		||||
			 */
 | 
			
		||||
			var serviceFunction = instanceFaker.Instance;
 | 
			
		||||
			await serviceFunction.Invoke(args);
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Assert
 | 
			
		||||
			 */
 | 
			
		||||
			databaseContextProviderFake.Verify(e => e.Open<TaxRate>().Update(It.IsAny<TaxRate>()), Times.Exactly(1));
 | 
			
		||||
			Assert.AreEqual(expectedValue, actualValue);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		[TestMethod("Delete invoke correctly maps values to entity")]
 | 
			
		||||
		public async Task Delete_Invoke_MapsArgumentsCorrectly()
 | 
			
		||||
		{
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Setup
 | 
			
		||||
			 */
 | 
			
		||||
			var expectedId = 1;
 | 
			
		||||
			var actualValue = int.MinValue;
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Required services
 | 
			
		||||
			 */
 | 
			
		||||
			var instanceFaker = new InstanceFaker<Delete>();
 | 
			
		||||
 | 
			
		||||
			var databaseContextProviderFake = instanceFaker.GetMock<IStorageProvider>()!;
 | 
			
		||||
 | 
			
		||||
			_ = databaseContextProviderFake
 | 
			
		||||
				.Setup(e => e.Open<TaxRate>().Update(It.IsAny<TaxRate>()))
 | 
			
		||||
				.Callback<TaxRate>(e => actualValue = e.Id)
 | 
			
		||||
				.ReturnsAsync(new TaxRate { Id = expectedId });
 | 
			
		||||
			/*
 | 
			
		||||
			 * Arguments play no role for this test
 | 
			
		||||
			 */
 | 
			
		||||
			var args = new PrimaryKeyArgs<int>(expectedId);
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Test
 | 
			
		||||
			 */
 | 
			
		||||
			var serviceFunction = instanceFaker.Instance;
 | 
			
		||||
			await serviceFunction.Invoke(args);
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Assert
 | 
			
		||||
			 */
 | 
			
		||||
			databaseContextProviderFake.Verify(e => e.Open<TaxRate>().Update(It.IsAny<TaxRate>()), Times.Exactly(1));
 | 
			
		||||
			Assert.AreEqual(expectedId, actualValue);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	[TestClass]
 | 
			
		||||
	public class OnCommit
 | 
			
		||||
	{
 | 
			
		||||
		[TestMethod("Delete commit invokes deleted event exactly once")]
 | 
			
		||||
		public async Task Delete_Commit_InvokedDeleted_ExactlyOnce()
 | 
			
		||||
		{
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Setup
 | 
			
		||||
			 */
 | 
			
		||||
			var instanceFaker = new InstanceFaker<Delete>();
 | 
			
		||||
 | 
			
		||||
			var taxRateCacheFake = instanceFaker.GetMock<ITaxRateCache>()!;
 | 
			
		||||
 | 
			
		||||
			_ = taxRateCacheFake.Setup(e => e.Refresh(It.IsAny<int>()));
 | 
			
		||||
 | 
			
		||||
			var eventServiceFake = instanceFaker.GetMock<IEventService>()!;
 | 
			
		||||
 | 
			
		||||
			_ = eventServiceFake.SetupEvent<ITaxRateService, int>(ServiceEvents.Deleted);
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Test
 | 
			
		||||
			 */
 | 
			
		||||
			var serviceFunction = instanceFaker.Instance;
 | 
			
		||||
 | 
			
		||||
			serviceFunction.SetArguments(new PrimaryKeyArgs<int>(1));
 | 
			
		||||
 | 
			
		||||
			await ((ITransactionClient)serviceFunction).Commit();
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Assert
 | 
			
		||||
			 */
 | 
			
		||||
			eventServiceFake.VerifyEvent<ITaxRateService, int>(ServiceEvents.Deleted);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		[TestMethod("Delete commit removes cache exactly once")]
 | 
			
		||||
		public async Task Delete_Commit_RemovesCache_ExactlyOnce()
 | 
			
		||||
		{
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Setup
 | 
			
		||||
			 */
 | 
			
		||||
			var instanceFaker = new InstanceFaker<Delete>();
 | 
			
		||||
 | 
			
		||||
			var taxRateCacheFake = instanceFaker.GetMock<ITaxRateCache>()!;
 | 
			
		||||
 | 
			
		||||
			_ = taxRateCacheFake.Setup(e => e.Remove(It.IsAny<int>()));
 | 
			
		||||
 | 
			
		||||
			var eventServiceFake = instanceFaker.GetMock<IEventService>()!;
 | 
			
		||||
 | 
			
		||||
			_ = eventServiceFake.SetupEvent<ITaxRateService, int>(ServiceEvents.Deleted);
 | 
			
		||||
			/*
 | 
			
		||||
			 * Test
 | 
			
		||||
			 */
 | 
			
		||||
			var serviceFunction = instanceFaker.Instance;
 | 
			
		||||
 | 
			
		||||
			serviceFunction.SetArguments(new PrimaryKeyArgs<int>(1));
 | 
			
		||||
 | 
			
		||||
			await ((ITransactionClient)serviceFunction).Commit();
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Assert
 | 
			
		||||
			 */
 | 
			
		||||
			taxRateCacheFake.Verify(e => e.Remove(It.IsAny<int>()), Times.Exactly(1));
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		[TestMethod("Delete commit fires deleted event after notifying cache")]
 | 
			
		||||
		public async Task Delete_Commit_InvokedDeletedEvent_AfterNotifyingCache()
 | 
			
		||||
		{
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Setup
 | 
			
		||||
			 * 
 | 
			
		||||
			 * If you receive an error about function calls not properly set up, and function 
 | 
			
		||||
			 * calls look ok, it's probably the sequence throwing the exception. This is a 
 | 
			
		||||
			 * failure in user code, not the test.
 | 
			
		||||
			 */
 | 
			
		||||
			var sequence = new MockSequence();
 | 
			
		||||
 | 
			
		||||
			var instanceFaker = new InstanceFaker<Delete>();
 | 
			
		||||
 | 
			
		||||
			var taxRateCacheFake = instanceFaker.GetMock<ITaxRateCache>()!;
 | 
			
		||||
 | 
			
		||||
			_ = taxRateCacheFake
 | 
			
		||||
				.InSequence(sequence)
 | 
			
		||||
				.Setup(e => e.Remove(It.IsAny<int>()));
 | 
			
		||||
 | 
			
		||||
			var eventServiceFake = instanceFaker.GetMock<IEventService>()!;
 | 
			
		||||
 | 
			
		||||
			_ = eventServiceFake
 | 
			
		||||
				.InSequence(sequence)
 | 
			
		||||
				.SetupEvent<ITaxRateService, int>(ServiceEvents.Deleted);
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Test
 | 
			
		||||
			 */
 | 
			
		||||
			var serviceFunction = instanceFaker.Instance;
 | 
			
		||||
 | 
			
		||||
			serviceFunction.SetArguments(new PrimaryKeyArgs<int>(1));
 | 
			
		||||
 | 
			
		||||
			await ((ITransactionClient)serviceFunction).Commit();
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Assert
 | 
			
		||||
			 */
 | 
			
		||||
			taxRateCacheFake.Verify(e => e.Remove(It.IsAny<int>()), Times.Exactly(1));
 | 
			
		||||
			eventServiceFake.VerifyEvent<ITaxRateService, int>(ServiceEvents.Deleted);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										270
									
								
								tests/Connected.Common.Types.Tests/TaxRates/Ops/InsertTests.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										270
									
								
								tests/Connected.Common.Types.Tests/TaxRates/Ops/InsertTests.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,270 @@
 | 
			
		||||
using System.Reflection;
 | 
			
		||||
using Connected.Common.Types.TaxRates;
 | 
			
		||||
using Connected.Data;
 | 
			
		||||
using Connected.Entities;
 | 
			
		||||
using Connected.Entities.Annotations;
 | 
			
		||||
using Connected.Entities.Storage;
 | 
			
		||||
using Connected.Notifications.Events;
 | 
			
		||||
using Connected.ServiceModel;
 | 
			
		||||
using Connected.ServiceModel.Transactions;
 | 
			
		||||
using Moq;
 | 
			
		||||
using static Connected.Common.Types.TaxRates.TaxRateOps;
 | 
			
		||||
 | 
			
		||||
namespace Common.Types.TaxRates.Ops;
 | 
			
		||||
 | 
			
		||||
public class InsertTests
 | 
			
		||||
{
 | 
			
		||||
	[TestClass]
 | 
			
		||||
	public class OnInvoke
 | 
			
		||||
	{
 | 
			
		||||
		[TestMethod("Insert invoke returns inserted id")]
 | 
			
		||||
		public async Task Insert_Invoke_ReturnsInsertedId()
 | 
			
		||||
		{
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Setup
 | 
			
		||||
			 */
 | 
			
		||||
			var expectedId = 1;
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Required services
 | 
			
		||||
			 */
 | 
			
		||||
			var instanceFaker = new InstanceFaker<Insert>();
 | 
			
		||||
 | 
			
		||||
			var databaseContextProviderFake = instanceFaker.GetMock<IStorageProvider>()!;
 | 
			
		||||
 | 
			
		||||
			_ = databaseContextProviderFake
 | 
			
		||||
				.Setup(e => e.Open<TaxRate>().Update(It.IsAny<TaxRate>()))
 | 
			
		||||
				.ReturnsAsync(new TaxRate { Id = expectedId });
 | 
			
		||||
			/*
 | 
			
		||||
			 * Arguments play no role for this test
 | 
			
		||||
			 */
 | 
			
		||||
			var args = new InsertTaxRateArgs { };
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Test
 | 
			
		||||
			 */
 | 
			
		||||
			var serviceFunction = instanceFaker.Instance;
 | 
			
		||||
			var result = await serviceFunction.Invoke(args);
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Assert
 | 
			
		||||
			 */
 | 
			
		||||
			Assert.AreEqual(result, expectedId);
 | 
			
		||||
			databaseContextProviderFake.Verify(e => e.Open<TaxRate>().Update(It.IsAny<TaxRate>()), Times.Exactly(1));
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		[TestMethod("Insert invoke inserts exactly one new value")]
 | 
			
		||||
		public async Task Insert_Invoke_InsertsNewValue_ExactlyOnce()
 | 
			
		||||
		{
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Setup
 | 
			
		||||
			 */
 | 
			
		||||
			var expectedId = 1;
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Required services
 | 
			
		||||
			 */
 | 
			
		||||
			var instanceFaker = new InstanceFaker<Insert>();
 | 
			
		||||
 | 
			
		||||
			var databaseContextProviderFake = instanceFaker.GetMock<IStorageProvider>()!;
 | 
			
		||||
 | 
			
		||||
			_ = databaseContextProviderFake
 | 
			
		||||
				.Setup(e => e.Open<TaxRate>().Update(It.Is<TaxRate>(e => e.State == State.New)))
 | 
			
		||||
				.ReturnsAsync(new TaxRate { Id = expectedId });
 | 
			
		||||
			/*
 | 
			
		||||
			 * Arguments play no role for this test
 | 
			
		||||
			 */
 | 
			
		||||
			var args = new InsertTaxRateArgs();
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Test
 | 
			
		||||
			 */
 | 
			
		||||
			var serviceFunction = instanceFaker.Instance;
 | 
			
		||||
			var result = await serviceFunction.Invoke(args);
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Assert
 | 
			
		||||
			 */
 | 
			
		||||
			databaseContextProviderFake.Verify(e => e.Open<TaxRate>().Update(It.IsAny<TaxRate>()), Times.Exactly(1));
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		[TestMethod("Insert invoke correctly maps values to entity")]
 | 
			
		||||
		public async Task Insert_Invoke_MapsArgumentsCorrectly()
 | 
			
		||||
		{
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Setup
 | 
			
		||||
			 */
 | 
			
		||||
			var expectedEntity = new TaxRate
 | 
			
		||||
			{
 | 
			
		||||
				Name = "TaxRate",
 | 
			
		||||
				Rate = 1.0f,
 | 
			
		||||
			};
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Required services
 | 
			
		||||
			 */
 | 
			
		||||
			var actualEntity = null as TaxRate;
 | 
			
		||||
 | 
			
		||||
			var instanceFaker = new InstanceFaker<Insert>();
 | 
			
		||||
 | 
			
		||||
			var databaseContextProviderFake = instanceFaker.GetMock<IStorageProvider>()!;
 | 
			
		||||
 | 
			
		||||
			_ = databaseContextProviderFake
 | 
			
		||||
				.Setup(e => e.Open<TaxRate>().Update(It.IsAny<TaxRate>()))
 | 
			
		||||
				.Callback<TaxRate>(e => actualEntity = e)
 | 
			
		||||
				.ReturnsAsync(expectedEntity with { Id = 1 });
 | 
			
		||||
 | 
			
		||||
			var args = new InsertTaxRateArgs
 | 
			
		||||
			{
 | 
			
		||||
				Name = expectedEntity.Name,
 | 
			
		||||
				Rate = expectedEntity.Rate
 | 
			
		||||
			};
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Test
 | 
			
		||||
			 */
 | 
			
		||||
			var serviceFunction = instanceFaker.Instance;
 | 
			
		||||
			var result = await serviceFunction.Invoke(args);
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Assert
 | 
			
		||||
			 */
 | 
			
		||||
			databaseContextProviderFake.Verify(e => e.Open<TaxRate>().Update(It.IsAny<TaxRate>()), Times.Exactly(1));
 | 
			
		||||
			Assert.AreEqual(expectedEntity.Name, actualEntity?.Name);
 | 
			
		||||
			Assert.AreEqual(expectedEntity.Rate, actualEntity?.Rate);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		[TestMethod("Insert invoke sets status to enabled or default")]
 | 
			
		||||
		public async Task Insert_Invoke_SetsStatusToEnabledOrDefault()
 | 
			
		||||
		{
 | 
			
		||||
			/*
 | 
			
		||||
			 * Setup
 | 
			
		||||
			 * Valid values are Enabled or Default (db provider sets it to enabled then)
 | 
			
		||||
			 */
 | 
			
		||||
			var expectedStatuses = new[] { Status.Enabled }.ToList();
 | 
			
		||||
			/*
 | 
			
		||||
			 * Check if the default value for the status field is enabled. If so, add 0 to the expected values list.
 | 
			
		||||
			 */
 | 
			
		||||
			var defaultValueAttributes = typeof(TaxRate).GetProperty(nameof(TaxRate.Status))!.GetCustomAttributes<DefaultAttribute>(true);
 | 
			
		||||
 | 
			
		||||
			if (defaultValueAttributes.Any())
 | 
			
		||||
			{
 | 
			
		||||
				var values = defaultValueAttributes.Select(e => (Status)e.Value!).ToList();
 | 
			
		||||
 | 
			
		||||
				if (values.Any(e => e == Status.Enabled))
 | 
			
		||||
					expectedStatuses.Add(0);
 | 
			
		||||
			}
 | 
			
		||||
			/*
 | 
			
		||||
			 * Required services
 | 
			
		||||
			 */
 | 
			
		||||
			var actualStatus = (Status)0;
 | 
			
		||||
 | 
			
		||||
			var instanceFaker = new InstanceFaker<Insert>();
 | 
			
		||||
 | 
			
		||||
			var databaseContextProviderFake = instanceFaker.GetMock<IStorageProvider>()!;
 | 
			
		||||
 | 
			
		||||
			_ = databaseContextProviderFake
 | 
			
		||||
				.Setup(e => e.Open<TaxRate>().Update(It.IsAny<TaxRate>()))
 | 
			
		||||
				.Callback<TaxRate>(e => actualStatus = e.Status)
 | 
			
		||||
				.ReturnsAsync(new TaxRate { Id = 1 });
 | 
			
		||||
			/*
 | 
			
		||||
			 * Arguments play no role for this test
 | 
			
		||||
			 */
 | 
			
		||||
			var args = new InsertTaxRateArgs();
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Test
 | 
			
		||||
			 */
 | 
			
		||||
			var serviceFunction = instanceFaker.Instance;
 | 
			
		||||
			var result = await serviceFunction.Invoke(args);
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Assert
 | 
			
		||||
			 */
 | 
			
		||||
			databaseContextProviderFake.Verify(e => e.Open<TaxRate>().Update(It.IsAny<TaxRate>()), Times.Exactly(1));
 | 
			
		||||
			Assert.IsTrue(expectedStatuses.Contains(actualStatus));
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	[TestClass]
 | 
			
		||||
	public class OnCommit
 | 
			
		||||
	{
 | 
			
		||||
		[TestMethod("Insert commit invokes inserted event exactly once")]
 | 
			
		||||
		public async Task Insert_Commit_InvokedInserted_ExactlyOnce()
 | 
			
		||||
		{
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Setup
 | 
			
		||||
			 */
 | 
			
		||||
			var instanceFaker = new InstanceFaker<Insert>();
 | 
			
		||||
 | 
			
		||||
			var taxRateCacheFake = instanceFaker.GetMock<ITaxRateCache>()!;
 | 
			
		||||
 | 
			
		||||
			_ = taxRateCacheFake.Setup(e => e.Refresh(It.IsAny<int>()));
 | 
			
		||||
 | 
			
		||||
			var eventServiceFake = instanceFaker.GetMock<IEventService>()!;
 | 
			
		||||
 | 
			
		||||
			_ = eventServiceFake.Setup(e => e.Enqueue(It.IsAny<ITaxRateService?>(), ServiceEvents.Inserted, It.IsAny<int>()));
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Test
 | 
			
		||||
			 */
 | 
			
		||||
			var serviceFunction = instanceFaker.Instance;
 | 
			
		||||
			await ((ITransactionClient)serviceFunction).Commit();
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Assert
 | 
			
		||||
			 */
 | 
			
		||||
			eventServiceFake.Verify(e => e.Enqueue(It.IsAny<ITaxRateService?>(), ServiceEvents.Inserted, It.IsAny<int>()), Times.Exactly(1));
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		[TestMethod("Insert commit refreshes cache exactly once")]
 | 
			
		||||
		public async Task Insert_Commit_RefreshesCache_ExactlyOnce()
 | 
			
		||||
		{
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Setup
 | 
			
		||||
			 */
 | 
			
		||||
			var instanceFaker = new InstanceFaker<Insert>();
 | 
			
		||||
 | 
			
		||||
			var taxRateCacheFake = instanceFaker.GetMock<ITaxRateCache>()!;
 | 
			
		||||
 | 
			
		||||
			_ = taxRateCacheFake.Setup(e => e.Refresh(It.IsAny<int>()));
 | 
			
		||||
 | 
			
		||||
			var eventServiceFake = instanceFaker.GetMock<IEventService>()!;
 | 
			
		||||
 | 
			
		||||
			_ = eventServiceFake.Setup(e => e.Enqueue(It.IsAny<ITaxRateService?>(), ServiceEvents.Inserted, It.IsAny<int>()));
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Test
 | 
			
		||||
			 */
 | 
			
		||||
			var serviceFunction = instanceFaker.Instance;
 | 
			
		||||
			await ((ITransactionClient)serviceFunction).Commit();
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Assert
 | 
			
		||||
			 */
 | 
			
		||||
			taxRateCacheFake.Verify(e => e.Refresh(It.IsAny<int>()), Times.Exactly(1));
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		[TestMethod("Insert commit fires inserted event after notifying cache")]
 | 
			
		||||
		public async Task Insert_Commit_InvokedInsertedEvent_AfterNotifyingCache()
 | 
			
		||||
		{
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Setup			
 | 
			
		||||
			 * Mockbehavior string ensures no unplanned functions are called on the services.
 | 
			
		||||
			 * If you receive an error about function calls not properly set up, and function
 | 
			
		||||
			 * calls look ok, it's probably the sequence throwing the exception. This is a
 | 
			
		||||
			 * failure in user code, not the test.
 | 
			
		||||
			*/
 | 
			
		||||
			var sequence = new MockSequence();
 | 
			
		||||
 | 
			
		||||
			var instanceFaker = new InstanceFaker<Insert>();
 | 
			
		||||
 | 
			
		||||
			var taxRateCacheFake = instanceFaker.GetMock<ITaxRateCache>()!;
 | 
			
		||||
 | 
			
		||||
			_ = taxRateCacheFake
 | 
			
		||||
				.InSequence(sequence)
 | 
			
		||||
				.Setup(e => e.Refresh(It.IsAny<int>()));
 | 
			
		||||
 | 
			
		||||
			var eventServiceFake = instanceFaker.GetMock<IEventService>()!;
 | 
			
		||||
 | 
			
		||||
			_ = eventServiceFake
 | 
			
		||||
				.InSequence(sequence)
 | 
			
		||||
				.Setup(e => e.Enqueue(It.IsAny<ITaxRateService?>(), ServiceEvents.Inserted, It.IsAny<int>()));
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Test
 | 
			
		||||
			 */
 | 
			
		||||
			var serviceFunction = instanceFaker.Instance;
 | 
			
		||||
			await ((ITransactionClient)serviceFunction).Commit();
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Assert
 | 
			
		||||
			 */
 | 
			
		||||
			taxRateCacheFake.Verify(e => e.Refresh(It.IsAny<int>()), Times.Exactly(1));
 | 
			
		||||
			eventServiceFake.Verify(e => e.Enqueue(It.IsAny<ITaxRateService?>(), ServiceEvents.Inserted, It.IsAny<int>()));
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										242
									
								
								tests/Connected.Common.Types.Tests/TaxRates/Ops/LookupTests.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										242
									
								
								tests/Connected.Common.Types.Tests/TaxRates/Ops/LookupTests.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,242 @@
 | 
			
		||||
using System.Collections.Immutable;
 | 
			
		||||
using System.Data;
 | 
			
		||||
using Connected.Common.Types.TaxRates;
 | 
			
		||||
using Connected.Entities;
 | 
			
		||||
using Connected.ServiceModel;
 | 
			
		||||
using Lookup = Connected.Common.Types.TaxRates.TaxRateOps.Lookup;
 | 
			
		||||
 | 
			
		||||
namespace Common.Types.TaxRates.Ops;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
[TestClass]
 | 
			
		||||
public class LookupTests
 | 
			
		||||
{
 | 
			
		||||
	[TestMethod("Lookup invoke returns ImmutableList when set is empty")]
 | 
			
		||||
	public async Task Lookup_Invoke_ReturnsImmutableList_WhenEmpty()
 | 
			
		||||
	{
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Setup
 | 
			
		||||
		*/
 | 
			
		||||
		var dataSet = TaxRateSamples.GetEmptyTaxRateSet();
 | 
			
		||||
 | 
			
		||||
		var instanceFaker = new InstanceFaker<Lookup>();
 | 
			
		||||
 | 
			
		||||
		var taxRateCacheFake = instanceFaker.GetMock<ITaxRateCache>()!;
 | 
			
		||||
 | 
			
		||||
		taxRateCacheFake.SetupIEnumerable(dataSet!);
 | 
			
		||||
 | 
			
		||||
		var args = new PrimaryKeyListArgs<int>();
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Test
 | 
			
		||||
		 */
 | 
			
		||||
		var serviceFunction = instanceFaker.Instance;
 | 
			
		||||
		var result = await serviceFunction.Invoke(args);
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Assert
 | 
			
		||||
		 */
 | 
			
		||||
		Assert.IsNotNull(result);
 | 
			
		||||
		Assert.IsTrue(result.GetType().IsAssignableToGenericType(typeof(ImmutableList<>)));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	[TestMethod("Lookup invoke returns empty set when argument list is empty")]
 | 
			
		||||
	public async Task Lookup_Invoke_ReturnsEmptyImmutableList_WhenArgumentListEmpty()
 | 
			
		||||
	{
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Setup
 | 
			
		||||
		 */
 | 
			
		||||
		var dataSet = TaxRateSamples.CombinedTaxRateSet;
 | 
			
		||||
 | 
			
		||||
		var instanceFaker = new InstanceFaker<Lookup>();
 | 
			
		||||
 | 
			
		||||
		var taxRateCacheFake = instanceFaker.GetMock<ITaxRateCache>()!;
 | 
			
		||||
 | 
			
		||||
		taxRateCacheFake.SetupIEnumerable(dataSet!);
 | 
			
		||||
 | 
			
		||||
		var args = new PrimaryKeyListArgs<int>
 | 
			
		||||
		{
 | 
			
		||||
			IdList = new List<int>()
 | 
			
		||||
		};
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Test
 | 
			
		||||
		 */
 | 
			
		||||
		var serviceFunction = instanceFaker.Instance;
 | 
			
		||||
		var result = await serviceFunction.Invoke(args);
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Assert
 | 
			
		||||
		 */
 | 
			
		||||
		Assert.IsNotNull(result);
 | 
			
		||||
		Assert.IsTrue(result.Count == 0);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	[TestMethod("Lookup invoke returns empty set when argument list is invalid")]
 | 
			
		||||
	public async Task Lookup_Invoke_ReturnsEmptyImmutableList_WhenArgumentListInvalid()
 | 
			
		||||
	{
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Setup
 | 
			
		||||
		 */
 | 
			
		||||
		var dataSet = TaxRateSamples.CombinedTaxRateSet;
 | 
			
		||||
 | 
			
		||||
		var instanceFaker = new InstanceFaker<Lookup>();
 | 
			
		||||
 | 
			
		||||
		var taxRateCacheFake = instanceFaker.GetMock<ITaxRateCache>()!;
 | 
			
		||||
 | 
			
		||||
		taxRateCacheFake.SetupIEnumerable(dataSet!);
 | 
			
		||||
 | 
			
		||||
		var args = new PrimaryKeyListArgs<int>();
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Test
 | 
			
		||||
		 */
 | 
			
		||||
		var serviceFunction = new Lookup(taxRateCacheFake.Object);
 | 
			
		||||
		var result = await serviceFunction.Invoke(args);
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Assert
 | 
			
		||||
		 */
 | 
			
		||||
		Assert.IsNotNull(result);
 | 
			
		||||
		Assert.IsTrue(result.Count == 0);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	[TestMethod("Lookup invoke returns correct set when argument list is valid")]
 | 
			
		||||
	public async Task Lookup_Invoke_ReturnsCorrectSet_WhenArgumentListValid()
 | 
			
		||||
	{
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Setup
 | 
			
		||||
		 */
 | 
			
		||||
		var dataSet = TaxRateSamples.CombinedTaxRateSet;
 | 
			
		||||
 | 
			
		||||
		var instanceFaker = new InstanceFaker<Lookup>();
 | 
			
		||||
 | 
			
		||||
		var taxRateCacheFake = instanceFaker.GetMock<ITaxRateCache>()!;
 | 
			
		||||
 | 
			
		||||
		taxRateCacheFake.SetupIEnumerable(dataSet!);
 | 
			
		||||
 | 
			
		||||
		var args = new PrimaryKeyListArgs<int>
 | 
			
		||||
		{
 | 
			
		||||
			IdList = new[]
 | 
			
		||||
			{
 | 
			
		||||
				TaxRateSamples.NotModifiedEnabled.Id,
 | 
			
		||||
				TaxRateSamples.NewEnabled.Id,
 | 
			
		||||
				TaxRateSamples.NotModifiedDisabled.Id
 | 
			
		||||
			}
 | 
			
		||||
		};
 | 
			
		||||
 | 
			
		||||
		var expected = new[]
 | 
			
		||||
		{
 | 
			
		||||
			TaxRateSamples.NotModifiedEnabled,
 | 
			
		||||
			TaxRateSamples.NewEnabled,
 | 
			
		||||
			TaxRateSamples.NotModifiedDisabled
 | 
			
		||||
		};
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Test
 | 
			
		||||
		 */
 | 
			
		||||
		var serviceFunction = instanceFaker.Instance;
 | 
			
		||||
		var result = await serviceFunction.Invoke(args);
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Assert
 | 
			
		||||
		 */
 | 
			
		||||
		Assert.IsNotNull(result);
 | 
			
		||||
		Assert.IsTrue(result.SequenceEquivalent(expected));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	[TestMethod("Lookup invoke returns correct set when argument list contains deleted values")]
 | 
			
		||||
	public async Task Lookup_Invoke_ReturnsCorrectSet_WhenArgumentListContainsDeletedValues()
 | 
			
		||||
	{
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Setup
 | 
			
		||||
		*/
 | 
			
		||||
		var dataSet = TaxRateSamples.CombinedTaxRateSet;
 | 
			
		||||
 | 
			
		||||
		var instanceFaker = new InstanceFaker<Lookup>();
 | 
			
		||||
 | 
			
		||||
		var taxRateCacheFake = instanceFaker.GetMock<ITaxRateCache>()!;
 | 
			
		||||
 | 
			
		||||
		taxRateCacheFake.SetupIEnumerable(dataSet!);
 | 
			
		||||
 | 
			
		||||
		var args = new PrimaryKeyListArgs<int>
 | 
			
		||||
		{
 | 
			
		||||
			IdList = new[]
 | 
			
		||||
			{
 | 
			
		||||
				TaxRateSamples.NotModifiedEnabled.Id,
 | 
			
		||||
				TaxRateSamples.DeletedEnabled.Id
 | 
			
		||||
			}
 | 
			
		||||
		};
 | 
			
		||||
 | 
			
		||||
		var expected = new[]
 | 
			
		||||
		{
 | 
			
		||||
			TaxRateSamples.NotModifiedEnabled
 | 
			
		||||
		};
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Test
 | 
			
		||||
		 */
 | 
			
		||||
		var serviceFunction = instanceFaker.Instance;
 | 
			
		||||
		var result = await serviceFunction.Invoke(args);
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Assert
 | 
			
		||||
		 */
 | 
			
		||||
		Assert.IsNotNull(result);
 | 
			
		||||
		Assert.IsTrue(result.SequenceEquivalent(expected));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	[TestMethod("Lookup invoke returns all entries when no entries are deleted")]
 | 
			
		||||
	public async Task Lookup_Invoke_ReturnsAllEntries_WhenNoEntriesAreDeleted()
 | 
			
		||||
	{
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Setup
 | 
			
		||||
		 */
 | 
			
		||||
		var dataSet = TaxRateSamples.GetTaxRates(State.Default)
 | 
			
		||||
			.Union(TaxRateSamples.GetTaxRates(State.New));
 | 
			
		||||
 | 
			
		||||
		var instanceFaker = new InstanceFaker<Lookup>();
 | 
			
		||||
 | 
			
		||||
		var taxRateCacheFake = instanceFaker.GetMock<ITaxRateCache>()!;
 | 
			
		||||
 | 
			
		||||
		taxRateCacheFake.SetupIEnumerable(dataSet!);
 | 
			
		||||
 | 
			
		||||
		var args = new PrimaryKeyListArgs<int>
 | 
			
		||||
		{
 | 
			
		||||
			IdList = dataSet.Select(e => e.Id)
 | 
			
		||||
		};
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Test
 | 
			
		||||
		 */
 | 
			
		||||
		var serviceFunction = instanceFaker.Instance;
 | 
			
		||||
		var result = await serviceFunction.Invoke(args);
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Assert
 | 
			
		||||
		 */
 | 
			
		||||
		Assert.IsNotNull(result);
 | 
			
		||||
		Assert.IsTrue(result.SequenceEqual(dataSet));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	[TestMethod("Lookup invoke returns only non deleted entries when entries are deleted")]
 | 
			
		||||
	public async Task Lookup_Invoke_ReturnsNonDeletedOnly_WhenEntriesAreDeleted()
 | 
			
		||||
	{
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Setup
 | 
			
		||||
		 */
 | 
			
		||||
		var expectedDataSet = TaxRateSamples.GetTaxRates(State.Default)
 | 
			
		||||
			.Union(TaxRateSamples.GetTaxRates(State.New));
 | 
			
		||||
 | 
			
		||||
		var completeDataSet = expectedDataSet.Union(TaxRateSamples.GetTaxRates(State.Deleted));
 | 
			
		||||
 | 
			
		||||
		var instanceFaker = new InstanceFaker<Lookup>();
 | 
			
		||||
 | 
			
		||||
		var taxRateCacheFake = instanceFaker.GetMock<ITaxRateCache>()!;
 | 
			
		||||
 | 
			
		||||
		taxRateCacheFake.SetupIEnumerable(completeDataSet);
 | 
			
		||||
 | 
			
		||||
		var args = new PrimaryKeyListArgs<int>
 | 
			
		||||
		{
 | 
			
		||||
			IdList = completeDataSet.Select(e => e.Id)
 | 
			
		||||
		};
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Test
 | 
			
		||||
		 */
 | 
			
		||||
		var serviceFunction = new Lookup(taxRateCacheFake.Object);
 | 
			
		||||
		var result = await serviceFunction.Invoke(args);
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Assert
 | 
			
		||||
		 */
 | 
			
		||||
		Assert.IsNotNull(result);
 | 
			
		||||
		Assert.IsTrue(result.SequenceEqual(expectedDataSet));
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,97 @@
 | 
			
		||||
using System.Collections.Immutable;
 | 
			
		||||
using Connected.Common.Types.TaxRates;
 | 
			
		||||
using Connected.Entities;
 | 
			
		||||
using Connected.ServiceModel;
 | 
			
		||||
using static Connected.Common.Types.TaxRates.TaxRateOps;
 | 
			
		||||
 | 
			
		||||
namespace Common.Types.TaxRates.Ops;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
[TestClass]
 | 
			
		||||
public class QueryTests
 | 
			
		||||
{
 | 
			
		||||
	[TestMethod("Query invoke returns ImmutableList when set is empty")]
 | 
			
		||||
	public async Task Query_Invoke_ReturnsImmutableList_WhenEmpty()
 | 
			
		||||
	{
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Setup
 | 
			
		||||
		 */
 | 
			
		||||
		var dataSet = TaxRateSamples.GetEmptyTaxRateSet();
 | 
			
		||||
 | 
			
		||||
		var instanceFaker = new InstanceFaker<Query>();
 | 
			
		||||
 | 
			
		||||
		var taxRateCacheFake = instanceFaker.GetMock<ITaxRateCache>()!;
 | 
			
		||||
 | 
			
		||||
		taxRateCacheFake.SetupIEnumerable(dataSet!);
 | 
			
		||||
 | 
			
		||||
		var args = QueryArgs.Default;
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Test
 | 
			
		||||
		 */
 | 
			
		||||
		var serviceFunction = instanceFaker.Instance;
 | 
			
		||||
		var result = await serviceFunction.Invoke(args);
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Assert
 | 
			
		||||
		 */
 | 
			
		||||
		Assert.IsNotNull(result);
 | 
			
		||||
		Assert.IsTrue(result.GetType().IsAssignableToGenericType(typeof(ImmutableList<>)));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	[TestMethod("Query invoke returns all entries when no entries are deleted")]
 | 
			
		||||
	public async Task Query_Invoke_ReturnsAllEntries_WhenNoEntriesAreDeleted()
 | 
			
		||||
	{
 | 
			
		||||
		/*
 | 
			
		||||
		 * Setup
 | 
			
		||||
		 */
 | 
			
		||||
		var dataSet = TaxRateSamples.GetTaxRates(State.Default)
 | 
			
		||||
			.Union(TaxRateSamples.GetTaxRates(State.New));
 | 
			
		||||
 | 
			
		||||
		var instanceFaker = new InstanceFaker<Query>();
 | 
			
		||||
 | 
			
		||||
		var taxRateCacheFake = instanceFaker.GetMock<ITaxRateCache>()!;
 | 
			
		||||
 | 
			
		||||
		taxRateCacheFake.SetupIEnumerable(dataSet!);
 | 
			
		||||
 | 
			
		||||
		var args = Dto.Empty;
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Test
 | 
			
		||||
		 */
 | 
			
		||||
		var serviceFunction = instanceFaker.Instance;
 | 
			
		||||
		var result = await serviceFunction.Invoke(QueryArgs.Default);
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Assert
 | 
			
		||||
		 */
 | 
			
		||||
		Assert.IsNotNull(result);
 | 
			
		||||
		Assert.IsTrue(result.SequenceEqual(dataSet));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	[TestMethod("Query invoke returns only non deleted entries when entries are deleted")]
 | 
			
		||||
	public async Task Query_Invoke_ReturnsNonDeletedOnly_WhenEntriesAreDeleted()
 | 
			
		||||
	{
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Setup
 | 
			
		||||
		*/
 | 
			
		||||
		var expectedDataSet = TaxRateSamples.GetTaxRates(State.Default)
 | 
			
		||||
			.Union(TaxRateSamples.GetTaxRates(State.New));
 | 
			
		||||
 | 
			
		||||
		var deletedDataSet = expectedDataSet.Union(TaxRateSamples.GetTaxRates(State.Deleted));
 | 
			
		||||
 | 
			
		||||
		var instanceFaker = new InstanceFaker<Query>();
 | 
			
		||||
 | 
			
		||||
		var taxRateCacheFake = instanceFaker.GetMock<ITaxRateCache>()!;
 | 
			
		||||
 | 
			
		||||
		taxRateCacheFake.SetupIEnumerable(deletedDataSet);
 | 
			
		||||
 | 
			
		||||
		var args = Dto.Empty;
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Test
 | 
			
		||||
		 */
 | 
			
		||||
		var serviceFunction = instanceFaker.Instance;
 | 
			
		||||
		var result = await serviceFunction.Invoke(QueryArgs.Default);
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Assert
 | 
			
		||||
		 */
 | 
			
		||||
		Assert.IsNotNull(result);
 | 
			
		||||
		Assert.IsTrue(result.SequenceEqual(expectedDataSet));
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,177 @@
 | 
			
		||||
using Connected.Common.Types.TaxRates;
 | 
			
		||||
using Connected.Entities;
 | 
			
		||||
using static Connected.Common.Types.TaxRates.TaxRateOps;
 | 
			
		||||
 | 
			
		||||
namespace Common.Types.TaxRates.Ops;
 | 
			
		||||
 | 
			
		||||
[TestClass]
 | 
			
		||||
public class SelectByRateTests
 | 
			
		||||
{
 | 
			
		||||
	private static IEnumerable<object[]> TaxRates => TaxRateSamples.CombinedTaxRateSet
 | 
			
		||||
		.Select(e => new object[] { e.Rate, e })
 | 
			
		||||
		.ToList();
 | 
			
		||||
 | 
			
		||||
	private static IEnumerable<object[]> DeletedTaxRates => TaxRateSamples.CombinedTaxRateSet
 | 
			
		||||
		.Where(e => e.State == State.Deleted)
 | 
			
		||||
		.Select(e => new object[] { e.Rate, e })
 | 
			
		||||
		.ToList();
 | 
			
		||||
 | 
			
		||||
	[TestMethod("SelectByRate invoke returns null when rate does not exist")]
 | 
			
		||||
	public async Task Select_Invoke_ReturnsNull_WhenRateInvalid()
 | 
			
		||||
	{
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Setup
 | 
			
		||||
		 */
 | 
			
		||||
		var dataSet = TaxRateSamples.CombinedTaxRateSet;
 | 
			
		||||
 | 
			
		||||
		var instanceFaker = new InstanceFaker<SelectByRate>();
 | 
			
		||||
 | 
			
		||||
		var taxRateCacheFake = instanceFaker.GetMock<ITaxRateCache>()!;
 | 
			
		||||
 | 
			
		||||
		taxRateCacheFake.SetupIEnumerable(dataSet);
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Ensure id is always out of range 
 | 
			
		||||
		 */
 | 
			
		||||
		var outOfRangeRate = dataSet.Select(e => e.Rate).DefaultIfEmpty(0).Max() + 1;
 | 
			
		||||
 | 
			
		||||
		var args = new TaxRateArgs
 | 
			
		||||
		{
 | 
			
		||||
			Rate = outOfRangeRate
 | 
			
		||||
		};
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Test
 | 
			
		||||
		 */
 | 
			
		||||
		var serviceFunction = instanceFaker.Instance;
 | 
			
		||||
		var result = await serviceFunction.Invoke(args);
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Assert
 | 
			
		||||
		 */
 | 
			
		||||
		Assert.IsNull(result);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	[TestMethod("SelectByRate invoke returns null when rate not specified")]
 | 
			
		||||
	public async Task Select_Invoke_ReturnsNull_WhenRateNotSpecified()
 | 
			
		||||
	{
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Setup
 | 
			
		||||
		 */
 | 
			
		||||
		var dataSet = TaxRateSamples.CombinedTaxRateSet;
 | 
			
		||||
 | 
			
		||||
		var instanceFaker = new InstanceFaker<SelectByRate>();
 | 
			
		||||
 | 
			
		||||
		var taxRateCacheFake = instanceFaker.GetMock<ITaxRateCache>()!;
 | 
			
		||||
 | 
			
		||||
		taxRateCacheFake.SetupIEnumerable(dataSet);
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Ensure id is always out of range 
 | 
			
		||||
		 */
 | 
			
		||||
		var args = new TaxRateArgs();
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Test
 | 
			
		||||
		 */
 | 
			
		||||
		var serviceFunction = instanceFaker.Instance;
 | 
			
		||||
		var result = await serviceFunction.Invoke(args);
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Assert
 | 
			
		||||
		 */
 | 
			
		||||
		Assert.IsNull(result);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	[TestMethod("SelectByRate invoke returns null when set is empty")]
 | 
			
		||||
	public async Task Select_Invoke_ReturnsNull_WhenSetEmpty()
 | 
			
		||||
	{
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Setup
 | 
			
		||||
		 */
 | 
			
		||||
		var dataSet = TaxRateSamples.GetEmptyTaxRateSet();
 | 
			
		||||
 | 
			
		||||
		var instanceFaker = new InstanceFaker<SelectByRate>();
 | 
			
		||||
 | 
			
		||||
		var taxRateCacheFake = instanceFaker.GetMock<ITaxRateCache>()!;
 | 
			
		||||
 | 
			
		||||
		taxRateCacheFake.SetupIEnumerable(dataSet);
 | 
			
		||||
 | 
			
		||||
		var args = new TaxRateArgs
 | 
			
		||||
		{
 | 
			
		||||
			Rate = 1
 | 
			
		||||
		};
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Test
 | 
			
		||||
		 */
 | 
			
		||||
		var serviceFunction = instanceFaker.Instance;
 | 
			
		||||
		var result = await serviceFunction.Invoke(args);
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Assert
 | 
			
		||||
		 */
 | 
			
		||||
		Assert.IsNull(result);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	[TestMethod("SelectByRate invoke returns value when rate exists")]
 | 
			
		||||
	[DynamicData(nameof(TaxRates))]
 | 
			
		||||
	public async Task Select_Invoke_ReturnsValue_WhenRateValid(float rate, ITaxRate expected)
 | 
			
		||||
	{
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Setup
 | 
			
		||||
		 */
 | 
			
		||||
		var dataSet = TaxRates
 | 
			
		||||
			.Select(e => e[1] as TaxRate)
 | 
			
		||||
			.ToList();
 | 
			
		||||
 | 
			
		||||
		var instanceFaker = new InstanceFaker<SelectByRate>();
 | 
			
		||||
 | 
			
		||||
		var taxRateCacheFake = instanceFaker.GetMock<ITaxRateCache>()!;
 | 
			
		||||
 | 
			
		||||
		taxRateCacheFake.SetupIEnumerable(dataSet);
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Ensure id is always out of range 
 | 
			
		||||
		 */
 | 
			
		||||
		var args = new TaxRateArgs
 | 
			
		||||
		{
 | 
			
		||||
			Rate = rate
 | 
			
		||||
		};
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Test
 | 
			
		||||
		 */
 | 
			
		||||
		var serviceFunction = instanceFaker.Instance;
 | 
			
		||||
		var result = await serviceFunction.Invoke(args);
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Assert
 | 
			
		||||
		 */
 | 
			
		||||
		Assert.AreSame(result, expected);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	[TestMethod("Select invoke returns null value when rate exists but is deleted")]
 | 
			
		||||
	[DynamicData(nameof(DeletedTaxRates))]
 | 
			
		||||
	public async Task Select_Invoke_ReturnsNull_WhenRateValidAndDeleted(float rate)
 | 
			
		||||
	{
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Setup
 | 
			
		||||
		 */
 | 
			
		||||
		var dataSet = TaxRates
 | 
			
		||||
			.Select(e => e[1] as TaxRate)
 | 
			
		||||
			.ToList();
 | 
			
		||||
 | 
			
		||||
		var instanceFaker = new InstanceFaker<SelectByRate>();
 | 
			
		||||
 | 
			
		||||
		var taxRateCacheFake = instanceFaker.GetMock<ITaxRateCache>()!;
 | 
			
		||||
 | 
			
		||||
		taxRateCacheFake.SetupIEnumerable(dataSet);
 | 
			
		||||
		/*
 | 
			
		||||
		 * Ensure id is always out of range 
 | 
			
		||||
		 */
 | 
			
		||||
		var args = new TaxRateArgs
 | 
			
		||||
		{
 | 
			
		||||
			Rate = rate
 | 
			
		||||
		};
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Test
 | 
			
		||||
		 */
 | 
			
		||||
		var serviceFunction = instanceFaker.Instance;
 | 
			
		||||
		var result = await serviceFunction.Invoke(args);
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Assert
 | 
			
		||||
		 */
 | 
			
		||||
		Assert.IsNull(result);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										140
									
								
								tests/Connected.Common.Types.Tests/TaxRates/Ops/SelectTests.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										140
									
								
								tests/Connected.Common.Types.Tests/TaxRates/Ops/SelectTests.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,140 @@
 | 
			
		||||
using Connected.Common.Types.TaxRates;
 | 
			
		||||
using Connected.Entities;
 | 
			
		||||
using Connected.ServiceModel;
 | 
			
		||||
using static Connected.Common.Types.TaxRates.TaxRateOps;
 | 
			
		||||
 | 
			
		||||
namespace Common.Types.TaxRates.Ops;
 | 
			
		||||
 | 
			
		||||
[TestClass]
 | 
			
		||||
public class SelectTests
 | 
			
		||||
{
 | 
			
		||||
	private static IEnumerable<object[]> TaxRates => TaxRateSamples.CombinedTaxRateSet
 | 
			
		||||
		.Select(e => new object[] { e.Id, e })
 | 
			
		||||
		.ToList();
 | 
			
		||||
	private static IEnumerable<object[]> DeletedTaxRates => TaxRateSamples.CombinedTaxRateSet
 | 
			
		||||
		.Where(e => e.State == State.Deleted)
 | 
			
		||||
		.Select(e => new object[] { e.Id, e })
 | 
			
		||||
		.ToList();
 | 
			
		||||
 | 
			
		||||
	[TestMethod("Select invoke returns null when id does not exist")]
 | 
			
		||||
	public async Task Select_Invoke_ReturnsNull_WhenIdInvalid()
 | 
			
		||||
	{
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Setup
 | 
			
		||||
		 */
 | 
			
		||||
		var dataSet = TaxRateSamples.CombinedTaxRateSet;
 | 
			
		||||
 | 
			
		||||
		var instanceFaker = new InstanceFaker<Select>();
 | 
			
		||||
 | 
			
		||||
		var taxRateCacheFake = instanceFaker.GetMock<ITaxRateCache>()!;
 | 
			
		||||
 | 
			
		||||
		_ = taxRateCacheFake
 | 
			
		||||
			.As<IEnumerable<TaxRate>>()
 | 
			
		||||
			.Setup(e => e.GetEnumerator())
 | 
			
		||||
			.Returns(dataSet.GetEnumerator());
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Ensure id is always out of range 
 | 
			
		||||
		 */
 | 
			
		||||
		var outOfRangeId = dataSet.Select(e => e.Id).DefaultIfEmpty(0).Max() + 1;
 | 
			
		||||
		var args = new PrimaryKeyArgs<int>(outOfRangeId);
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Test
 | 
			
		||||
		 */
 | 
			
		||||
		var serviceFunction = instanceFaker.Instance;
 | 
			
		||||
		var result = await serviceFunction.Invoke(args);
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Assert
 | 
			
		||||
		*/
 | 
			
		||||
		Assert.IsNull(result);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	[TestMethod("Select invoke returns null when set is empty")]
 | 
			
		||||
	public async Task Select_Invoke_ReturnsNull_WhenSetEmpty()
 | 
			
		||||
	{
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Setup
 | 
			
		||||
		 */
 | 
			
		||||
		var dataSet = TaxRateSamples.GetEmptyTaxRateSet();
 | 
			
		||||
 | 
			
		||||
		var instanceFaker = new InstanceFaker<Select>();
 | 
			
		||||
 | 
			
		||||
		var taxRateCacheFake = instanceFaker.GetMock<ITaxRateCache>()!;
 | 
			
		||||
 | 
			
		||||
		_ = taxRateCacheFake
 | 
			
		||||
			.As<IEnumerable<TaxRate>>()
 | 
			
		||||
			.Setup(e => e.GetEnumerator())
 | 
			
		||||
			.Returns(dataSet.GetEnumerator());
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Ensure id is always out of range 
 | 
			
		||||
		 */
 | 
			
		||||
		var args = new PrimaryKeyArgs<int>(1);
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Test
 | 
			
		||||
		*/
 | 
			
		||||
		var serviceFunction = instanceFaker.Instance;
 | 
			
		||||
		var result = await serviceFunction.Invoke(args);
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Assert
 | 
			
		||||
		 */
 | 
			
		||||
		Assert.IsNull(result);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	[TestMethod("Select invoke returns value when id exists")]
 | 
			
		||||
	[DynamicData(nameof(TaxRates))]
 | 
			
		||||
	public async Task Select_Invoke_ReturnsValue_WhenIdValid(int id, ITaxRate expected)
 | 
			
		||||
	{
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Setup
 | 
			
		||||
		 */
 | 
			
		||||
		var dataSet = TaxRates.Select(e => e[1] as TaxRate).ToList();
 | 
			
		||||
 | 
			
		||||
		var instanceFaker = new InstanceFaker<Select>();
 | 
			
		||||
 | 
			
		||||
		var taxRateCacheFake = instanceFaker.GetMock<ITaxRateCache>()!;
 | 
			
		||||
 | 
			
		||||
		taxRateCacheFake.SetupIEnumerable(dataSet!);
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Ensure id is always out of range 
 | 
			
		||||
		 */
 | 
			
		||||
		var args = new PrimaryKeyArgs<int>(id);
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Test
 | 
			
		||||
		 */
 | 
			
		||||
		var serviceFunction = instanceFaker.Instance;
 | 
			
		||||
		var result = await serviceFunction.Invoke(args);
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Assert
 | 
			
		||||
		 */
 | 
			
		||||
		Assert.AreSame(result, expected);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	[TestMethod("Select invoke returns deleted value when id exists")]
 | 
			
		||||
	[DynamicData(nameof(DeletedTaxRates))]
 | 
			
		||||
	public async Task Select_Invoke_ReturnsDeletedValue_WhenIdValid(int id, ITaxRate expected)
 | 
			
		||||
	{
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Setup
 | 
			
		||||
		 */
 | 
			
		||||
		var dataSet = TaxRates.Select(e => e[1] as TaxRate).ToList();
 | 
			
		||||
 | 
			
		||||
		var instanceFaker = new InstanceFaker<Select>();
 | 
			
		||||
 | 
			
		||||
		var taxRateCacheFake = instanceFaker.GetMock<ITaxRateCache>()!;
 | 
			
		||||
 | 
			
		||||
		taxRateCacheFake.SetupIEnumerable<TaxRate>(dataSet!);
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Ensure id is always out of range 
 | 
			
		||||
		 */
 | 
			
		||||
		var args = new PrimaryKeyArgs<int>(id);
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Test
 | 
			
		||||
		 */
 | 
			
		||||
		var serviceFunction = instanceFaker.Instance;
 | 
			
		||||
		var result = await serviceFunction.Invoke(args);
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Assert
 | 
			
		||||
		 */
 | 
			
		||||
		Assert.AreSame(result, expected);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -0,0 +1,75 @@
 | 
			
		||||
using Connected.Common.Types.TaxRates;
 | 
			
		||||
using Connected.Entities;
 | 
			
		||||
 | 
			
		||||
namespace Common.Types.TaxRates.Ops;
 | 
			
		||||
 | 
			
		||||
internal class TaxRateSamples
 | 
			
		||||
{
 | 
			
		||||
	internal static IEnumerable<TaxRate> GetEmptyTaxRateSet() => new List<TaxRate> { };
 | 
			
		||||
 | 
			
		||||
	internal static IEnumerable<TaxRate> GetTaxRates(State state) => CombinedTaxRateSet.Where(e => e.State == state);
 | 
			
		||||
 | 
			
		||||
	public static TaxRate NewEnabled = new()
 | 
			
		||||
	{
 | 
			
		||||
		Id = 1,
 | 
			
		||||
		Name = nameof(NewEnabled),
 | 
			
		||||
		Rate = 10,
 | 
			
		||||
		State = State.New,
 | 
			
		||||
		Status = Connected.Data.Status.Enabled
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	public static TaxRate NotModifiedEnabled = new()
 | 
			
		||||
	{
 | 
			
		||||
		Id = 3,
 | 
			
		||||
		Name = nameof(NotModifiedEnabled),
 | 
			
		||||
		Rate = 30,
 | 
			
		||||
		State = State.Default,
 | 
			
		||||
		Status = Connected.Data.Status.Enabled
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	public static TaxRate DeletedEnabled = new()
 | 
			
		||||
	{
 | 
			
		||||
		Id = 4,
 | 
			
		||||
		Name = nameof(DeletedEnabled),
 | 
			
		||||
		Rate = 40,
 | 
			
		||||
		State = State.Deleted,
 | 
			
		||||
		Status = Connected.Data.Status.Enabled
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	public static TaxRate NewDisabled = new()
 | 
			
		||||
	{
 | 
			
		||||
		Id = 5,
 | 
			
		||||
		Name = nameof(NewDisabled),
 | 
			
		||||
		Rate = 50,
 | 
			
		||||
		State = State.New,
 | 
			
		||||
		Status = Connected.Data.Status.Disabled
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	public static TaxRate NotModifiedDisabled = new()
 | 
			
		||||
	{
 | 
			
		||||
		Id = 7,
 | 
			
		||||
		Name = nameof(NotModifiedDisabled),
 | 
			
		||||
		Rate = 70,
 | 
			
		||||
		State = State.Default,
 | 
			
		||||
		Status = Connected.Data.Status.Disabled
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	public static TaxRate DeletedDisabled = new()
 | 
			
		||||
	{
 | 
			
		||||
		Id = 8,
 | 
			
		||||
		Name = nameof(DeletedDisabled),
 | 
			
		||||
		Rate = 80,
 | 
			
		||||
		State = State.Deleted,
 | 
			
		||||
		Status = Connected.Data.Status.Disabled
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	internal static IEnumerable<TaxRate> CombinedTaxRateSet => new List<TaxRate>
 | 
			
		||||
	{
 | 
			
		||||
		NewEnabled,
 | 
			
		||||
		NotModifiedEnabled,
 | 
			
		||||
		DeletedEnabled,
 | 
			
		||||
		NewDisabled,
 | 
			
		||||
		NotModifiedDisabled,
 | 
			
		||||
		DeletedDisabled
 | 
			
		||||
	};
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										315
									
								
								tests/Connected.Common.Types.Tests/TaxRates/Ops/UpdateTests.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										315
									
								
								tests/Connected.Common.Types.Tests/TaxRates/Ops/UpdateTests.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,315 @@
 | 
			
		||||
using System.Data;
 | 
			
		||||
using System.Linq.Expressions;
 | 
			
		||||
using Connected.Common.Types.TaxRates;
 | 
			
		||||
using Connected.Entities.Storage;
 | 
			
		||||
using Connected.Notifications.Events;
 | 
			
		||||
using Connected.ServiceModel;
 | 
			
		||||
using Connected.ServiceModel.Transactions;
 | 
			
		||||
using Moq;
 | 
			
		||||
using static Common.Types.TestUtils;
 | 
			
		||||
using static Connected.Common.Types.TaxRates.TaxRateOps;
 | 
			
		||||
 | 
			
		||||
namespace Common.Types.TaxRates.Ops;
 | 
			
		||||
 | 
			
		||||
public class UpdateTests
 | 
			
		||||
{
 | 
			
		||||
	[TestClass]
 | 
			
		||||
	public class OnInvoke
 | 
			
		||||
	{
 | 
			
		||||
		private static IEnumerable<object[]> TaxRates => TaxRateSamples.CombinedTaxRateSet
 | 
			
		||||
		.Select(e => new object[] { e.Id, e })
 | 
			
		||||
		.ToList();
 | 
			
		||||
 | 
			
		||||
		[TestMethod("Update updates only matching id")]
 | 
			
		||||
		[DynamicData(nameof(TaxRates))]
 | 
			
		||||
		public async Task Update_Invoke_UpdatesMatchingEntity(int id, ITaxRate expected)
 | 
			
		||||
		{
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Setup
 | 
			
		||||
			 */
 | 
			
		||||
			var dataSet = TaxRates.Select(e => e[1] as TaxRate).ToList();
 | 
			
		||||
 | 
			
		||||
			var instanceFaker = new InstanceFaker<Update>();
 | 
			
		||||
 | 
			
		||||
			var databaseContextProviderFake = instanceFaker.GetMock<IStorageProvider>()!;
 | 
			
		||||
 | 
			
		||||
			Expression<Action<IStorageProvider>> updateFunction = (IStorageProvider e) => e.Open<TaxRate>().Update(It.IsAny<TaxRate>(), It.IsAny<UpdateTaxRateArgs>(), It.IsAny<Func<Task<TaxRate?>>>());
 | 
			
		||||
 | 
			
		||||
			TaxRate? updatedEntity = null;
 | 
			
		||||
 | 
			
		||||
			_ = databaseContextProviderFake
 | 
			
		||||
					.Setup(updateFunction)
 | 
			
		||||
					.Callback<TaxRate, UpdateTaxRateArgs, Func<Task<TaxRate>>>((e, _, _) => updatedEntity = e);
 | 
			
		||||
 | 
			
		||||
			var taxRateCacheFake = instanceFaker.GetMock<ITaxRateCache>()!;
 | 
			
		||||
 | 
			
		||||
			taxRateCacheFake.SetupIEnumerable(dataSet);
 | 
			
		||||
 | 
			
		||||
			var args = new UpdateTaxRateArgs
 | 
			
		||||
			{
 | 
			
		||||
				Id = id
 | 
			
		||||
			};
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Test
 | 
			
		||||
			 */
 | 
			
		||||
			var serviceFunction = instanceFaker.Instance;
 | 
			
		||||
			await serviceFunction.Invoke(args);
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Assert
 | 
			
		||||
			 */
 | 
			
		||||
			databaseContextProviderFake.Verify(updateFunction, Times.Once());
 | 
			
		||||
			Assert.AreEqual(expected, updatedEntity);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		[TestMethod("Update throws if tax rate does not exist")]
 | 
			
		||||
		public async Task Update_Invoke_ThrowsException_WhenEntityDoesNotExist()
 | 
			
		||||
		{
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Setup
 | 
			
		||||
			 */
 | 
			
		||||
			var dataSet = TaxRateSamples.GetEmptyTaxRateSet();
 | 
			
		||||
 | 
			
		||||
			var instanceFaker = new InstanceFaker<Update>();
 | 
			
		||||
 | 
			
		||||
			var databaseContextProviderFake = instanceFaker.GetMock<IStorageProvider>()!;
 | 
			
		||||
 | 
			
		||||
			Expression<Action<IStorageProvider>> updateFunction = (IStorageProvider e) => e.Open<TaxRate>().Update(It.IsAny<TaxRate>(), It.IsAny<UpdateTaxRateArgs>(), It.IsAny<Func<Task<TaxRate?>>>());
 | 
			
		||||
 | 
			
		||||
			_ = databaseContextProviderFake.Setup(updateFunction);
 | 
			
		||||
 | 
			
		||||
			var taxRateCacheFake = instanceFaker.GetMock<ITaxRateCache>()!;
 | 
			
		||||
 | 
			
		||||
			taxRateCacheFake.SetupIEnumerable(dataSet);
 | 
			
		||||
			/*
 | 
			
		||||
			 * Generate empty arguments, as the dataset is empty either way
 | 
			
		||||
			 */
 | 
			
		||||
			var args = new UpdateTaxRateArgs();
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Test
 | 
			
		||||
			 */
 | 
			
		||||
			var serviceFunction = instanceFaker.Instance;
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Assert
 | 
			
		||||
			 */
 | 
			
		||||
			await AssertExtensions.Throws(async () => await serviceFunction.Invoke(args));
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		[TestMethod("Update invokes concurrent update exactly once")]
 | 
			
		||||
		public async Task Update_Invoke_InvokesConcurrentUpdate_ExactlyOnce()
 | 
			
		||||
		{
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Setup
 | 
			
		||||
			 */
 | 
			
		||||
			var dataSet = TaxRateSamples.GetEmptyTaxRateSet();
 | 
			
		||||
 | 
			
		||||
			var instanceFaker = new InstanceFaker<Update>();
 | 
			
		||||
 | 
			
		||||
			var databaseContextProviderFake = instanceFaker.GetMock<IStorageProvider>()!;
 | 
			
		||||
 | 
			
		||||
			Expression<Action<IStorageProvider>> updateFunction = (IStorageProvider e) => e.Open<TaxRate>().Update(It.IsAny<TaxRate>(), It.IsAny<UpdateTaxRateArgs>(), It.IsAny<Func<Task<TaxRate?>>>());
 | 
			
		||||
 | 
			
		||||
			_ = databaseContextProviderFake.Setup(updateFunction);
 | 
			
		||||
 | 
			
		||||
			var taxRateCacheFake = instanceFaker.GetMock<ITaxRateCache>()!;
 | 
			
		||||
 | 
			
		||||
			taxRateCacheFake.SetupIEnumerable(dataSet);
 | 
			
		||||
			/*
 | 
			
		||||
			 * Arguments are irrelevant for this test
 | 
			
		||||
			 */
 | 
			
		||||
			var args = new UpdateTaxRateArgs();
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Test
 | 
			
		||||
			 */
 | 
			
		||||
			var serviceFunction = instanceFaker.Instance;
 | 
			
		||||
			await serviceFunction.Invoke(args);
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Assert
 | 
			
		||||
			 */
 | 
			
		||||
			databaseContextProviderFake.Verify(updateFunction, Times.Exactly(1));
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		[TestMethod("Update loads data exactly once when version is current")]
 | 
			
		||||
		public async Task Update_Invoke_LoadsEntityExactlyOnce_WhenVersionIsCurrent()
 | 
			
		||||
		{
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Setup
 | 
			
		||||
			 */
 | 
			
		||||
			var dataSet = TaxRateSamples.GetEmptyTaxRateSet();
 | 
			
		||||
 | 
			
		||||
			var instanceFaker = new InstanceFaker<Update>();
 | 
			
		||||
 | 
			
		||||
			var databaseContextProviderFake = instanceFaker.GetMock<IStorageProvider>()!;
 | 
			
		||||
 | 
			
		||||
			Expression<Action<IStorageProvider>> updateFunction = (IStorageProvider e) => e.Open<TaxRate>().Update(It.IsAny<TaxRate>(), It.IsAny<UpdateTaxRateArgs>(), It.IsAny<Func<Task<TaxRate?>>>());
 | 
			
		||||
 | 
			
		||||
			_ = databaseContextProviderFake.Setup(updateFunction);
 | 
			
		||||
 | 
			
		||||
			var taxRateCacheFake = instanceFaker.GetMock<ITaxRateCache>()!;
 | 
			
		||||
 | 
			
		||||
			taxRateCacheFake.SetupIEnumerable(dataSet);
 | 
			
		||||
 | 
			
		||||
			/*
 | 
			
		||||
			 * Arguments are irrelevant for this test
 | 
			
		||||
			 */
 | 
			
		||||
			var args = new UpdateTaxRateArgs();
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Test
 | 
			
		||||
			 */
 | 
			
		||||
			var serviceFunction = instanceFaker.Instance;
 | 
			
		||||
			await serviceFunction.Invoke(args);
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Assert
 | 
			
		||||
			 */
 | 
			
		||||
			taxRateCacheFake.Verify(e => e.GetEnumerator(), Times.Exactly(1));
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		[TestMethod("Update loads data twice when version is mismatched")]
 | 
			
		||||
		public async Task Update_Invoke_LoadsEntityExactlyTwice_WhenVersionIsMismatched()
 | 
			
		||||
		{
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Setup
 | 
			
		||||
			 */
 | 
			
		||||
			var dataSet = TaxRateSamples.GetEmptyTaxRateSet();
 | 
			
		||||
 | 
			
		||||
			var instanceFaker = new InstanceFaker<Update>();
 | 
			
		||||
 | 
			
		||||
			var databaseContextProviderFake = instanceFaker.GetMock<IStorageProvider>()!;
 | 
			
		||||
 | 
			
		||||
			Expression<Action<IStorageProvider>> updateFunction = (IStorageProvider e) => e.Open<TaxRate>().Update(It.IsAny<TaxRate>(), It.IsAny<UpdateTaxRateArgs>(), It.IsAny<Func<Task<TaxRate?>>>());
 | 
			
		||||
 | 
			
		||||
			/*
 | 
			
		||||
			 * Simulate version mismatch by invoking the retry once
 | 
			
		||||
			 */
 | 
			
		||||
			_ = databaseContextProviderFake.Setup(updateFunction).Callback<TaxRate, UpdateTaxRateArgs, Func<Task<TaxRate?>>>((_, _, e) => e.Invoke());
 | 
			
		||||
 | 
			
		||||
			var taxRateCacheFake = instanceFaker.GetMock<ITaxRateCache>()!;
 | 
			
		||||
 | 
			
		||||
			taxRateCacheFake.SetupIEnumerable(dataSet);
 | 
			
		||||
 | 
			
		||||
			/*
 | 
			
		||||
			 * Arguments are irrelevant for this test
 | 
			
		||||
			 */
 | 
			
		||||
			var args = new UpdateTaxRateArgs();
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Test
 | 
			
		||||
			 */
 | 
			
		||||
			var serviceFunction = instanceFaker.Instance;
 | 
			
		||||
			await serviceFunction.Invoke(args);
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Assert
 | 
			
		||||
			 */
 | 
			
		||||
			taxRateCacheFake.Verify(e => e.GetEnumerator(), Times.Exactly(2));
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	[TestClass]
 | 
			
		||||
	public class OnCommit
 | 
			
		||||
	{
 | 
			
		||||
		[TestMethod("Update commit invokes updated event exactly once")]
 | 
			
		||||
		public async Task Update_Commit_InvokedUpdated_ExactlyOnce()
 | 
			
		||||
		{
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Setup
 | 
			
		||||
			 */
 | 
			
		||||
			var instanceFaker = new InstanceFaker<Update>();
 | 
			
		||||
 | 
			
		||||
			var taxRateCacheFake = instanceFaker.GetMock<ITaxRateCache>()!;
 | 
			
		||||
 | 
			
		||||
			_ = taxRateCacheFake.Setup(e => e.Refresh(It.IsAny<int>()));
 | 
			
		||||
 | 
			
		||||
			var eventServiceFake = instanceFaker.GetMock<IEventService>()!;
 | 
			
		||||
 | 
			
		||||
			_ = eventServiceFake.Setup(e => e.Enqueue(It.IsAny<ITaxRateService?>(), ServiceEvents.Updated, It.IsAny<int>()));
 | 
			
		||||
 | 
			
		||||
			/*
 | 
			
		||||
			 * Argument values are irrelevant for the test
 | 
			
		||||
			 */
 | 
			
		||||
			var args = new UpdateTaxRateArgs();
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Test
 | 
			
		||||
			 */
 | 
			
		||||
			var serviceFunction = instanceFaker.Instance;
 | 
			
		||||
			serviceFunction.SetArguments(args);
 | 
			
		||||
			await ((ITransactionClient)serviceFunction).Commit();
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Assert
 | 
			
		||||
			 */
 | 
			
		||||
			eventServiceFake.Verify(e => e.Enqueue(It.IsAny<ITaxRateService?>(), ServiceEvents.Updated, It.IsAny<int>()), Times.Exactly(1));
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		[TestMethod("Update commit refreshes cache exactly once")]
 | 
			
		||||
		public async Task Update_Commit_RefreshesCache_ExactlyOnce()
 | 
			
		||||
		{
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Setup
 | 
			
		||||
			 */
 | 
			
		||||
			var instanceFaker = new InstanceFaker<Update>();
 | 
			
		||||
 | 
			
		||||
			var taxRateCacheFake = instanceFaker.GetMock<ITaxRateCache>()!;
 | 
			
		||||
 | 
			
		||||
			_ = taxRateCacheFake.Setup(e => e.Refresh(It.IsAny<int>()));
 | 
			
		||||
 | 
			
		||||
			var eventServiceFake = instanceFaker.GetMock<IEventService>()!;
 | 
			
		||||
 | 
			
		||||
			_ = eventServiceFake.Setup(e => e.Enqueue(It.IsAny<ITaxRateService?>(), ServiceEvents.Updated, It.IsAny<int>()));
 | 
			
		||||
 | 
			
		||||
			/*
 | 
			
		||||
			 * Argument values are irrelevant for the test
 | 
			
		||||
			 */
 | 
			
		||||
			var args = new UpdateTaxRateArgs();
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Test
 | 
			
		||||
			 */
 | 
			
		||||
			var serviceFunction = instanceFaker.Instance;
 | 
			
		||||
			serviceFunction.SetArguments(args);
 | 
			
		||||
			await ((ITransactionClient)serviceFunction).Commit();
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Assert
 | 
			
		||||
			 */
 | 
			
		||||
			taxRateCacheFake.Verify(e => e.Refresh(It.IsAny<int>()), Times.Exactly(1));
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		[TestMethod("Update commit fires updated event after notifying cache")]
 | 
			
		||||
		public async Task Update_Commit_InvokedLastUpdatedEvent_AfterNotifyingCache()
 | 
			
		||||
		{
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Setup			
 | 
			
		||||
			 * Mockbehavior string ensures no unplanned functions are called on the services.
 | 
			
		||||
			 * If you receive an error about function calls not properly set up, and function
 | 
			
		||||
			 * calls look ok, it's probably the sequence throwing the exception. This is a
 | 
			
		||||
			 * failure in user code, not the test.
 | 
			
		||||
			*/
 | 
			
		||||
			var sequence = new MockSequence();
 | 
			
		||||
 | 
			
		||||
			var instanceFaker = new InstanceFaker<Update>();
 | 
			
		||||
 | 
			
		||||
			var taxRateCacheFake = instanceFaker.GetMock<ITaxRateCache>()!;
 | 
			
		||||
 | 
			
		||||
			_ = taxRateCacheFake
 | 
			
		||||
				.InSequence(sequence)
 | 
			
		||||
				.Setup(e => e.Refresh(It.IsAny<int>()));
 | 
			
		||||
 | 
			
		||||
			var eventServiceFake = instanceFaker.GetMock<IEventService>()!;
 | 
			
		||||
 | 
			
		||||
			_ = eventServiceFake
 | 
			
		||||
				.InSequence(sequence)
 | 
			
		||||
				.Setup(e => e.Enqueue(It.IsAny<ITaxRateService?>(), ServiceEvents.Updated, It.IsAny<int>()));
 | 
			
		||||
 | 
			
		||||
			/*
 | 
			
		||||
			 * Argument values are irrelevant for the test
 | 
			
		||||
			 */
 | 
			
		||||
			var args = new UpdateTaxRateArgs();
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Test
 | 
			
		||||
			 */
 | 
			
		||||
			var serviceFunction = instanceFaker.Instance;
 | 
			
		||||
			serviceFunction.SetArguments(args);
 | 
			
		||||
			await ((ITransactionClient)serviceFunction).Commit();
 | 
			
		||||
			/* 
 | 
			
		||||
			 * Assert
 | 
			
		||||
			 */
 | 
			
		||||
			taxRateCacheFake.Verify(e => e.Refresh(It.IsAny<int>()), Times.AtLeastOnce());
 | 
			
		||||
			eventServiceFake.VerifyEvent<ITaxRateService, int>(ServiceEvents.Updated);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										36
									
								
								tests/Connected.Common.Types.Tests/TaxRates/TaxRateTests.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								tests/Connected.Common.Types.Tests/TaxRates/TaxRateTests.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,36 @@
 | 
			
		||||
using System.Reflection;
 | 
			
		||||
using Connected.Common.Types.TaxRates;
 | 
			
		||||
using Connected.Entities.Annotations;
 | 
			
		||||
using Connected.Entities.Consistency;
 | 
			
		||||
 | 
			
		||||
namespace Common.Types.TaxRates;
 | 
			
		||||
 | 
			
		||||
[TestClass]
 | 
			
		||||
public class TaxRateTests
 | 
			
		||||
{
 | 
			
		||||
	[TestMethod("TaxRate is ConsistentEntity<>")]
 | 
			
		||||
	public void TaxRate_IsConsistentEntity()
 | 
			
		||||
	{
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Test
 | 
			
		||||
		 */
 | 
			
		||||
		var isConsistentEntity = typeof(TaxRate).IsAssignableToGenericType(typeof(ConsistentEntity<>));
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Assert
 | 
			
		||||
		 */
 | 
			
		||||
		Assert.IsTrue(isConsistentEntity);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	[TestMethod("TaxRate has exactly one schema")]
 | 
			
		||||
	public void TaxRate_HasExactlyOneSchema()
 | 
			
		||||
	{
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Test
 | 
			
		||||
		 */
 | 
			
		||||
		var tableAttributes = typeof(TaxRate).GetCustomAttributes<TableAttribute>();
 | 
			
		||||
		/* 
 | 
			
		||||
		 * Assert
 | 
			
		||||
		 */
 | 
			
		||||
		Assert.IsTrue(tableAttributes.Count() == 1);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										106
									
								
								tests/Connected.Common.Types.Tests/TestUtils.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										106
									
								
								tests/Connected.Common.Types.Tests/TestUtils.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,106 @@
 | 
			
		||||
using Connected;
 | 
			
		||||
using Connected.Notifications.Events;
 | 
			
		||||
using Connected.ServiceModel;
 | 
			
		||||
using Connected.Services;
 | 
			
		||||
 | 
			
		||||
using Moq;
 | 
			
		||||
 | 
			
		||||
namespace Common.Types;
 | 
			
		||||
 | 
			
		||||
internal static class TestUtils
 | 
			
		||||
{
 | 
			
		||||
	public static bool IsAssignableToGenericType<TGenericType>(this Type type)
 | 
			
		||||
	{
 | 
			
		||||
		var genericType = typeof(TGenericType);
 | 
			
		||||
 | 
			
		||||
		if (!genericType.IsGenericType)
 | 
			
		||||
			throw new ArgumentException("The passed type must be a generic type.", nameof(TGenericType));
 | 
			
		||||
 | 
			
		||||
		return type.IsAssignableToGenericType(genericType);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public static bool IsAssignableToGenericType(this Type type, Type genericType)
 | 
			
		||||
	{
 | 
			
		||||
		if (!genericType.IsGenericType)
 | 
			
		||||
			throw new ArgumentException("The passed type must be a generic type.", nameof(genericType));
 | 
			
		||||
 | 
			
		||||
		var interfaceTypes = type.GetInterfaces();
 | 
			
		||||
 | 
			
		||||
		foreach (var interfaceType in interfaceTypes)
 | 
			
		||||
		{
 | 
			
		||||
			if (interfaceType.IsGenericType && interfaceType.GetGenericTypeDefinition() == genericType)
 | 
			
		||||
				return true;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (type.IsGenericType && type.GetGenericTypeDefinition() == genericType)
 | 
			
		||||
			return true;
 | 
			
		||||
 | 
			
		||||
		var baseType = type.BaseType;
 | 
			
		||||
 | 
			
		||||
		if (baseType is null)
 | 
			
		||||
			return false;
 | 
			
		||||
 | 
			
		||||
		return baseType.IsAssignableToGenericType(genericType);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public static bool SequenceEquivalent<T>(this IEnumerable<T> firstSequence, IEnumerable<T> secondSequence)
 | 
			
		||||
	{
 | 
			
		||||
		var diff1 = firstSequence.Except(secondSequence);
 | 
			
		||||
		var diff2 = secondSequence.Except(firstSequence);
 | 
			
		||||
 | 
			
		||||
		return !diff1.Any() && !diff2.Any();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public static void SetArguments<TArgs>(this ServiceOperation<TArgs> operation, TArgs args)
 | 
			
		||||
		where TArgs : IDto
 | 
			
		||||
	{
 | 
			
		||||
		typeof(ServiceOperation<TArgs>).GetProperty(nameof(operation.Arguments))!.SetValue(operation, args);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public static Moq.Language.Flow.ISetup<IEventService, Task> SetupEvent<TService, TId>(this Moq.Language.ISetupConditionResult<IEventService> setup, string @event)
 | 
			
		||||
	{
 | 
			
		||||
		return setup.Setup(e => e.Enqueue(It.IsAny<IOperationState>(), It.IsAny<TService?>(), @event, It.IsAny<TId>()));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public static Moq.Language.Flow.ISetup<IEventService, Task> SetupEvent<TService, TId>(this Mock<IEventService> setup, string @event)
 | 
			
		||||
	{
 | 
			
		||||
		return setup.Setup(e => e.Enqueue(It.IsAny<IOperationState>(), It.IsAny<TService?>(), @event, It.IsAny<TId>()));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public static void VerifyEvent<TService, TId>(this Mock<IEventService> setup, string @event)
 | 
			
		||||
	{
 | 
			
		||||
		setup.Verify(e => e.Enqueue(It.IsAny<IOperationState>(), It.IsAny<TService?>(), @event, It.IsAny<TId>()), Times.Exactly(1));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public static void SetupIEnumerable<TEnumerable>(this Mock mock, IEnumerable<TEnumerable> data)
 | 
			
		||||
	{
 | 
			
		||||
		mock.As<IEnumerable<TEnumerable>>()
 | 
			
		||||
			.Setup(e => e.GetEnumerator())
 | 
			
		||||
			.Returns(data.GetEnumerator());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public static class AssertExtensions
 | 
			
		||||
	{
 | 
			
		||||
		public static async Task Throws(Task action)
 | 
			
		||||
		{
 | 
			
		||||
			Exception exception = null;
 | 
			
		||||
 | 
			
		||||
			try
 | 
			
		||||
			{
 | 
			
		||||
				await action;
 | 
			
		||||
			}
 | 
			
		||||
			catch (Exception ex)
 | 
			
		||||
			{
 | 
			
		||||
				exception = ex;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if (exception is null)
 | 
			
		||||
				Assert.Fail("Expected exception, none was thrown.");
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		internal static Task Throws(Func<Task> value)
 | 
			
		||||
		{
 | 
			
		||||
			return Throws(value());
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										1
									
								
								tests/Connected.Common.Types.Tests/Usings.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								tests/Connected.Common.Types.Tests/Usings.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1 @@
 | 
			
		||||
global using Microsoft.VisualStudio.TestTools.UnitTesting;
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user