-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added tests for Group instructor/team
- Loading branch information
1 parent
a0f5997
commit 0c7c179
Showing
2 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
using Newtonsoft.Json.Linq; | ||
using NUnit.Framework; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using TinCan; | ||
|
||
namespace TinCanTests | ||
{ | ||
[TestFixture] | ||
class ContextTest | ||
{ | ||
[TestCase(false)] | ||
[TestCase(true)] | ||
public void TestGroupInstructor(bool isGroup) | ||
{ | ||
// Build our test JObject | ||
Context exampleContext = BuildTextContext(); | ||
if (isGroup) | ||
{ | ||
exampleContext.instructor = new Group(); | ||
} | ||
else | ||
{ | ||
exampleContext.instructor = new Agent(); | ||
} | ||
JObject contextObj = exampleContext.ToJObject(); | ||
|
||
// Ensure that Context.instructor is the correct Type | ||
Context testContext = new Context(contextObj); | ||
Assert.IsTrue(testContext.instructor is Agent); | ||
Assert.AreEqual(isGroup, testContext.instructor is Group); | ||
} | ||
|
||
[TestCase(false)] | ||
[TestCase(true)] | ||
public void TestGroupTeam(bool isGroup) | ||
{ | ||
// Build our test JObject | ||
Context exampleContext = BuildTextContext(); | ||
if (isGroup) | ||
{ | ||
exampleContext.team = new Group(); | ||
} | ||
else | ||
{ | ||
exampleContext.team = new Agent(); | ||
} | ||
JObject contextObj = exampleContext.ToJObject(); | ||
|
||
// Ensure that Context.instructor is the correct Type | ||
Context testContext = new Context(contextObj); | ||
Assert.IsTrue(testContext.team is Agent); | ||
Assert.AreEqual(isGroup, testContext.team is Group); | ||
} | ||
|
||
private Context BuildTextContext() | ||
{ | ||
Guid registration = new Guid("42c0855b-8f64-47f3-b0e2-3f337930045a"); | ||
ContextActivities contextActivities = new ContextActivities(); | ||
string revision = ""; | ||
string platform = ""; | ||
string language = ""; | ||
StatementRef statement = new StatementRef(); | ||
TinCan.Extensions extensions = new TinCan.Extensions(); | ||
|
||
Context context = new Context(); | ||
context.registration = registration; | ||
context.contextActivities = contextActivities; | ||
context.revision = revision; | ||
context.platform = platform; | ||
context.language = language; | ||
context.statement = statement; | ||
context.extensions = extensions; | ||
|
||
return context; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters