Follow the leader
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

49 lines
1.5KB

  1. using System;
  2. using NUnit.Framework;
  3. namespace Leadercraft.Server
  4. {
  5. [TestFixture]
  6. public class Tests
  7. {
  8. private static readonly string tokenUrl = "http://192.168.122.229:1337/token";
  9. private static readonly string criteriaUrl = "http://192.168.122.229:7048/criteria";
  10. private LeadercraftApi api;
  11. [SetUp]
  12. public void SetUp()
  13. {
  14. api = new LeadercraftApi(13, tokenUrl, criteriaUrl);
  15. }
  16. [Test]
  17. public void TokenIntegrationTest()
  18. {
  19. LeadercraftResult<KeyStruct> result = api.RequestPOSTToken();
  20. Assert.AreEqual(200, result.StatusCode, "Expected HTTP 200 Ok StatusCode");
  21. ResultStruct<KeyStruct> resultStruct = result.ParseResult();
  22. Assert.Greater(resultStruct.Items.Length, 0, "Expected a non-zero item count");
  23. Assert.AreEqual(1, resultStruct.Items.Length, "Expected one result item");
  24. Assert.IsNotEmpty(resultStruct.Items[0].Token, "Expected a non-empty token string");
  25. }
  26. [Test]
  27. public void CriteriaIntegrationTest()
  28. {
  29. CriteriaStruct criteria = new CriteriaStruct
  30. {
  31. Location = new float[][] { new float[] { 1, 1, 0 }, new float[] { 1, 1, 0 } },
  32. Time = 42,
  33. GameID = 2,
  34. PlayerID = 333,
  35. Complete = true
  36. };
  37. // this may fail when TokenIntegrationTest also fails
  38. string token = api.RequestPOSTToken().ParseResult().Items[0].Token;
  39. LeadercraftResult<string> result = api.RequestPOSTCriteria(criteria, token);
  40. Assert.AreEqual(200, result.StatusCode, "Expected HTTP 200 Ok StatusCode");
  41. }
  42. }
  43. }