Skip to content

Commit ce7b0d2

Browse files
authored
DYN-7571 Add Compatibility Map route as an API (#114)
* Create GetCompatibilityMap.cs * add test * comments
1 parent 3109720 commit ce7b0d2

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Net.Http;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
using RestSharp;
8+
9+
namespace Greg.Requests
10+
{
11+
/// <summary>
12+
/// Returns the compatibility information with a fixed map of host applications
13+
/// and it's respective supported Dynamo version
14+
/// </summary>
15+
public class GetCompatibilityMap : Request
16+
{
17+
public GetCompatibilityMap()
18+
{
19+
}
20+
21+
public override string Path
22+
{
23+
get { return "host_map"; }
24+
}
25+
26+
public override HttpMethod HttpMethod
27+
{
28+
get { return HttpMethod.Get; }
29+
}
30+
31+
internal override void Build(ref RestRequest request)
32+
{
33+
}
34+
}
35+
}

src/GregClientTests/GregClientTests.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using Greg.Requests;
33
using Greg.Responses;
44
using Greg.Utility;
5+
using Newtonsoft.Json.Linq;
56
using RestSharp;
67
using System.Reflection;
78
using System.Text.Json;
@@ -161,6 +162,19 @@ public void ListHostsTest()
161162
Assert.That(hostsResponse.content.Count, Is.EqualTo(5));
162163
}
163164

165+
[Test]
166+
public void ListCompatibilityMapTest()
167+
{
168+
GregClient pmc = new GregClient(null, "http://dynamopackages.com/");
169+
var comMap = new GetCompatibilityMap();
170+
var comMapResponse = pmc.ExecuteAndDeserializeWithContent<object>(comMap);
171+
Assert.That(comMapResponse.content != null, Is.EqualTo(true));
172+
var content = JsonSerializer.Serialize(comMapResponse.content);
173+
Console.WriteLine(content);
174+
var jsonResp = JArray.Parse(content);
175+
Assert.That(jsonResp.Where(x => ((JObject)x).ContainsKey("Revit") || ((JObject)x).ContainsKey("Civil3D")).Any(), Is.EqualTo(true));
176+
}
177+
164178
[Test]
165179

166180
public void TestCompatibilityDeserializationTest()

0 commit comments

Comments
 (0)