Пример #1
0
        public void Annotation_Parse_HandlesCompositeTokens()
        {
            TestAnnotation annotation = new TestAnnotation();

            Assert.Null(annotation.Date);
            Assert.Null(annotation.Price);
            Assert.Null(annotation.ValueExpr);
            Assert.Null(annotation.Tag);

            string line = "{123} [2010/02/02] (mytag) ((2345))rest of string";

            annotation.Parse(ref line);

            Assert.Equal(new Date(2010, 2, 2), annotation.Date);

            Assert.NotNull(annotation.Price);
            Assert.Equal(1, annotation.PriceParseCallCounter);
            Assert.Equal("123", annotation.PriceParseArgument);
            Assert.False(annotation.IsPriceNotPerUnit);
            Assert.False(annotation.IsPriceFixated);

            Assert.Equal("mytag", annotation.Tag);

            Assert.NotNull(annotation.ValueExpr);
            Assert.Equal(1, annotation.CreateExprCallCounter);
            Assert.Equal("2345", annotation.CreateExprArgument);

            Assert.Equal("rest of string", line);
        }
Пример #2
0
        private void TestCtor(int offset, int length)
        {
            // Arrange

            // Act
            Annotation a = new TestAnnotation(offset, length);

            // Assert
        }
Пример #3
0
        public void TestGetHashCode()
        {
            // Arrange
            Annotation sut = new TestAnnotation(5, 7);

            // Act
            int result = sut.GetHashCode();

            // Assert
            Assert.AreNotEqual(0, result);
        }
Пример #4
0
        private void TestCompareTo(int offset1, int length1, int offset2, int length2, int exectedSign)
        {
            // Arrange
            IComparable <Annotation> a = new TestAnnotation(offset1, length1);
            Annotation b = new TestAnnotation(offset2, length2);

            // Act
            int result = a.CompareTo(b);

            // Assert
            Assert.AreEqual(exectedSign, Math.Sign(result));
        }
Пример #5
0
        private void TestIntersects(int offset1, int length1, int offset2, int length2, bool expectedResult)
        {
            // Arrange
            Annotation a = new TestAnnotation(offset1, length1);
            Annotation b = new TestAnnotation(offset2, length2);

            // Act
            bool result = a.Intersects(b);

            // Assert
            Assert.AreEqual(expectedResult, result);
        }
Пример #6
0
        public void Annotation_Parse_HandlesExpressions()
        {
            TestAnnotation annotation = new TestAnnotation();

            Assert.Null(annotation.ValueExpr);

            string line = "((12345))rest of string";

            annotation.Parse(ref line);

            Assert.NotNull(annotation.ValueExpr);
            Assert.Equal(1, annotation.CreateExprCallCounter);
            Assert.Equal("12345", annotation.CreateExprArgument);
            Assert.Equal("rest of string", line);
        }
Пример #7
0
        public void Annotation_Parse_HandlesPerUnitFixatedPrices()
        {
            TestAnnotation annotation = new TestAnnotation();

            Assert.Null(annotation.Price);
            Assert.False(annotation.IsPriceNotPerUnit);
            Assert.False(annotation.IsPriceFixated);

            string line = "{{=12345}}rest of string";

            annotation.Parse(ref line);

            Assert.Equal(1, annotation.PriceParseCallCounter);
            Assert.Equal("12345", annotation.PriceParseArgument);
            Assert.True(annotation.IsPriceNotPerUnit);
            Assert.True(annotation.IsPriceFixated);
            Assert.Equal("rest of string", line);
        }