Skip to content

Commit

Permalink
chore: introduce editorconfig formatting and update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
arjendev committed Sep 21, 2023
1 parent c2e8375 commit baf92e3
Show file tree
Hide file tree
Showing 1,712 changed files with 477 additions and 5,193 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ Azure Data Factory does not support unit testing out of the box. The only way to

> Even though Azure Data Factory is a UI-driven tool and writing unit tests might not be in the nature of it. How can you be confident that your changes will work as expected, and existing pipelines will not break, without writing unit tests?
## Getting started

1. Add the following nuget source to `nuget.config`: `https://nuget.pkg.github.com/arjendev/index.json`
2. Install the nuget package: `dotnet add package AzureDataFactory.TestingFramework --prerelease`
3. Start writing tests

## Features - Examples

The samples seen below is the _only_ code that you need to write! The framework will take care of the rest.
Expand Down
48 changes: 47 additions & 1 deletion src/.editorconfig
Original file line number Diff line number Diff line change
@@ -1 +1,47 @@
dotnet_naming_rule.public_members_must_be_capitalized.severity = suggestion
[*]

# Microsoft .NET properties
csharp_new_line_before_members_in_object_initializers = false
csharp_new_line_before_open_brace = all
csharp_preferred_modifier_order = internal, protected, private, public, file, new, override, sealed, abstract, static, virtual, async, extern, unsafe, volatile, readonly, required:suggestion
file_header_template=Copyright (c) Microsoft Corporation.

# ReSharper properties
resharper_accessor_owner_body = accessors_with_expression_body
resharper_arguments_skip_single = true
resharper_blank_lines_after_block_statements = 0
resharper_blank_lines_around_auto_property = 0
resharper_blank_lines_around_property = 0
resharper_braces_for_foreach = required_for_multiline
resharper_braces_for_ifelse = not_required
resharper_braces_redundant = false
resharper_csharp_blank_lines_around_field = 0
resharper_csharp_blank_lines_around_invocable = 0
resharper_csharp_blank_lines_around_region = 0
resharper_csharp_blank_lines_around_single_line_invocable = 1
resharper_csharp_blank_lines_inside_region = 0
resharper_csharp_case_block_braces = next_line_shifted_2
resharper_csharp_indent_invocation_pars = none
resharper_csharp_insert_final_newline = true
resharper_csharp_max_line_length = 4517
resharper_csharp_remove_blank_lines_near_braces_in_code = false
resharper_csharp_remove_blank_lines_near_braces_in_declarations = false
resharper_csharp_wrap_parameters_style = chop_if_long
resharper_for_other_types = use_explicit_type
resharper_instance_members_qualify_declared_in =
resharper_local_function_body = expression_body
resharper_method_or_operator_body = expression_body
resharper_null_checking_pattern_style = empty_recursive_pattern
resharper_object_creation_when_type_evident = explicitly_typed
resharper_parentheses_redundancy_style = remove
resharper_place_accessorholder_attribute_on_same_line = false
resharper_place_expr_accessor_on_single_line = true
resharper_place_expr_method_on_single_line = true
resharper_place_expr_property_on_single_line = true
resharper_place_simple_anonymousmethod_on_single_line = false
resharper_place_simple_embedded_statement_on_same_line = false
resharper_place_simple_enum_on_single_line = true
resharper_place_simple_initializer_on_single_line = false
resharper_wrap_chained_binary_expressions = chop_if_long
resharper_wrap_enum_declaration = wrap_if_long
resharper_wrap_object_and_collection_initializer_style = chop_always
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Copyright (c) Microsoft Corporation.

using AzureDataFactory.TestingFramework.Exceptions;
using AzureDataFactory.TestingFramework.Models;
using AzureDataFactory.TestingFramework.Models.Base;
Expand All @@ -15,49 +17,49 @@ public void BatchJobTest()
Assert.Equal("batch_job", pipeline.Name);
Assert.Equal(11, pipeline.Activities.Count);

