Exemplo n.º 1
0
        public void TryParseLengthSuccess(SuccessData <Length> data)
        {
            Length actual;
            var    success = QuantityParser.TryParse <LengthUnit, Length>(
                data.Text,
                Length.From,
                NumberStyles.Float,
                data.CultureInfo,
                out actual);

            Assert.AreEqual(true, success);
            Assert.AreEqual(data.Expected, actual);

            success = Length.TryParse(data.Text, NumberStyles.Float, data.CultureInfo, out actual);
            Assert.AreEqual(true, success);
            Assert.AreEqual(data.Expected, actual);

            success = Length.TryParse(data.Text, data.CultureInfo, out actual);
            Assert.AreEqual(true, success);
            Assert.AreEqual(data.Expected, actual);

            using (Thread.CurrentThread.UsingTempCulture(data.CultureInfo))
            {
                success = Length.TryParse(data.Text, out actual);
                Assert.AreEqual(true, success);
                Assert.AreEqual(data.Expected, actual);
            }
        }
Exemplo n.º 2
0
        public void ReadSuccess(SuccessData <int> data)
        {
            var end    = data.Start;
            var actual = PowerReader.Read(data.Text, ref end);

            Assert.AreEqual(data.Expected, actual);
            Assert.AreEqual(data.ExpectedEnd, end);
        }
Exemplo n.º 3
0
        public void ParseSuccess(SuccessData <int> data)
        {
            int pos    = data.Start;
            var actual = IntReader.ReadInt32(data.Text, ref pos);

            Assert.AreEqual(actual, data.Expected);
            Assert.AreEqual(pos, data.ExpectedEnd);
        }
Exemplo n.º 4
0
        public void TryReadSuccess(SuccessData <int> data)
        {
            var end = data.Start;
            int actual;
            var success = PowerReader.TryRead(data.Text, ref end, out actual);

            Assert.AreEqual(true, success);
            Assert.AreEqual(data.Expected, actual);
            Assert.AreEqual(data.ExpectedEnd, end);
        }
Exemplo n.º 5
0
        public void TryParseSuccess(SuccessData <int> data)
        {
            int pos = data.Start;
            int actual;
            var success = IntReader.TryReadInt32(data.Text, ref pos, out actual);

            Assert.AreEqual(true, success);
            Assert.AreEqual(data.Expected, actual);
            Assert.AreEqual(data.ExpectedEnd, pos);
        }
Exemplo n.º 6
0
        public void ParseLengthSuccess(SuccessData <Length> data)
        {
            var numberStyles = NumberStyles.Float;

            var length = QuantityParser.Parse <LengthUnit, Length>(data.Text, Length.From, numberStyles, data.CultureInfo);

            Assert.AreEqual(data.Expected, length);

            length = Length.Parse(data.Text, numberStyles, data.CultureInfo);
            Assert.AreEqual(data.Expected, length);

            length = Length.Parse(data.Text, data.CultureInfo);
            Assert.AreEqual(data.Expected, length);

            using (Thread.CurrentThread.UsingTempCulture(data.CultureInfo))
            {
                length = Length.Parse(data.Text);
                Assert.AreEqual(data.Expected, length);
            }
        }