Skip to content

Commit

Permalink
DYN-7571 Add Compatibility Map route as an API (#114)
Browse files Browse the repository at this point in the history
* Create GetCompatibilityMap.cs

* add test

* comments
  • Loading branch information
zeusongit authored Oct 14, 2024
1 parent 3109720 commit ce7b0d2
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/GregClient/Requests/GetCompatibilityMap.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using RestSharp;

namespace Greg.Requests
{
/// <summary>
/// Returns the compatibility information with a fixed map of host applications
/// and it's respective supported Dynamo version
/// </summary>
public class GetCompatibilityMap : Request
{
public GetCompatibilityMap()
{
}

public override string Path
{
get { return "host_map"; }
}

public override HttpMethod HttpMethod
{
get { return HttpMethod.Get; }
}

internal override void Build(ref RestRequest request)
{
}
}
}
14 changes: 14 additions & 0 deletions src/GregClientTests/GregClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Greg.Requests;
using Greg.Responses;
using Greg.Utility;
using Newtonsoft.Json.Linq;
using RestSharp;
using System.Reflection;
using System.Text.Json;
Expand Down Expand Up @@ -161,6 +162,19 @@ public void ListHostsTest()
Assert.That(hostsResponse.content.Count, Is.EqualTo(5));
}

[Test]
public void ListCompatibilityMapTest()
{
GregClient pmc = new GregClient(null, "http://dynamopackages.com/");
var comMap = new GetCompatibilityMap();
var comMapResponse = pmc.ExecuteAndDeserializeWithContent<object>(comMap);
Assert.That(comMapResponse.content != null, Is.EqualTo(true));
var content = JsonSerializer.Serialize(comMapResponse.content);
Console.WriteLine(content);
var jsonResp = JArray.Parse(content);
Assert.That(jsonResp.Where(x => ((JObject)x).ContainsKey("Revit") || ((JObject)x).ContainsKey("Civil3D")).Any(), Is.EqualTo(true));
}

[Test]

public void TestCompatibilityDeserializationTest()
Expand Down

0 comments on commit ce7b0d2

Please sign in to comment.