Пример #1
0
        public void Detect_Normal_Value()
        {
            const string input = "CREATED:20101114T222754Z";
            const string expectedName = "CREATED";
            const string expectedValue = "20101114T222754Z";

            VCardLineReader lr = new VCardLineReader(input);

            Assert.AreEqual(VCardLineType.Value, lr.Type, "Type");
            Assert.AreEqual(expectedName, lr.Name, "Name");
            Assert.AreEqual(expectedValue, lr.GetEscapedValue(), "EscapedValue");
        }
Пример #2
0
        private VCardValue GetValueFromLine(VCardLineReader line)
        {
            VCardValue value = new VCardValue(line.Name);

            string paramName;
            string paramEscapedValue;
            while (line.ReadParameter(out paramName, out paramEscapedValue))
                value.Parameters.Add(new VCardSimpleValue(paramName, paramEscapedValue));

            value.EscapedValue = line.GetEscapedValue();

            return value;
        }
Пример #3
0
        public void Read_Value_With_Two_Parameters()
        {
            const string input = "Name;P1=V1;P2=V2:Value";

            VCardLineReader lr = new VCardLineReader(input);
            Assert.AreEqual("Name", lr.Name, "Name");

            string name; string value; bool gotParam;

            gotParam = lr.ReadParameter(out name, out value);

            Assert.IsTrue(gotParam, "P1: Read Parameter");
            Assert.AreEqual("P1", name, "P1: Name");
            Assert.AreEqual("V1", value, "P1: Value");

            gotParam = lr.ReadParameter(out name, out value);

            Assert.IsTrue(gotParam, "P2: Read Parameter");
            Assert.AreEqual("P2", name, "P2: Name");
            Assert.AreEqual("V2", value, "P2: Value");

            gotParam = lr.ReadParameter(out name, out value);
            Assert.IsFalse(gotParam, "P3: Read Parameter");

            value = lr.GetEscapedValue();
            Assert.AreEqual("Value", value, "Value");
        }
Пример #4
0
        public void Read_Value_With_Parameter()
        {
            const string input = "ATTENDEE;[email protected]:mailto:[email protected]";
            const string expectedName = "ATTENDEE";
            const string expectedParamName = "CN";
            const string expectedParamValue = "*****@*****.**";
            const string expectedValue = "mailto:[email protected]";

            VCardLineReader lr = new VCardLineReader(input);

            string actualParamName; string actualParamValue;
            bool gotParam = lr.ReadParameter(out actualParamName, out actualParamValue);

            string actualValue = lr.GetEscapedValue();

            Assert.AreEqual(VCardLineType.Value, lr.Type, "Type");
            Assert.AreEqual(expectedName, lr.Name, "Name");

            Assert.IsTrue(gotParam, "Retrieved Parameter");
            Assert.AreEqual(expectedParamName, actualParamName, "Parameter Name");
            Assert.AreEqual(expectedParamValue, actualParamValue, "Parameter Value");

            Assert.AreEqual(expectedValue, actualValue, "EscapedValue");
        }
Пример #5
0
        public void Read_Value_With_Escaped_Semicolon()
        {
            const string input = @"RANDOMTEXT:before\;after";
            const string expectedValue = @"before\;after";

            VCardLineReader lr = new VCardLineReader(input);
            string actualValue = lr.GetEscapedValue();

            Assert.AreEqual(expectedValue, actualValue, "EscapedValue");
        }
Пример #6
0
        public void Read_Value_Fails_If_You_Havent_Read_All_Parameters_First()
        {
            const string input = "ATTENDEE;[email protected]:mailto:[email protected]";

            VCardLineReader lr = new VCardLineReader(input);

            lr.GetEscapedValue();
        }
Пример #7
0
        public void Read_Value_Fails_For_Group_Beginning()
        {
            const string input = "BEGIN:VCARD";

            VCardLineReader lr = new VCardLineReader(input);
            lr.GetEscapedValue();
        }
Пример #8
0
        public void Read_Parameter_With_Escaped_Colon()
        {
            const string input = @"SOMEVAL;Param=My\:Value:MyText";
            const string expectedParamName = "Param";
            const string expectedParamValue = @"My\:Value";

            VCardLineReader lr = new VCardLineReader(input);

            string actualParamName; string actualParamValue;
            bool gotParam = lr.ReadParameter(out actualParamName, out actualParamValue);

            string actualValue = lr.GetEscapedValue();

            Assert.IsTrue(gotParam, "Retrieved Parameter");
            Assert.AreEqual(expectedParamName, actualParamName, "Parameter Name");
            Assert.AreEqual(expectedParamValue, actualParamValue, "Parameter Value");
        }