fix some tests
This commit is contained in:
parent
db210362f9
commit
63e72ab97f
@ -17,19 +17,12 @@
|
||||
|
||||
using Mocha.Core;
|
||||
using Mocha.Core.OmsImplementations;
|
||||
using Mocha.Testing;
|
||||
|
||||
namespace Mocha.Oms.Server.Tests;
|
||||
|
||||
public class LocalTests
|
||||
public class LocalTests : OmsTestsBase
|
||||
{
|
||||
public Mocha.Core.Oms? Oms { get; private set; }
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
Oms = new EmbeddedMiniOms();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestInstanceTaskWithGAS_GetGlobalIdentifier()
|
||||
{
|
||||
@ -40,4 +33,4 @@ public class LocalTests
|
||||
Dictionary<string, string> form = new Dictionary<string, string>();
|
||||
Response resp = Oms.ProcessElement(context, ProcessingInstance, form);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,6 +22,7 @@
|
||||
<ProjectReference Include="../../src/app/Mocha.Oms.Server/Mocha.Oms.Server.csproj" />
|
||||
<ProjectReference Include="../../src/lib/Mocha.Core.UI.Server/Mocha.Core.UI.Server.csproj" />
|
||||
<ProjectReference Include="../../src/lib/Mocha.Core/Mocha.Core.csproj" />
|
||||
<ProjectReference Include="../../src/lib/Mocha.Testing/Mocha.Testing.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
using System.Data.SqlTypes;
|
||||
using System.Net;
|
||||
using System.Net.Http.Json;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text.Json.Nodes;
|
||||
using Mocha.Core;
|
||||
using NUnit.Framework.Interfaces;
|
||||
@ -22,6 +23,12 @@ public class RemoteTests
|
||||
int exitCode = program.Start();
|
||||
}
|
||||
|
||||
protected int GetPort()
|
||||
{
|
||||
return 4436;
|
||||
// return program.Port;
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void TearDown()
|
||||
{
|
||||
@ -30,14 +37,18 @@ public class RemoteTests
|
||||
|
||||
protected string? BuildUrl(string v)
|
||||
{
|
||||
return String.Format("http://localhost:{0}{1}", program.Port, v);
|
||||
return String.Format("http://localhost:{0}{1}", GetPort(), v);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task Does_Test_Program_Boot()
|
||||
{
|
||||
Assert.That(program, Is.Not.Null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task Tenant_List_Test()
|
||||
{
|
||||
Assert.That(program, Is.Not.Null);
|
||||
|
||||
HttpClient client = new HttpClient();
|
||||
HttpResponseMessage resp = client.Send(new HttpRequestMessage(HttpMethod.Get, BuildUrl("/tenants")));
|
||||
|
||||
@ -55,8 +66,6 @@ public class RemoteTests
|
||||
[Test]
|
||||
public async Task Instance_Json_Test()
|
||||
{
|
||||
Assert.That(program, Is.Not.Null);
|
||||
|
||||
InstanceHandle h = program.Oms.GetInstance(KnownInstanceGuids.Classes.Class);
|
||||
InstanceKey k = program.Oms.GetInstanceKey(h);
|
||||
Guid g = program.Oms.GetGlobalIdentifier(h);
|
||||
@ -79,8 +88,6 @@ public class RemoteTests
|
||||
[Test, TestCase("1$1"), TestCase("1$2"), TestCase("1$3"), TestCase("4$1"), TestCase("6$3")]
|
||||
public async Task Instance_Json_Test_Multi(string ik)
|
||||
{
|
||||
Assert.That(program, Is.Not.Null);
|
||||
|
||||
InstanceHandle h = program.Oms.GetInstance(InstanceKey.Parse(ik));
|
||||
InstanceKey k = program.Oms.GetInstanceKey(h);
|
||||
Guid g = program.Oms.GetGlobalIdentifier(h);
|
||||
@ -99,13 +106,35 @@ public class RemoteTests
|
||||
Assert.That(new Guid(json["globalIdentifier"].ToString()), Is.EqualTo(g));
|
||||
Assert.That(json["text"].ToString(), Is.EqualTo(sz));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task Element_with_Parameters_Test()
|
||||
{
|
||||
InstanceHandle h = program.Oms.GetInstance(KnownInstanceGuids.Classes.Class);
|
||||
InstanceKey k = program.Oms.GetInstanceKey(h);
|
||||
Guid g = program.Oms.GetGlobalIdentifier(h);
|
||||
string sz = program.Oms.GetInstanceText(h);
|
||||
|
||||
HttpClient client = new HttpClient();
|
||||
|
||||
Dictionary<string, string> coll = new Dictionary<string, string>();
|
||||
coll["56$272"] = "86$1";
|
||||
HttpResponseMessage resp = client.Send(new HttpRequestMessage(HttpMethod.Post, BuildUrl("/tenants/super/instances/2997$48/element")) { Content = new FormUrlEncodedContent(coll) });
|
||||
|
||||
Assert.That(resp.StatusCode, Is.EqualTo(System.Net.HttpStatusCode.OK));
|
||||
Assert.That(resp.Content.Headers.ContentType.ToString(), Is.EqualTo("application/json"));
|
||||
|
||||
string content = await resp.Content.ReadAsStringAsync();
|
||||
|
||||
JsonObject json = JsonNode.Parse(content) as JsonObject;
|
||||
Assert.That(json["result"].ToString(), Is.EqualTo("success"));
|
||||
Assert.That(json["value"]["widget"].ToString(), Is.EqualTo("root"));
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public async Task Element_Test()
|
||||
{
|
||||
Assert.That(program, Is.Not.Null);
|
||||
|
||||
InstanceHandle h = program.Oms.GetInstance(KnownInstanceGuids.Classes.Class);
|
||||
InstanceKey k = program.Oms.GetInstanceKey(h);
|
||||
Guid g = program.Oms.GetGlobalIdentifier(h);
|
||||
@ -127,15 +156,22 @@ public class RemoteTests
|
||||
[Test]
|
||||
public async Task Instance_Task_Test_with_GAS_Get_Global_Identifier()
|
||||
{
|
||||
Assert.That(program, Is.Not.Null);
|
||||
|
||||
InstanceHandle h = program.Oms.GetInstance(KnownInstanceGuids.Classes.Class);
|
||||
InstanceKey k = program.Oms.GetInstanceKey(h);
|
||||
Guid g = program.Oms.GetGlobalIdentifier(h);
|
||||
string sz = program.Oms.GetInstanceText(h);
|
||||
|
||||
HttpClient client = new HttpClient();
|
||||
HttpResponseMessage resp = client.Send(new HttpRequestMessage(HttpMethod.Get, BuildUrl("/tenants/super/instances/56$51/element")));
|
||||
HttpRequestMessage message = new HttpRequestMessage(HttpMethod.Get, BuildUrl("/tenants/super/instances/56$51/element"));
|
||||
|
||||
// when a related task is executed, the url is ~/d/inst/{iid}/rel-task/{task-iid}.htmld
|
||||
// {iid} in this case is passed in as a Work Set to the related task
|
||||
// how to determine what Work Set it should be passed in as? I don't think it's simply `Related Instance`
|
||||
|
||||
Dictionary<string, string> dict = new Dictionary<string, string>();
|
||||
dict[KnownInstanceGuids.Classes.Instance.ToString("b")] = "";
|
||||
message.Content = new FormUrlEncodedContent(dict);
|
||||
HttpResponseMessage resp = client.Send(message);
|
||||
|
||||
Assert.That(resp.StatusCode, Is.EqualTo(System.Net.HttpStatusCode.OK));
|
||||
Assert.That(resp.Content.Headers.ContentType.ToString(), Is.EqualTo("application/json"));
|
||||
@ -150,8 +186,6 @@ public class RemoteTests
|
||||
[Test]
|
||||
public async Task Globals_Test_Get_Empty_Value()
|
||||
{
|
||||
Assert.That(program, Is.Not.Null);
|
||||
|
||||
HttpClient client = new HttpClient();
|
||||
HttpResponseMessage resp = client.Send(new HttpRequestMessage(HttpMethod.Get, BuildUrl(String.Format("/globals/{0}", KnownAttributeGuids.Text.ReferralURL))));
|
||||
|
||||
@ -168,8 +202,6 @@ public class RemoteTests
|
||||
[Test]
|
||||
public async Task Globals_Test_Set_Value()
|
||||
{
|
||||
Assert.That(program, Is.Not.Null);
|
||||
|
||||
HttpClient client = new HttpClient();
|
||||
HttpRequestMessage msg = new HttpRequestMessage(HttpMethod.Post, BuildUrl(String.Format("/globals/{0}", KnownAttributeGuids.Text.ReferralURL)));
|
||||
msg.Content = new System.Net.Http.FormUrlEncodedContent(new KeyValuePair<string, string>[] { new KeyValuePair<string, string>("value", "test attribute value") });
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user