IKsJackDescription2Test.cs 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // -----------------------------------------
  2. // SoundScribe (TM) and related software.
  3. //
  4. // Copyright (C) 2007-2011 Vannatech
  5. // http://www.vannatech.com
  6. // All rights reserved.
  7. //
  8. // This source code is subject to the MIT License.
  9. // http://www.opensource.org/licenses/mit-license.php
  10. //
  11. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  15. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  17. // THE SOFTWARE.
  18. // -----------------------------------------
  19. using System;
  20. using CoreAudioTests.Common;
  21. using Microsoft.VisualStudio.TestTools.UnitTesting;
  22. using Vannatech.CoreAudio.Interfaces;
  23. using Vannatech.CoreAudio.Constants;
  24. using Vannatech.CoreAudio.Structures;
  25. namespace CoreAudioTests.DeviceTopologyApi
  26. {
  27. /// <summary>
  28. /// Tests all methods of the IKsJackDescription2 interface.
  29. /// </summary>
  30. [TestClass]
  31. public class IKsJackDescription2Test : TestClass<IKsJackDescription2>
  32. {
  33. /// <summary>
  34. /// Tests that the jack count may be received, for each applicable part in the system.
  35. /// </summary>
  36. [TestMethod]
  37. public void IKsJackDescription2_GetJackCount()
  38. {
  39. ExecutePartActivationTest(activation =>
  40. {
  41. var count = UInt32.MaxValue;
  42. var result = activation.GetJackCount(out count);
  43. AssertCoreAudio.IsHResultOk(result);
  44. Assert.AreNotEqual(UInt32.MaxValue, count, "The count was not received.");
  45. });
  46. }
  47. /// <summary>
  48. /// Tests that the jack description may be received, for each applicable part in the system.
  49. /// </summary>
  50. [TestMethod]
  51. public void IKsJackDescription2_GetJackDescription2()
  52. {
  53. var tested = false;
  54. ExecutePartActivationTest(activation =>
  55. {
  56. UInt32 count;
  57. activation.GetJackCount(out count);
  58. for (uint i = 0; i < count; i++)
  59. {
  60. KSJACK_DESCRIPTION2 description = new KSJACK_DESCRIPTION2();
  61. description.JackCapabilities = UInt32.MaxValue;
  62. var result = activation.GetJackDescription(i, out description);
  63. AssertCoreAudio.IsHResultOk(result);
  64. Assert.AreNotEqual(UInt32.MaxValue, description.JackCapabilities, "The jack capabilities was not received.");
  65. tested = true;
  66. }
  67. });
  68. if (!tested) Assert.Inconclusive("The test cannot be run properly. No jacks were found.");
  69. }
  70. }
  71. }