var activities = pipeline.EvaluateWithActivityEnumerator(new List<IRunParameter>
{
new RunParameter<string>(ParameterType.Parameter, "BatchPoolId", "batch-pool-id"),
new RunParameter<string>(ParameterType.Parameter, "WorkloadApplicationPackageName", "test-application"),
new RunParameter<string>(ParameterType.Parameter, "WorkloadApplicationPackageVersion", "1.5.0"),
new RunParameter<string>(ParameterType.Parameter, "ManagerApplicationPackageName", "batchmanager"),
new RunParameter<string>(ParameterType.Parameter, "ManagerApplicationPackageVersion", "2.0.0"),
new RunParameter<string>(ParameterType.Parameter, "ManagerTaskParameters", "--parameter1 dummy --parameter2 another-dummy"),
new RunParameter<string>(ParameterType.Parameter, "JobId", "802100a5-ec79-4a52-be62-8d6109f3ff9a"),
new RunParameter<string>(ParameterType.Parameter, "TaskOutputFolderPrefix", "TASKOUTPUT_"),
new RunParameter<string>(ParameterType.Parameter, "WorkloadUserAssignedIdentityName", "test-application-identity-name"),
new RunParameter<string>(ParameterType.Parameter, "WorkloadUserAssignedIdentityClientId", "/subscriptions/SUBSCRIPTION_ID/resourcegroups/RESOURCE_GROUP/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-application-identity-name"),
new RunParameter<string>(ParameterType.Parameter, "JobAdditionalEnvironmentSettings", "[]"),
new RunParameter<string>(ParameterType.Parameter, "OutputStorageAccountName", "test-application-output-storage-account-name"),
new RunParameter<string>(ParameterType.Parameter, "OutputContainerName", "test-application-output-container-name"),
new RunParameter<string>(ParameterType.Parameter, "OutputFolderName", "TEMP"),
new RunParameter<string>(ParameterType.Parameter, "BatchJobTimeout", "PT4H"),
new RunParameter<string>(ParameterType.Global, "BatchStorageAccountName", "batch-account-name"),
new RunParameter<string>(ParameterType.Global, "BatchAccountSubscription", "SUBSCRIPTION_ID"),
new RunParameter<string>(ParameterType.Global, "BatchAccountResourceGroup", "RESOURCE_GROUP"),
new RunParameter<string>(ParameterType.Global, "BatchURI", "https://batch-account-name.westeurope.batch.azure.com"),
new RunParameter<string>(ParameterType.Global, "ADFSubscription", "bd19dba4-89ad-4976-b862-848bf43a4340"),
new RunParameter<string>(ParameterType.Global, "ADFResourceGroup", "adf-rg"),
new RunParameter<string>(ParameterType.Global, "ADFName", "adf-name"),
});

var setUserAssignedIdentityActivity = activities.GetNext() as SetVariableActivity;
Assert.NotNull(setUserAssignedIdentityActivity);
Assert.Equal("Set UserAssignedIdentityReference", setUserAssignedIdentityActivity.Name);
Assert.Equal("UserAssignedIdentityReference", setUserAssignedIdentityActivity.VariableName);
Assert.Equal("/subscriptions/SUBSCRIPTION_ID/resourcegroups/RESOURCE_GROUP/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-application-identity-name", setUserAssignedIdentityActivity.Value);

var setManagerApplicationPackagePathActivity = activities.GetNext() as SetVariableActivity;
Assert.NotNull(setManagerApplicationPackagePathActivity);
Assert.Equal("Set ManagerApplicationPackagePath", setManagerApplicationPackagePathActivity.Name);
Assert.Equal("ManagerApplicationPackagePath", setManagerApplicationPackagePathActivity.VariableName);
Assert.Equal("$AZ_BATCH_APP_PACKAGE_batchmanager_2_0_0/batchmanager.tar.gz", setManagerApplicationPackagePathActivity.Value);

