diff --git a/src/SDKs/DataFactory/DataFactory.Tests/ScenarioTests/DataFactoryScenarioTests.cs b/src/SDKs/DataFactory/DataFactory.Tests/ScenarioTests/DataFactoryScenarioTests.cs new file mode 100644 index 000000000000..d07635d50415 --- /dev/null +++ b/src/SDKs/DataFactory/DataFactory.Tests/ScenarioTests/DataFactoryScenarioTests.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. + +using DataFactory.Tests.Utils; +using Microsoft.Azure.Management.DataFactory; +using Microsoft.Azure.Management.DataFactory.Models; +using Microsoft.Rest.Azure; +using System; +using System.Linq; +using Xunit; + +namespace DataFactory.Tests.ScenarioTests +{ + public class DataFactoryScenarioTests : ScenarioTestBase + { + [Fact] + [Trait(TraitName.TestType, TestType.Scenario)] + public void DataFactoryCrud() + { + var expectedFactory = new Factory(location: FactoryLocation); + + Action action = (client) => + { + Factory createResponse = client.Factories.CreateOrUpdate(ResourceGroupName, DataFactoryName, expectedFactory); + this.ValidateFactory(createResponse); + + Factory getResponse = client.Factories.Get(ResourceGroupName, DataFactoryName); + this.ValidateFactory(getResponse); + + IPage listByResourceGroupResponse = client.Factories.ListByResourceGroup(ResourceGroupName); + this.ValidateFactory(listByResourceGroupResponse.First()); + }; + + Action finallyAction = (client) => + { + client.Factories.Delete(ResourceGroupName, DataFactoryName); + }; + + this.RunTest(action, finallyAction); + } + + private void ValidateFactory(Factory actualFactory) + { + Assert.Equal(DataFactoryName, actualFactory.Name); + Assert.Equal(FactoryLocation, actualFactory.Location); + Assert.Equal("Succeeded", actualFactory.ProvisioningState); + } + } +} diff --git a/src/SDKs/DataFactory/DataFactory.Tests/ScenarioTests/ScenarioTestBase.cs b/src/SDKs/DataFactory/DataFactory.Tests/ScenarioTests/ScenarioTestBase.cs new file mode 100644 index 000000000000..68cea43742ad --- /dev/null +++ b/src/SDKs/DataFactory/DataFactory.Tests/ScenarioTests/ScenarioTestBase.cs @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. + +using Microsoft.Azure.Management.DataFactory; +using Microsoft.Rest.ClientRuntime.Azure.TestFramework; +using System; +using System.Runtime.CompilerServices; + +namespace DataFactory.Tests.ScenarioTests +{ + public abstract class ScenarioTestBase + { + protected const string ResourceGroupName = "sdktesting"; + protected const string DataFactoryName = "sdktestingfactory"; + protected const string FactoryLocation = "East US 2"; + protected static string ClassName = typeof(T).FullName; + + protected void RunTest(Action initialAction, Action finallyAction = null, [CallerMemberName] string methodName = "") + { + using (MockContext mockContext = MockContext.Start(ClassName, methodName)) + { + DataFactoryManagementClient client = mockContext.GetServiceClient(TestEnvironmentFactory.GetTestEnvironment()); + try + { + initialAction.Invoke(client); + } + finally + { + if (finallyAction != null) + { + finallyAction.Invoke(client); + } + } + } + } + } +} diff --git a/src/SDKs/DataFactory/DataFactory.Tests/SessionRecords/DataFactory.Tests.ScenarioTests.DataFactoryScenarioTests/DataFactoryCrud.json b/src/SDKs/DataFactory/DataFactory.Tests/SessionRecords/DataFactory.Tests.ScenarioTests.DataFactoryScenarioTests/DataFactoryCrud.json new file mode 100644 index 000000000000..9210fa94fc15 --- /dev/null +++ b/src/SDKs/DataFactory/DataFactory.Tests/SessionRecords/DataFactory.Tests.ScenarioTests.DataFactoryScenarioTests/DataFactoryCrud.json @@ -0,0 +1,276 @@ +{ + "Entries": [ + { + "RequestUri": "/subscriptions/876407bb-5bd3-45c4-9c07-cd74a964b2fc/resourceGroups/sdktesting/providers/Microsoft.DataFactory/factories/sdktestingfactory?api-version=2017-09-01-preview", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvODc2NDA3YmItNWJkMy00NWM0LTljMDctY2Q3NGE5NjRiMmZjL3Jlc291cmNlR3JvdXBzL3Nka3Rlc3RpbmcvcHJvdmlkZXJzL01pY3Jvc29mdC5EYXRhRmFjdG9yeS9mYWN0b3JpZXMvc2RrdGVzdGluZ2ZhY3Rvcnk/YXBpLXZlcnNpb249MjAxNy0wOS0wMS1wcmV2aWV3", + "RequestMethod": "PUT", + "RequestBody": "{\r\n \"location\": \"East US 2\"\r\n}", + "RequestHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "31" + ], + "x-ms-client-request-id": [ + "ccc12cc7-9c24-457d-8c23-f6f0a67a11d1" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.25211.01", + "Microsoft.Azure.Management.DataFactory.DataFactoryManagementClient/0.2.0.0" + ] + }, + "ResponseBody": "{\r\n \"name\": \"sdktestingfactory\",\r\n \"tags\": {},\r\n \"properties\": {\r\n \"provisioningState\": \"Succeeded\",\r\n \"loggingStorageAccountKey\": \"**********\",\r\n \"createTime\": \"2017-10-11T18:05:17.8196041Z\",\r\n \"version\": \"2017-09-01-preview\"\r\n },\r\n \"id\": \"/subscriptions/876407bb-5bd3-45c4-9c07-cd74a964b2fc/resourceGroups/sdktesting/providers/Microsoft.DataFactory/factories/sdktestingfactory\",\r\n \"type\": \"Microsoft.DataFactory/factories\",\r\n \"location\": \"East US 2\"\r\n}", + "ResponseHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ], + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Wed, 11 Oct 2017 18:05:26 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Transfer-Encoding": [ + "chunked" + ], + "Server": [ + "Microsoft-IIS/8.5" + ], + "Vary": [ + "Accept-Encoding" + ], + "x-ms-request-id": [ + "4aff2f3a-da68-47c8-bf58-09bbd1fb0147" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "X-Powered-By": [ + "ASP.NET" + ], + "x-ms-ratelimit-remaining-subscription-writes": [ + "1134" + ], + "x-ms-correlation-request-id": [ + "7a17a3b9-ef1c-4c93-8eae-f398d85a78d2" + ], + "x-ms-routing-request-id": [ + "CENTRALUS:20171011T180526Z:7a17a3b9-ef1c-4c93-8eae-f398d85a78d2" + ] + }, + "StatusCode": 200 + }, + { + "RequestUri": "/subscriptions/876407bb-5bd3-45c4-9c07-cd74a964b2fc/resourceGroups/sdktesting/providers/Microsoft.DataFactory/factories/sdktestingfactory?api-version=2017-09-01-preview", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvODc2NDA3YmItNWJkMy00NWM0LTljMDctY2Q3NGE5NjRiMmZjL3Jlc291cmNlR3JvdXBzL3Nka3Rlc3RpbmcvcHJvdmlkZXJzL01pY3Jvc29mdC5EYXRhRmFjdG9yeS9mYWN0b3JpZXMvc2RrdGVzdGluZ2ZhY3Rvcnk/YXBpLXZlcnNpb249MjAxNy0wOS0wMS1wcmV2aWV3", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "a61d9ce4-8db6-414e-abf2-56b6d92c48cd" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.25211.01", + "Microsoft.Azure.Management.DataFactory.DataFactoryManagementClient/0.2.0.0" + ] + }, + "ResponseBody": "{\r\n \"name\": \"sdktestingfactory\",\r\n \"tags\": {},\r\n \"properties\": {\r\n \"provisioningState\": \"Succeeded\",\r\n \"loggingStorageAccountKey\": \"**********\",\r\n \"createTime\": \"2017-10-11T18:05:17.8196041Z\",\r\n \"version\": \"2017-09-01-preview\"\r\n },\r\n \"id\": \"/subscriptions/876407bb-5bd3-45c4-9c07-cd74a964b2fc/resourceGroups/sdktesting/providers/Microsoft.DataFactory/factories/sdktestingfactory\",\r\n \"type\": \"Microsoft.DataFactory/factories\",\r\n \"location\": \"East US 2\"\r\n}", + "ResponseHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ], + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Wed, 11 Oct 2017 18:05:29 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Transfer-Encoding": [ + "chunked" + ], + "Server": [ + "Microsoft-IIS/8.5" + ], + "Vary": [ + "Accept-Encoding" + ], + "x-ms-request-id": [ + "2a201819-702c-4230-9f02-6b55725f891a" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "X-Powered-By": [ + "ASP.NET" + ], + "x-ms-ratelimit-remaining-subscription-reads": [ + "14740" + ], + "x-ms-correlation-request-id": [ + "6bad86c9-4ceb-4bd8-953f-d4708be7a264" + ], + "x-ms-routing-request-id": [ + "CENTRALUS:20171011T180530Z:6bad86c9-4ceb-4bd8-953f-d4708be7a264" + ] + }, + "StatusCode": 200 + }, + { + "RequestUri": "/subscriptions/876407bb-5bd3-45c4-9c07-cd74a964b2fc/resourceGroups/sdktesting/providers/Microsoft.DataFactory/factories?api-version=2017-09-01-preview", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvODc2NDA3YmItNWJkMy00NWM0LTljMDctY2Q3NGE5NjRiMmZjL3Jlc291cmNlR3JvdXBzL3Nka3Rlc3RpbmcvcHJvdmlkZXJzL01pY3Jvc29mdC5EYXRhRmFjdG9yeS9mYWN0b3JpZXM/YXBpLXZlcnNpb249MjAxNy0wOS0wMS1wcmV2aWV3", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "12eb2527-80ac-4266-8114-33389f4862f9" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.25211.01", + "Microsoft.Azure.Management.DataFactory.DataFactoryManagementClient/0.2.0.0" + ] + }, + "ResponseBody": "{\r\n \"value\": [\r\n {\r\n \"name\": \"sdktestingfactory\",\r\n \"tags\": {},\r\n \"properties\": {\r\n \"provisioningState\": \"Succeeded\",\r\n \"loggingStorageAccountKey\": \"**********\",\r\n \"createTime\": \"2017-10-11T18:05:17.8196041Z\",\r\n \"version\": \"2017-09-01-preview\"\r\n },\r\n \"id\": \"/subscriptions/876407bb-5bd3-45c4-9c07-cd74a964b2fc/resourceGroups/sdktesting/providers/Microsoft.DataFactory/factories/sdktestingfactory\",\r\n \"type\": \"Microsoft.DataFactory/factories\",\r\n \"location\": \"East US 2\"\r\n }\r\n ]\r\n}", + "ResponseHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ], + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Wed, 11 Oct 2017 18:05:29 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Transfer-Encoding": [ + "chunked" + ], + "Server": [ + "Microsoft-IIS/8.5" + ], + "Vary": [ + "Accept-Encoding" + ], + "x-ms-request-id": [ + "b2858e9d-e52b-47b2-b3fc-e6b276b2f59e" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "X-Powered-By": [ + "ASP.NET" + ], + "x-ms-ratelimit-remaining-subscription-reads": [ + "14739" + ], + "x-ms-correlation-request-id": [ + "f4667a02-1925-4eb4-9a3e-c53bd8bd1f13" + ], + "x-ms-routing-request-id": [ + "CENTRALUS:20171011T180530Z:f4667a02-1925-4eb4-9a3e-c53bd8bd1f13" + ] + }, + "StatusCode": 200 + }, + { + "RequestUri": "/subscriptions/876407bb-5bd3-45c4-9c07-cd74a964b2fc/resourceGroups/sdktesting/providers/Microsoft.DataFactory/factories/sdktestingfactory?api-version=2017-09-01-preview", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvODc2NDA3YmItNWJkMy00NWM0LTljMDctY2Q3NGE5NjRiMmZjL3Jlc291cmNlR3JvdXBzL3Nka3Rlc3RpbmcvcHJvdmlkZXJzL01pY3Jvc29mdC5EYXRhRmFjdG9yeS9mYWN0b3JpZXMvc2RrdGVzdGluZ2ZhY3Rvcnk/YXBpLXZlcnNpb249MjAxNy0wOS0wMS1wcmV2aWV3", + "RequestMethod": "DELETE", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "bf2f6c61-8a27-486a-9439-4124cf50b1c9" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.25211.01", + "Microsoft.Azure.Management.DataFactory.DataFactoryManagementClient/0.2.0.0" + ] + }, + "ResponseBody": "", + "ResponseHeaders": { + "Content-Length": [ + "0" + ], + "Expires": [ + "-1" + ], + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Wed, 11 Oct 2017 18:05:34 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Server": [ + "Microsoft-IIS/8.5" + ], + "x-ms-request-id": [ + "dec4559d-6f11-490f-9b98-70817ec6dc4c" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "X-Powered-By": [ + "ASP.NET" + ], + "x-ms-ratelimit-remaining-subscription-writes": [ + "1131" + ], + "x-ms-correlation-request-id": [ + "06d8f20a-0a2e-4ab2-87f5-895545f25e0a" + ], + "x-ms-routing-request-id": [ + "CENTRALUS:20171011T180534Z:06d8f20a-0a2e-4ab2-87f5-895545f25e0a" + ] + }, + "StatusCode": 200 + } + ], + "Names": {}, + "Variables": { + "SubscriptionId": "876407bb-5bd3-45c4-9c07-cd74a964b2fc" + } +} \ No newline at end of file