|
- using System;
- using NUnit.Framework;
- namespace Leadercraft.Server
- {
- [TestFixture]
- public class Tests
- {
- private static readonly string tokenUrl = "http://192.168.122.229:1337/token";
-
- private static readonly string criteriaUrl = "http://192.168.122.229:7048/criteria";
-
- private LeadercraftApi api;
-
- [SetUp]
- public void SetUp()
- {
- api = new LeadercraftApi(13, tokenUrl, criteriaUrl);
- }
-
- [Test]
- public void TokenIntegrationTest()
- {
- LeadercraftResult<KeyStruct> result = api.RequestPOSTToken();
- Assert.AreEqual(200, result.StatusCode, "Expected HTTP 200 Ok StatusCode");
- ResultStruct<KeyStruct> resultStruct = result.ParseResult();
- Assert.Greater(resultStruct.Items.Length, 0, "Expected a non-zero item count");
- Assert.AreEqual(1, resultStruct.Items.Length, "Expected one result item");
- Assert.IsNotEmpty(resultStruct.Items[0].Token, "Expected a non-empty token string");
- }
-
- [Test]
- public void CriteriaIntegrationTest()
- {
- CriteriaStruct criteria = new CriteriaStruct
- {
- Location = new float[][] { new float[] { 1, 1, 0 }, new float[] { 1, 1, 0 } },
- Time = 42,
- GameID = 2,
- PlayerID = 333,
- Complete = true
- };
- // this may fail when TokenIntegrationTest also fails
- string token = api.RequestPOSTToken().ParseResult().Items[0].Token;
- LeadercraftResult<string> result = api.RequestPOSTCriteria(criteria, token);
- Assert.AreEqual(200, result.StatusCode, "Expected HTTP 200 Ok StatusCode");
- }
- }
- }
|