IAudioClockTest.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. namespace CoreAudioTests.Wasapi
  25. {
  26. /// <summary>
  27. /// Tests all methods of the IAudioClock interface.
  28. /// </summary>
  29. [TestClass]
  30. public class IAudioClockTest : TestClass<IAudioClock>
  31. {
  32. /// <summary>
  33. /// Tests nothing, the GetCharacteristics method is reserved for future use.
  34. /// </summary>
  35. [TestMethod]
  36. public void IAudioClock_GetCharacteristics()
  37. {
  38. // Testing is not applicable. This method is reserved for future use.
  39. }
  40. /// <summary>
  41. /// Tests that the frequency may be received, for each available audio client.
  42. /// </summary>
  43. [TestMethod]
  44. public void IAudioClock_GetFrequency()
  45. {
  46. ExecuteRunningServiceTest(runningService =>
  47. {
  48. UInt64 frequency = UInt64.MaxValue;
  49. var result = runningService.GetFrequency(out frequency);
  50. AssertCoreAudio.IsHResultOk(result);
  51. Assert.AreNotEqual(UInt64.MaxValue, frequency, "The frequency was not received.");
  52. });
  53. }
  54. /// <summary>
  55. /// Tests that the position may be received, for each available audio client.
  56. /// </summary>
  57. [TestMethod]
  58. public void IAudioClock_GetPosition()
  59. {
  60. ExecuteRunningServiceTest(runningService =>
  61. {
  62. UInt64 devicePos = UInt64.MaxValue;
  63. UInt64 counterPos = UInt64.MaxValue;
  64. var result = runningService.GetPosition(out devicePos, out counterPos);
  65. AssertCoreAudio.IsHResultOk(result);
  66. Assert.AreNotEqual(UInt64.MaxValue, devicePos, "The device position was not received.");
  67. Assert.AreNotEqual(UInt64.MaxValue, counterPos, "The counter position was not received.");
  68. });
  69. }
  70. }
  71. }