Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added $(SdkTargetFx)
Empty file.
7 changes: 7 additions & 0 deletions src/SDKs/EdgeGateway/AzSdk.RP.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!--This file and it's contents are updated at build time moving or editing might result in build failure. Take due deligence while editing this file-->
<PropertyGroup>
<AzureApiTag>DataBoxEdge_2019-03-01;</AzureApiTag>
<PackageTags>$(PackageTags);$(CommonTags);$(AzureApiTag);</PackageTags>
</PropertyGroup>
</Project>
28 changes: 28 additions & 0 deletions src/SDKs/EdgeGateway/EdgeGateway.Tests/EdgeGateway.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
<!-- Please do not move/edit code below this line -->
<Import Condition=" Exists('$([MSBuild]::GetPathOfFileAbove(AzSdk.test.reference.props))') " Project="$([MSBuild]::GetPathOfFileAbove('AzSdk.test.reference.props'))" />
<!-- Please do not move/edit code below this line -->
<PropertyGroup>
<PackageId>EdgeGateway.Tests</PackageId>
<Version>1.0.0</Version>
<AssemblyName>EdgeGateway.Tests</AssemblyName>
<Description>EdgeGateway.Tests;</Description>
</PropertyGroup>
<PropertyGroup>
<TargetFrameworks>netcoreapp2.0</TargetFrameworks>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Management.EdgeGateway\Microsoft.Azure.Management.EdgeGateway.csproj" />
</ItemGroup>
<!--Do not remove until VS Test Tools fixes #472-->
<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>
<ItemGroup>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use a regex like SessionRecords\**\*.json instead

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

<None Update="SessionRecords\**\*.json ">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
51 changes: 51 additions & 0 deletions src/SDKs/EdgeGateway/EdgeGateway.Tests/Helpers/AlertHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using Microsoft.Azure.Management.EdgeGateway;
using Microsoft.Azure.Management.EdgeGateway.Models;
using Microsoft.Rest.Azure;
using System.Collections.Generic;

