Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.
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
1 change: 1 addition & 0 deletions build/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.snk
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"msbuild-sdks": {
"Microsoft.Quantum.Sdk": "0.16.2105140327-beta"
"Microsoft.Quantum.Sdk": "0.16.2105143425-alpha"
}
}
52 changes: 0 additions & 52 deletions src/Azure/Azure.Quantum.Client.Test/Helpers/MockHelper.cs

This file was deleted.

115 changes: 115 additions & 0 deletions src/Azure/Azure.Quantum.Client.Test/Helpers/Problem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
using System.Collections.Generic;
using System.IO;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Threading.Tasks;

namespace Microsoft.Azure.Quantum.Test
{
public enum ProblemType : int
{
PUBO = 0,
Ising = 1,
}

/// <summary>
/// This is the data structure that represents a QIO problem payload on the service.
/// It's currently not exposed in C#, so we have it here so we can test job submission of
/// the client libraries without having to serialize Q# programs.
/// </summary>
public class Problem
{
private readonly HashSet<Term> terms = new HashSet<Term>();

public Problem(ProblemType type = ProblemType.PUBO)
{
ProblemType = type;
}

public Problem(IEnumerable<Term> collection)
: this()
{
AddRange(collection);
}

[JsonPropertyName("version")]
public string Version => "1.1";

[JsonPropertyName("type")]
[JsonConverter(typeof(JsonStringEnumConverter))]
public ProblemType ProblemType { get; }

[JsonPropertyName("terms")]
public IEnumerable<Term> Terms => terms;

public void Add(Term term)
{
terms.Add(term);
}

public void Add(int i, float c)
{
terms.Add(new Term(new int[] { i }, c));
}

public void Add(int i, int j, float c)
{
terms.Add(new Term( new int[] { i, j }, c));
}

public void Add(int i, int j, int k, float c)
{
terms.Add(new Term( new int[] { i, j, k }, c));
}

public void AddRange(IEnumerable<Term> collection)
{
foreach (var term in collection)
{
terms.Add(term);
}
}

public Task SerializeAsync(Stream stream)
{
var root = new SerializationWrapper
{
CostFunction = this,
};

// Save to the writer
return JsonSerializer.SerializeAsync(stream, root);
}

public override string ToString()
{
var root = new SerializationWrapper
{
CostFunction = this,
};

return JsonSerializer.Serialize(root);
}

private struct SerializationWrapper
{
[JsonPropertyName("cost_function")]
public Problem CostFunction { get; set; }
}

public class Term
{
public Term(int[] ids, float c)
{
this.IDs = ids;
this.Weight = c;
}

[JsonPropertyName("c")]
public float Weight { get; }

[JsonPropertyName("ids")]
public int[] IDs { get; }
}
}
}
11 changes: 6 additions & 5 deletions src/Azure/Azure.Quantum.Client.Test/Helpers/TestConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ namespace Microsoft.Azure.Quantum.Test
{
public static class TestConstants
{
public const string SubscriptionId = "sub1";
public const string ResourceGroupName = "rg1";
public const string WorkspaceName = "ws1";
public const string ProviderId = "provider1";
public const string Endpoint = "https://test";
// Used when connecting live
public const string LiveSubscriptionId = "916dfd6d-030c-4bd9-b579-7bb6d1926e97";
public const string LiveLocation = "westus2";
public const string LiveResourceGroupName = "e2e-scenarios";
public const string LiveStorageAccount = "e2etests";
public const string LiveWorkspaceName = "e2e-qsharp-tests";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.0.0" />
<PackageReference Include="MSTest.TestFramework" Version="2.0.0" />
<PackageReference Include="Moq" Version="4.13.1" />
<PackageReference Include="coverlet.collector" Version="1.0.1" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets>
Expand Down
Loading