コード例 #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
        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);
        }
コード例 #3
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);
        }