var setWorkloadApplicationPackagePathActivity = activities.GetNext() as SetVariableActivity;
Assert.NotNull(setWorkloadApplicationPackagePathActivity);
Assert.Equal("Set WorkloadApplicationPackagePath", setWorkloadApplicationPackagePathActivity.Name);
Assert.Equal("WorkloadApplicationPackagePath", setWorkloadApplicationPackagePathActivity.VariableName);
Assert.Equal("$AZ_BATCH_APP_PACKAGE_test-application_1_5_0/test-application.tar.gz", setWorkloadApplicationPackagePathActivity.Value);
var activities = pipeline.EvaluateWithActivityEnumerator(new List<IRunParameter>
{
new RunParameter<string>(ParameterType.Parameter, "BatchPoolId", "batch-pool-id"),
new RunParameter<string>(ParameterType.Parameter, "WorkloadApplicationPackageName", "test-application"),
new RunParameter<string>(ParameterType.Parameter, "WorkloadApplicationPackageVersion", "1.5.0"),
new RunParameter<string>(ParameterType.Parameter, "ManagerApplicationPackageName", "batchmanager"),
new RunParameter<string>(ParameterType.Parameter, "ManagerApplicationPackageVersion", "2.0.0"),
new RunParameter<string>(ParameterType.Parameter, "ManagerTaskParameters", "--parameter1 dummy --parameter2 another-dummy"),
new RunParameter<string>(ParameterType.Parameter, "JobId", "802100a5-ec79-4a52-be62-8d6109f3ff9a"),
new RunParameter<string>(ParameterType.Parameter, "TaskOutputFolderPrefix", "TASKOUTPUT_"),
new RunParameter<string>(ParameterType.Parameter, "WorkloadUserAssignedIdentityName", "test-application-identity-name"),
new RunParameter<string>(ParameterType.Parameter, "WorkloadUserAssignedIdentityClientId", "/subscriptions/SUBSCRIPTION_ID/resourcegroups/RESOURCE_GROUP/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-application-identity-name"),
new RunParameter<string>(ParameterType.Parameter, "JobAdditionalEnvironmentSettings", "[]"),
new RunParameter<string>(ParameterType.Parameter, "OutputStorageAccountName", "test-application-output-storage-account-name"),
new RunParameter<string>(ParameterType.Parameter, "OutputContainerName", "test-application-output-container-name"),
new RunParameter<string>(ParameterType.Parameter, "OutputFolderName", "TEMP"),
new RunParameter<string>(ParameterType.Parameter, "BatchJobTimeout", "PT4H"),
new RunParameter<string>(ParameterType.Global, "BatchStorageAccountName", "batch-account-name"),
new RunParameter<string>(ParameterType.Global, "BatchAccountSubscription", "SUBSCRIPTION_ID"),
new RunParameter<string>(ParameterType.Global, "BatchAccountResourceGroup", "RESOURCE_GROUP"),
new RunParameter<string>(ParameterType.Global, "BatchURI", "https://batch-account-name.westeurope.batch.azure.com"),
new RunParameter<string>(ParameterType.Global, "ADFSubscription", "bd19dba4-89ad-4976-b862-848bf43a4340"),
new RunParameter<string>(ParameterType.Global, "ADFResourceGroup", "adf-rg"),
new RunParameter<string>(ParameterType.Global, "ADFName", "adf-name"),
});

var setUserAssignedIdentityActivity = activities.GetNext() as SetVariableActivity;
Assert.NotNull(setUserAssignedIdentityActivity);
Assert.Equal("Set UserAssignedIdentityReference", setUserAssignedIdentityActivity.Name);
Assert.Equal("UserAssignedIdentityReference", setUserAssignedIdentityActivity.VariableName);
Assert.Equal("/subscriptions/SUBSCRIPTION_ID/resourcegroups/RESOURCE_GROUP/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-application-identity-name", setUserAssignedIdentityActivity.Value);

var setManagerApplicationPackagePathActivity = activities.GetNext() as SetVariableActivity;
Assert.NotNull(setManagerApplicationPackagePathActivity);
Assert.Equal("Set ManagerApplicationPackagePath", setManagerApplicationPackagePathActivity.Name);
Assert.Equal("ManagerApplicationPackagePath", setManagerApplicationPackagePathActivity.VariableName);
Assert.Equal("$AZ_BATCH_APP_PACKAGE_batchmanager_2_0_0/batchmanager.tar.gz", setManagerApplicationPackagePathActivity.Value);

