PageRenderTime 38ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/sipsorcery-core/Tests/SIPSorcery.CRM.UnitTests/ThirtySevenSignalsPersonRequestUnitTest.cs

https://github.com/thecc4re/sipsorcery-mono
C# | 82 lines | 39 code | 8 blank | 35 comment | 0 complexity | 3b708e067b4bc33631b02456ee7b808c MD5 | raw file
Possible License(s): CC-BY-SA-3.0
  1. // ============================================================================
  2. // FileName: ThirtySevenSignalsPersonRequestUnitTest.cs
  3. //
  4. // Description:
  5. // Unit tests for the class that requests Person objects from the 37 Signals contact management system Highrise.
  6. //
  7. // Author(s):
  8. // Aaron Clauson
  9. //
  10. // History:
  11. // 13 Feb 2011 Aaron Clauson Created.
  12. //
  13. // License:
  14. // This software is licensed under the BSD License http://www.opensource.org/licenses/bsd-license.php
  15. //
  16. // Copyright (c) 2011 Aaron Clauson (aaron@sipsorcery.com), SIP Sorcery Pty Ltd
  17. // All rights reserved.
  18. //
  19. // Redistribution and use in source and binary forms, with or without modification, are permitted provided that
  20. // the following conditions are met:
  21. //
  22. // Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  23. // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
  24. // disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of SIP Sorcery Ltd.
  25. // nor the names of its contributors may be used to endorse or promote products derived from this software without specific
  26. // prior written permission.
  27. //
  28. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
  29. // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  30. // IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  31. // OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  32. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  33. // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  34. // POSSIBILITY OF SUCH DAMAGE.
  35. // ============================================================================
  36. using System;
  37. using System.Text;
  38. using System.Collections.Generic;
  39. using System.Linq;
  40. using Microsoft.VisualStudio.TestTools.UnitTesting;
  41. using SIPSorcery.CRM.ThirtySevenSignals;
  42. namespace SIPSorcery.CRM.UnitTests
  43. {
  44. [TestClass]
  45. public class ThirtySevenSignalsPersonRequestUnitTest
  46. {
  47. private string m_highriseURL = "https://x.highrisehq.com";
  48. private string m_highriseAuthToken = "";
  49. [TestMethod]
  50. public void PersonRequestByIDTest()
  51. {
  52. int id = 59708303;
  53. PersonRequest request = new PersonRequest(m_highriseURL, m_highriseAuthToken);
  54. Person person = request.GetByID(id);
  55. Assert.AreEqual(id, person.ID, "The ID of the person record did not match the ID that was requested.");
  56. }
  57. [TestMethod]
  58. public void GetPeopleByPhoneNumberTest()
  59. {
  60. PersonRequest request = new PersonRequest(m_highriseURL, m_highriseAuthToken);
  61. People people = request.GetByPhoneNumber("555");
  62. Assert.IsNotNull(people, "The people should not have been null.");
  63. }
  64. [TestMethod]
  65. public void GetPeopleByNameTest()
  66. {
  67. PersonRequest request = new PersonRequest(m_highriseURL, m_highriseAuthToken);
  68. People people = request.GetByName("Agent Smith");
  69. Assert.IsNotNull(people, "The people should not have been null.");
  70. Assert.AreEqual(1, people.PersonList.Count, "An unexpected number of results were returned.");
  71. Assert.AreEqual(people.PersonList[0].ID, 59708303, "The ID of the person returned for a name search was not expected.");
  72. }
  73. }
  74. }