Ejemplo n.º 1
0
        public void ParseStatement_WhenBetweenDateTime_ExpectDateTimeParsed()
        {
            // Arrange
            var rangeParser = new RangeParser();

            // Act
            var stopwatch = Stopwatch.StartNew();
            var unaryNode = rangeParser.ParseStatement("{2018-1-2T10:11:11,2018-1-2T10:11:13}");

            stopwatch.Stop();

            // Assert
            this.WriteTimeElapsed(stopwatch);

            Assert.That(unaryNode, Is.Not.Null);

            Assert.That(unaryNode, Is.TypeOf(typeof(RangeOperator)));

            var rangeNode = (RangeOperator)unaryNode;

            Assert.That(rangeNode.Name, Is.Null);

            Assert.That(rangeNode.Name, Is.Null);
            Assert.That(rangeNode.Lower, Is.EqualTo(new DateTime(2018, 1, 2, 10, 11, 11)));
            Assert.That(rangeNode.Upper, Is.EqualTo(new DateTime(2018, 1, 2, 10, 11, 13)));
            Assert.That(rangeNode.LowerInclusive, Is.True);
            Assert.That(rangeNode.UpperInclusive, Is.True);
        }
Ejemplo n.º 2
0
        public void ParseStatement_WhenNonInclusiveRange_ExpectCorrectRangeNode()
        {
            // Arrange
            var rangeParser = new RangeParser();

            // Act
            var stopwatch = Stopwatch.StartNew();
            var unaryNode = rangeParser.ParseStatement("[25,50]");

            stopwatch.Stop();

            // Assert
            this.WriteTimeElapsed(stopwatch);

            Assert.That(unaryNode, Is.Not.Null);

            Assert.That(unaryNode, Is.TypeOf(typeof(RangeOperator)));

            var rangeNode = (RangeOperator)unaryNode;

            Assert.That(rangeNode.Name, Is.Null);

            Assert.That(rangeNode.Lower, Is.EqualTo(25));
            Assert.That(rangeNode.Upper, Is.EqualTo(50));

            Assert.That(rangeNode.LowerInclusive, Is.False);
            Assert.That(rangeNode.UpperInclusive, Is.False);
        }
Ejemplo n.º 3
0
        public void ParseStatement_WhenGreatThanDateTime_ExpectDateTimeParsed()
        {
            // Arrange
            var rangeParser = new RangeParser();

            // Act
            var stopwatch = Stopwatch.StartNew();
            var unaryNode = rangeParser.ParseStatement("{2018-1-2T10:11:12,*}");

            stopwatch.Stop();

            // Assert
            this.WriteTimeElapsed(stopwatch);

            Assert.That(unaryNode, Is.Not.Null);

            Assert.That(unaryNode, Is.TypeOf(typeof(GreaterThanOperator)));

            var rangeNode = (GreaterThanOperator)unaryNode;

            Assert.That(rangeNode.Name, Is.Null);

            Assert.That(rangeNode.Name, Is.Null);
            Assert.That(rangeNode.Value, Is.EqualTo(new DateTime(2018, 1, 2, 10, 11, 12)));
            Assert.That(rangeNode.Inclusive, Is.True);
        }
Ejemplo n.º 4
0
        public void ParseStatement_WhenNonInclusiveWildcardUpper_ExpectCorrectGreaterThanNode()
        {
            // Arrange
            var rangeParser = new RangeParser();

            // Act
            var stopwatch = Stopwatch.StartNew();
            var unaryNode = rangeParser.ParseStatement("[10,*]");

            stopwatch.Stop();

            // Assert
            this.WriteTimeElapsed(stopwatch);

            Assert.That(unaryNode, Is.Not.Null);

            Assert.That(unaryNode, Is.TypeOf(typeof(GreaterThanOperator)));

            var rangeNode = (GreaterThanOperator)unaryNode;

            Assert.That(rangeNode.Name, Is.Null);
            Assert.That(rangeNode.Value, Is.EqualTo(10));
            Assert.That(rangeNode.Inclusive, Is.False);
        }