Skip to content

Commit a09e52b

Browse files
Review Comments Incorporation
Remove Test code Add help content Add xml comments Re-Record
1 parent 5369c74 commit a09e52b

File tree

146 files changed

+17911
-17378
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

146 files changed

+17911
-17378
lines changed

src/StorageSync/StorageSync.Test/Common/MockEcsManagementInteropClient.cs

Lines changed: 427 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Commands.StorageSync.Interop.Clients;
16+
using Commands.StorageSync.Interop.DataObjects;
17+
using Commands.StorageSync.Interop.Interfaces;
18+
using Microsoft.Azure.Commands.StorageSync.Common;
19+
using Microsoft.Azure.Commands.StorageSync.Interfaces;
20+
using System;
21+
using System.Text.RegularExpressions;
22+
23+
namespace StorageSync.Test.Common
24+
{
25+
/// <summary>
26+
/// Class StorageSyncResourceManager.
27+
/// Implements the <see cref="Microsoft.Azure.Commands.StorageSync.Common.IStorageSyncResourceManager" />
28+
/// Implements the <see cref="Microsoft.Azure.Commands.StorageSync.Interfaces.IStorageSyncResourceManager" />
29+
/// </summary>
30+
/// <seealso cref="Microsoft.Azure.Commands.StorageSync.Interfaces.IStorageSyncResourceManager" />
31+
/// <seealso cref="Microsoft.Azure.Commands.StorageSync.Common.IStorageSyncResourceManager" />
32+
public class MockStorageSyncResourceManager : IStorageSyncResourceManager
33+
{
34+
35+
/// <summary>
36+
/// Initializes a new instance of the <see cref="MockStorageSyncResourceManager"/> class.
37+
/// </summary>
38+
/// <param name="testName">Name of the test.</param>
39+
public MockStorageSyncResourceManager(string testName)
40+
{
41+
TestName = testName;
42+
}
43+
44+
/// <summary>
45+
/// The is playback mode
46+
/// </summary>
47+
private bool? isPlaybackMode;
48+
49+
/// <summary>
50+
/// Gets a value indicating whether this instance is playback mode.
51+
/// </summary>
52+
/// <value><c>true</c> if this instance is playback mode; otherwise, <c>false</c>.</value>
53+
/// <exception cref="NotSupportedException"></exception>
54+
protected bool IsPlaybackMode
55+
{
56+
get
57+
{
58+
if (!isPlaybackMode.HasValue)
59+
{
60+
if (Microsoft.Azure.Test.HttpRecorder.HttpMockServer.Mode == Microsoft.Azure.Test.HttpRecorder.HttpRecorderMode.Playback)
61+
{
62+
isPlaybackMode =true;
63+
}
64+
else if (Microsoft.Azure.Test.HttpRecorder.HttpMockServer.Mode == Microsoft.Azure.Test.HttpRecorder.HttpRecorderMode.Record)
65+
{
66+
isPlaybackMode = false;
67+
68+
} else
69+
{
70+
throw new NotSupportedException($"{Microsoft.Azure.Test.HttpRecorder.HttpMockServer.Mode} Mode is not supported");
71+
}
72+
}
73+
return isPlaybackMode.Value;
74+
}
75+
}
76+
77+
/// <summary>
78+
/// Gets the name of the test.
79+
/// </summary>
80+
/// <value>The name of the test.</value>
81+
public string TestName
82+
{
83+
get;
84+
}
85+
86+
/// <summary>
87+
/// Creates the ecs management.
88+
/// </summary>
89+
/// <returns>IEcsManagement.</returns>
90+
public IEcsManagement CreateEcsManagement() => IsPlaybackMode ? new MockEcsManagementInteropClient() as IEcsManagement : new EcsManagementInteropClient();
91+
92+
/// <summary>
93+
/// Gets the unique identifier.
94+
/// </summary>
95+
/// <param name="testName">Name of the test.</param>
96+
/// <returns>Guid.</returns>
97+
public Guid GetGuid(string testName) => Microsoft.Azure.Test.HttpRecorder.HttpMockServer.GetAssetGuid(testName);
98+
99+
/// <summary>
100+
/// Gets the afs agent installer path.
101+
/// </summary>
102+
/// <param name="afsAgentInstallerPath">The afs agent installer path.</param>
103+
/// <returns>System.String.</returns>
104+
public bool TryGetAfsAgentInstallerPath(out string afsAgentInstallerPath)
105+
{
106+
afsAgentInstallerPath = @"C:\Program Files\Azure\StorageSyncAgent\";
107+
return true;
108+
}
109+
110+
/// <summary>
111+
/// Gets the afs agent version.
112+
/// </summary>
113+
/// <param name="afsAgentVersion">The afs agent version.</param>
114+
/// <returns>System.String.</returns>
115+
public bool TryGetAfsAgentVersion(out string afsAgentVersion)
116+
{
117+
afsAgentVersion = @"5.0.2.0";
118+
return true;
119+
}
120+
121+
/// <summary>
122+
/// Updates the server registration data.
123+
/// </summary>
124+
/// <param name="pServerRegistrationData">The p server registration data.</param>
125+
/// <returns>ServerRegistrationData.</returns>
126+
public ServerRegistrationData UpdateServerRegistrationData(ServerRegistrationData pServerRegistrationData)
127+
{
128+
pServerRegistrationData.Id = Microsoft.Azure.Test.HttpRecorder.HttpMockServer.GetVariable(StorageSyncConstants.SyncServerId, pServerRegistrationData.Id);
129+
pServerRegistrationData.ServerId = Guid.Parse(Regex.Match(pServerRegistrationData.Id, @"([^/]+)$").Value);
130+
return pServerRegistrationData;
131+
}
132+
133+
/// <summary>
134+
/// Waits for access propogation.
135+
/// </summary>
136+
public void WaitForAccessPropogation()
137+
{
138+
if (!IsPlaybackMode)
139+
{
140+
System.Threading.Thread.Sleep(40 * 1000);
141+
}
142+
}
143+
}
144+
}