var setWorkloadApplicationPackagePathActivity = activities.GetNext() as SetVariableActivity;
Assert.NotNull(setWorkloadApplicationPackagePathActivity);
Assert.Equal("Set WorkloadApplicationPackagePath", setWorkloadApplicationPackagePathActivity.Name);
Assert.Equal("WorkloadApplicationPackagePath", setWorkloadApplicationPackagePathActivity.VariableName);
Assert.Equal("$AZ_BATCH_APP_PACKAGE_test-application_1_5_0/test-application.tar.gz", setWorkloadApplicationPackagePathActivity.Value);

var setCommonEnvironmentSettingsActivity = activities.GetNext() as SetVariableActivity;
Assert.NotNull(setCommonEnvironmentSettingsActivity);
Expand Down Expand Up @@ -193,23 +195,23 @@ public void BatchJobTest()
Assert.Equal(1, monitorActivity.Parameters.Count);
Assert.Equal("802100a5-ec79-4a52-be62-8d6109f3ff9a", monitorActivity.Parameters["JobId"]);

var copyOutputFiles = activities.GetNext() as ExecutePipelineActivity;
Assert.NotNull(copyOutputFiles);
Assert.Equal("Copy Output Files", copyOutputFiles.Name);
Assert.Equal("copy_output_files", copyOutputFiles.Pipeline.ReferenceName);
Assert.Equal(5, copyOutputFiles.Parameters.Count);
Assert.Equal("job-802100a5-ec79-4a52-be62-8d6109f3ff9a", copyOutputFiles.Parameters["JobContainerName"]);
Assert.Equal("TASKOUTPUT_", copyOutputFiles.Parameters["TaskOutputFolderPrefix"]);
Assert.Equal("test-application-output-storage-account-name", copyOutputFiles.Parameters["OutputStorageAccountName"]);
Assert.Equal("test-application-output-container-name", copyOutputFiles.Parameters["OutputContainerName"]);
Assert.Equal("TEMP", copyOutputFiles.Parameters["OutputFolderName"]);

var deleteJobContainer = activities.GetNext() as WebActivity;
Assert.NotNull(deleteJobContainer);
Assert.Equal("Delete Job Storage Container", deleteJobContainer.Name);
Assert.Equal("https://batch-account-name.blob.core.windows.net/job-802100a5-ec79-4a52-be62-8d6109f3ff9a?restype=container", deleteJobContainer.Uri);
Assert.Equal("DELETE", deleteJobContainer.Method);
Assert.Null(deleteJobContainer.Body);
var copyOutputFiles = activities.GetNext() as ExecutePipelineActivity;
Assert.NotNull(copyOutputFiles);
Assert.Equal("Copy Output Files", copyOutputFiles.Name);
Assert.Equal("copy_output_files", copyOutputFiles.Pipeline.ReferenceName);
Assert.Equal(5, copyOutputFiles.Parameters.Count);
Assert.Equal("job-802100a5-ec79-4a52-be62-8d6109f3ff9a", copyOutputFiles.Parameters["JobContainerName"]);
Assert.Equal("TASKOUTPUT_", copyOutputFiles.Parameters["TaskOutputFolderPrefix"]);
Assert.Equal("test-application-output-storage-account-name", copyOutputFiles.Parameters["OutputStorageAccountName"]);
Assert.Equal("test-application-output-container-name", copyOutputFiles.Parameters["OutputContainerName"]);
Assert.Equal("TEMP", copyOutputFiles.Parameters["OutputFolderName"]);

var deleteJobContainer = activities.GetNext() as WebActivity;
Assert.NotNull(deleteJobContainer);
Assert.Equal("Delete Job Storage Container", deleteJobContainer.Name);
Assert.Equal("https://batch-account-name.blob.core.windows.net/job-802100a5-ec79-4a52-be62-8d6109f3ff9a?restype=container", deleteJobContainer.Uri);
Assert.Equal("DELETE", deleteJobContainer.Method);
Assert.Null(deleteJobContainer.Body);

Assert.Throws<ActivityEnumeratorException>(() => activities.GetNext());
}
Expand Down
Loading

0 comments on commit baf92e3

Please sign in to comment.