Skip to content

Commit 0c7c179

Browse files
committed
Added tests for Group instructor/team
1 parent a0f5997 commit 0c7c179

2 files changed

Lines changed: 81 additions & 0 deletions

File tree

TinCanTests/ContextTest.cs

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
using Newtonsoft.Json.Linq;
2+
using NUnit.Framework;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Linq;
6+
using System.Text;
7+
using TinCan;
8+
9+
namespace TinCanTests
10+
{
11+
[TestFixture]
12+
class ContextTest
13+
{
14+
[TestCase(false)]
15+
[TestCase(true)]
16+
public void TestGroupInstructor(bool isGroup)
17+
{
18+
// Build our test JObject
19+
Context exampleContext = BuildTextContext();
20+
if (isGroup)
21+
{
22+
exampleContext.instructor = new Group();
23+
}
24+
else
25+
{
26+
exampleContext.instructor = new Agent();
27+
}
28+
JObject contextObj = exampleContext.ToJObject();
29+
30+
// Ensure that Context.instructor is the correct Type
31+
Context testContext = new Context(contextObj);
32+
Assert.IsTrue(testContext.instructor is Agent);
33+
Assert.AreEqual(isGroup, testContext.instructor is Group);
34+
}
35+
36+
[TestCase(false)]
37+
[TestCase(true)]
38+
public void TestGroupTeam(bool isGroup)
39+
{
40+
// Build our test JObject
41+
Context exampleContext = BuildTextContext();
42+
if (isGroup)
43+
{
44+
exampleContext.team = new Group();
45+
}
46+
else
47+
{
48+
exampleContext.team = new Agent();
49+
}
50+
JObject contextObj = exampleContext.ToJObject();
51+
52+
// Ensure that Context.instructor is the correct Type
53+
Context testContext = new Context(contextObj);
54+
Assert.IsTrue(testContext.team is Agent);
55+
Assert.AreEqual(isGroup, testContext.team is Group);
56+
}
57+
58+
private Context BuildTextContext()
59+
{
60+
Guid registration = new Guid("42c0855b-8f64-47f3-b0e2-3f337930045a");
61+
ContextActivities contextActivities = new ContextActivities();
62+
string revision = "";
63+
string platform = "";
64+
string language = "";
65+
StatementRef statement = new StatementRef();
66+
TinCan.Extensions extensions = new TinCan.Extensions();
67+
68+
Context context = new Context();
69+
context.registration = registration;
70+
context.contextActivities = contextActivities;
71+
context.revision = revision;
72+
context.platform = platform;
73+
context.language = language;
74+
context.statement = statement;
75+
context.extensions = extensions;
76+
77+
return context;
78+
}
79+
}
80+
}

TinCanTests/TinCanTests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
<ItemGroup>
8989
<Compile Include="ActivityTest.cs" />
9090
<Compile Include="AgentTest.cs" />
91+
<Compile Include="ContextTest.cs" />
9192
<Compile Include="ResultTest.cs" />
9293
<Compile Include="Support.cs" />
9394
<Compile Include="SubStatementTest.cs" />

0 commit comments

Comments
 (0)