src/StorageSync/StorageSync.Test/ScenarioTests/CloudEndpointTests.cs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,44 +21,69 @@
2121

2222
namespace StorageSyncTests
2323
{
24+
/// <summary>
25+
/// Class CloudEndpointTests.
26+
/// </summary>
2427
public class CloudEndpointTests
2528
{
29+
/// <summary>
30+
/// The logger
31+
/// </summary>
2632
private readonly XunitTracingInterceptor _logger;
2733

34+
/// <summary>
35+
/// Initializes a new instance of the <see cref="CloudEndpointTests"/> class.
36+
/// </summary>
37+
/// <param name="output">The output.</param>
2838
public CloudEndpointTests(ITestOutputHelper output)
2939
{
3040
_logger = new XunitTracingInterceptor(output);
3141
XunitTracingInterceptor.AddToContext(_logger);
3242
}
3343

44+
/// <summary>
45+
/// Defines the test method TestCloudEndpoint.
46+
/// </summary>
3447
[Fact]
3548
[Trait(Category.AcceptanceType, Category.CheckIn)]
3649
public void TestCloudEndpoint()
3750
{
3851
TestController.NewInstance.RunPsTest(_logger, "Test-CloudEndpoint");
3952
}
4053

54+
/// <summary>
55+
/// Defines the test method TestNewCloudEndpoint.
56+
/// </summary>
4157
[Fact]
4258
[Trait(Category.AcceptanceType, Category.CheckIn)]
4359
public void TestNewCloudEndpoint()
4460
{
4561
TestController.NewInstance.RunPsTest(_logger, "Test-NewCloudEndpoint");
4662
}
4763

64+
/// <summary>
65+
/// Defines the test method TestGetCloudEndpoint.
66+
/// </summary>
4867
[Fact]
4968
[Trait(Category.AcceptanceType, Category.CheckIn)]
5069
public void TestGetCloudEndpoint()
5170
{
5271
TestController.NewInstance.RunPsTest(_logger, "Test-GetCloudEndpoint");
5372
}
5473

74+
/// <summary>
75+
/// Defines the test method TestGetCloudEndpointParentObject.
76+
/// </summary>
5577
[Fact]
5678
[Trait(Category.AcceptanceType, Category.CheckIn)]
5779
public void TestGetCloudEndpointParentObject()
5880
{
5981
TestController.NewInstance.RunPsTest(_logger, "Test-GetCloudEndpointParentObject");
6082
}
6183

84+
/// <summary>
85+
/// Defines the test method TestGetCloudEndpointParentResourceId.
86+
/// </summary>
6287
[Fact]
6388
[Trait(Category.AcceptanceType, Category.CheckIn)]
6489
public void TestGetCloudEndpointParentResourceId()
@@ -67,27 +92,39 @@ public void TestGetCloudEndpointParentResourceId()
6792
}
6893

6994

95+
/// <summary>
96+
/// Defines the test method TestGetCloudEndpoints.
97+
/// </summary>
7098
[Fact]
7199
[Trait(Category.AcceptanceType, Category.CheckIn)]
72100
public void TestGetCloudEndpoints()
73101
{
74102
TestController.NewInstance.RunPsTest(_logger, "Test-GetCloudEndpoints");
75103
}
76104

105+
/// <summary>
106+
/// Defines the test method TestRemoveCloudEndpoint.
107+
/// </summary>
77108
[Fact]
78109
[Trait(Category.AcceptanceType, Category.CheckIn)]
79110
public void TestRemoveCloudEndpoint()
80111
{
81112
TestController.NewInstance.RunPsTest(_logger, "Test-RemoveCloudEndpoint");
82113
}
83114

115+
/// <summary>
116+
/// Defines the test method TestRemoveCloudEndpointResourceId.
117+
/// </summary>
84118
[Fact]
85119
[Trait(Category.AcceptanceType, Category.CheckIn)]
86120
public void TestRemoveCloudEndpointResourceId()
87121
{
88122
TestController.NewInstance.RunPsTest(_logger, "Test-RemoveCloudEndpointResourceId");
89123
}
90124

125+
/// <summary>
126+
/// Defines the test method TestRemoveCloudEndpointInputObject.
127+
/// </summary>
91128
[Fact]
92129
[Trait(Category.AcceptanceType, Category.CheckIn)]
93130
public void TestRemoveCloudEndpointInputObject()

0 commit comments

Comments
 (0)