namespace EdgeGateway.Tests
{
/// <summary>
/// Contains the test helper methods
/// </summary>
public static partial class TestUtilities
{
/// <summary>
/// Gets alerts int the device
/// </summary>
/// <param name="client"></param>
/// <param name="deviceName"></param>
/// <param name="resourceGroupName"></param>
/// <param name="continuationToken"></param>
/// <returns></returns>
public static IEnumerable<Alert> ListAlerts(
DataBoxEdgeManagementClient client,
string deviceName,
string resourceGroupName,
out string continuationToken)
{
//Create a databox edge/gateway device
IPage<Alert> alertList = client.Alerts.ListByDataBoxEdgeDevice(deviceName, resourceGroupName);
continuationToken = alertList.NextPageLink;
return alertList;
}

/// <summary>
/// Gets next page of alerts in device
/// </summary>
/// <param name="client"></param>
/// <param name="nextLink"></param>
/// <param name="continuationToken"></param>
/// <returns></returns>
public static IEnumerable<Alert> ListAlertsNext(
DataBoxEdgeManagementClient client,
string nextLink,
out string continuationToken)
{
// Gets the alert list
IPage<Alert> alertList = client.Alerts.ListByDataBoxEdgeDeviceNext(nextLink);
continuationToken = alertList.NextPageLink;
return alertList;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
using Microsoft.Azure.Management.EdgeGateway;
using Microsoft.Azure.Management.EdgeGateway.Models;
using Microsoft.Rest.Azure;
using System;
using System.Collections.Generic;
using System.Text;

namespace EdgeGateway.Tests
{
public static partial class TestUtilities
{

/// <summary>
/// Gets a bandwidth schedule object
/// </summary>
/// <returns>BandwidthSchedule</returns>
public static BandwidthSchedule GetBWSObject()
{

string start = string.Format("{0}:{1}:{2}", 0, 0, 0);
string stopTime = string.Format("{0}:{1}:{2}", 13, 59, 0);
List<string> days = new List<string> { "Sunday", "Monday" };

BandwidthSchedule bws = new BandwidthSchedule(start, stopTime, 100, days);
return bws;
}

/// <summary>
/// Gets the bandwidth schedules in device
/// </summary>
/// <param name="client"></param>
/// <param name="deviceName"></param>
/// <param name="resourceGroupName"></param>
/// <param name="continuationToken"></param>
/// <returns></returns>
public static IEnumerable<BandwidthSchedule> ListBandwidthSchedules(
DataBoxEdgeManagementClient client,
string deviceName,
string resourceGroupName,
out string continuationToken)
{
//Create a databox edge/gateway device
IPage<BandwidthSchedule> scheduleList = client.BandwidthSchedules.ListByDataBoxEdgeDevice(deviceName, resourceGroupName);
continuationToken = scheduleList.NextPageLink;
return scheduleList;
}

/// <summary>
/// Gets next page of bandwidth schedules in device
/// </summary>
/// <param name="client"></param>
/// <param name="nextLink"></param>
/// <param name="continuationToken"></param>
/// <returns></returns>
public static IEnumerable<BandwidthSchedule> ListBandwidthSchedulesNext(
DataBoxEdgeManagementClient client,
string nextLink,
out string continuationToken)
{
//Create a databox edge/gateway device
IPage<BandwidthSchedule> scheduleList = client.BandwidthSchedules.ListByDataBoxEdgeDeviceNext(nextLink);
continuationToken = scheduleList.NextPageLink;
return scheduleList;
}
}
}

134 changes: 134 additions & 0 deletions src/SDKs/EdgeGateway/EdgeGateway.Tests/Helpers/DeviceHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
using Microsoft.Azure.Management.EdgeGateway;
using Microsoft.Azure.Management.EdgeGateway.Models;
using Microsoft.Rest.Azure;
using System.Collections.Generic;

namespace EdgeGateway.Tests
{
public static partial class TestUtilities
{

/// <summary>
/// Creates or updates given edge resource
/// </summary>
/// <param name="device"></param>
/// <param name="deviceName"></param>
/// <param name="client"></param>
/// <param name="resourceGroupName"></param>
/// <returns></returns>
public static DataBoxEdgeDevice CreateOrUpdate(
this DataBoxEdgeDevice device,
string deviceName,
DataBoxEdgeManagementClient client,
string resourceGroupName)
{
//Create a databox edge/gateway device
client.Devices.CreateOrUpdate(deviceName,
device,
resourceGroupName
);

//Returns a databox edge/gateway device
return client.Devices.Get(deviceName, resourceGroupName);
}

/// <summary>
/// Populates the values of a gateway device
/// </summary>
/// <param name="device"></param>
/// <returns></returns>
public static void PopulateGatewayDeviceProperties(this DataBoxEdgeDevice device)
{
device.Location = TestConstants.DefaultResourceLocation;
device.Sku = new Sku("Gateway", "standard");
device.Tags = new Dictionary<string, string>();
device.Tags.Add("tag1", "value1");
device.Tags.Add("tag2", "value2");
}

/// <summary>
/// Populates the values of a edge device
/// </summary>
/// <param name="device"></param>
/// <returns></returns>
public static void PopulateEdgeDeviceProperties(this DataBoxEdgeDevice device)
{
device.Location = TestConstants.DefaultResourceLocation;
device.Sku = new Sku("Edge", "standard");
device.Tags = new Dictionary<string, string>();
device.Tags.Add("tag1", "value1");
device.Tags.Add("tag2", "value2");
}


/// <summary>
/// Gets resources by resource group
/// </summary>
/// <param name="client"></param>
/// <param name="resourceGroupName"></param>
/// <param name="continuationToken"></param>
/// <returns></returns>
public static IEnumerable<DataBoxEdgeDevice> GetResourcesByResourceGroup(
DataBoxEdgeManagementClient client,
string resourceGroupName,
out string continuationToken)
{
//Create a databox edge/gateway device
IPage<DataBoxEdgeDevice> resourceList = client.Devices.ListByResourceGroup(resourceGroupName);
continuationToken = resourceList.NextPageLink;
return resourceList;
}

/// <summary>
/// Gets next page in resource group
/// </summary>
/// <param name="client"></param>
/// <param name="nextLink"></param>
/// <param name="continuationToken"></param>
/// <returns></returns>
public static IEnumerable<DataBoxEdgeDevice> GetResourcesByResourceGroupNext(
DataBoxEdgeManagementClient client,
string nextLink,
out string continuationToken)
{
//Create a databox edge/gateway device
IPage<DataBoxEdgeDevice> resourceList = client.Devices.ListByResourceGroupNext(nextLink);
continuationToken = resourceList.NextPageLink;
return resourceList;
}

/// <summary>
/// Gets resources by subscription
/// </summary>
/// <param name="client"></param>
/// <param name="continuationToken"></param>
/// <returns></returns>
public static IEnumerable<DataBoxEdgeDevice> GetResourcesBySubscription(
DataBoxEdgeManagementClient client,
out string continuationToken)
{
//Create a databox edge/gateway device
IPage<DataBoxEdgeDevice> resourceList = client.Devices.ListBySubscription();
continuationToken = resourceList.NextPageLink;
return resourceList;
}

/// <summary>
/// Gets next page of resources in subscription
/// </summary>
/// <param name="client"></param>
/// <param name="nextLink"></param>
/// <param name="continuationToken"></param>
/// <returns></returns>
public static IEnumerable<DataBoxEdgeDevice> GetResourcesBySubscriptionNext(
DataBoxEdgeManagementClient client,
string nextLink,
out string continuationToken)
{
//Create a databox edge/gateway device
IPage<DataBoxEdgeDevice> resourceList = client.Devices.ListBySubscriptionNext(nextLink);
continuationToken = resourceList.NextPageLink;
return resourceList;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Microsoft.Azure.Management.EdgeGateway;
using Microsoft.Azure.Management.EdgeGateway.Models;
using System.Collections.Generic;
using System.Linq;

namespace EdgeGateway.Tests
{
public static partial class TestUtilities
{
/// <summary>
/// Gets the tags.
/// </summary>
/// <param name="device"></param>
/// <returns></returns>
public static Dictionary<string, string> GetTags(this DataBoxEdgeDevice device)
{
var Tags = new Dictionary<string, string>();
if (device.Tags != null)
{
Tags = device.Tags.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
}
Tags.Add("tag3", "value3");
Tags.Add("tag4", "value4");

return Tags;
}
}
}
46 changes: 46 additions & 0 deletions src/SDKs/EdgeGateway/EdgeGateway.Tests/Helpers/OrderHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using Microsoft.Azure.Management.EdgeGateway;
using Microsoft.Azure.Management.EdgeGateway.Models;
using Microsoft.Rest.Azure;
using System;
using System.Collections.Generic;
using System.Text;

namespace EdgeGateway.Tests
{
public static partial class TestUtilities
{
/// <summary>
/// Gets an order object
/// </summary>
/// <returns>Order</returns>
public static Order GetOrderObject()
{
ContactDetails contactDetails = new ContactDetails("John Mcclane", "Microsoft", "8004269400", new List<string>() { "john@microsoft.com" });

Address shippingAddress = new Address("Microsoft Corporation", "98052", "Redmond", "WA", "USA");
Order order = new Order(contactDetails, shippingAddress);
return order;
}

/// <summary>
/// Gets storage account credentials in the device
/// </summary>
/// <param name="client"></param>
/// <param name="deviceName"></param>
/// <param name="resourceGroupName"></param>
/// <param name="continuationToken"></param>
/// <returns>List of order</returns>
public static IEnumerable<Order> ListOrders(
DataBoxEdgeManagementClient client,
string deviceName,
string resourceGroupName,
out string continuationToken)
{
//Create a databox edge/gateway device
IPage<Order> orderList = client.Orders.ListByDataBoxEdgeDevice(deviceName, resourceGroupName);
continuationToken = orderList.NextPageLink;
return orderList;
}

}
}
Loading