Exemplo n.º 1
0
        public void ContainsInt_ReturnsTrue_IfInsideRange()
        {
            // Arrange
            var DekRange = new DekRange(5, 10);

            // Assert & Act

            // Values before range
            foreach (int i in new int[] { 0, 1, 2, 3, 4 })
            {
                Assert.That(DekRange.Contains(i), Is.False);
            }

            // Inside range
            foreach (int i in new int[] { 5, 6, 7, 8, 9, 10 })
            {
                Assert.That(DekRange.Contains(i), Is.True);
            }

            // After range
            foreach (int i in new int[] { 11, 12, 13, 100000 })
            {
                Assert.That(DekRange.Contains(i), Is.False);
            }

            // Special case
            Assert.DoesNotThrow(() => DekRange.Contains(-1));
        }
Exemplo n.º 2
0
        public void Range_14_Contians_11_and_44()
        {
            var testRange   = new DekRange(1, 4);
            var otherRange1 = new DekRange(1, 1);
            var otherRange2 = new DekRange(4, 4);

            // Assert
            Assert.That(testRange.Contains(otherRange1), Is.True);
            Assert.That(testRange.Contains(otherRange2), Is.True);
        }
Exemplo n.º 3
0
        public void Range_14_DoesNotContians_01_nor_45()
        {
            var testRange   = new DekRange(1, 4);
            var otherRange1 = new DekRange(0, 1);
            var otherRange2 = new DekRange(4, 5);

            // Assert
            Assert.That(testRange.Contains(otherRange1), Is.False);
            Assert.That(testRange.Contains(otherRange2), Is.False);
        }
Exemplo n.º 4
0
 public void ContainsItself_ReturnsTrue()
 {
     foreach (var DekRange in DekRanges)
     {
         Assert.That(DekRange.Contains(DekRange), Is.True);
     }
 }
Exemplo n.º 5
0
        public void BiggerContainsSmaller_And_NotTheOpposite()
        {
            foreach (var DekRange in DekRanges)
            {
                var biggerDekRange = new DekRange(DekRange.Start, DekRange.Stop + 1);
                Assert.That(biggerDekRange.Contains(DekRange), Is.True);
                Assert.That(DekRange.Contains(biggerDekRange), Is.False);

                // reverse
                var biggerReverseDekRange = new DekRange(DekRange.Stop + 1, DekRange.Start);
                Assert.That(biggerReverseDekRange.Contains(DekRange), Is.True);
                Assert.That(DekRange.Contains(biggerReverseDekRange), Is.False);
            }
        }