BooleanTests.cs 937 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. using System;
  2. using Microsoft.VisualStudio.TestTools.UnitTesting;
  3. using Boolean = S7.Net.Types.Boolean;
  4. namespace S7.Net.UnitTest.TypeTests
  5. {
  6. [TestClass]
  7. public class BooleanTests
  8. {
  9. [DataTestMethod]
  10. [DataRow(0)]
  11. [DataRow(1)]
  12. [DataRow(2)]
  13. [DataRow(3)]
  14. [DataRow(4)]
  15. [DataRow(5)]
  16. [DataRow(6)]
  17. [DataRow(7)]
  18. public void TestValidSetBitValues(int index)
  19. {
  20. Assert.AreEqual(Math.Pow(2, index), Boolean.SetBit(0, index));
  21. }
  22. [DataTestMethod]
  23. [DataRow(0)]
  24. [DataRow(1)]
  25. [DataRow(2)]
  26. [DataRow(3)]
  27. [DataRow(4)]
  28. [DataRow(5)]
  29. [DataRow(6)]
  30. [DataRow(7)]
  31. public void TestValidClearBitValues(int index)
  32. {
  33. Assert.AreEqual((byte) ((uint) Math.Pow(2, index) ^ uint.MaxValue), Boolean.ClearBit(byte.MaxValue, index));
  34. }
  35. }
  36. }