Exemplo n.º 1
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;
        }
Exemplo n.º 2
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");
        }
Exemplo n.º 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");
        }
Exemplo n.º 4
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");
        }
Exemplo n.º 5
0
        public void Read_Parameter_Returns_True_Only_Once_For_One_Parameter()
        {
            const string input = "ATTENDEE;[email protected]:mailto:[email protected]";

            VCardLineReader lr = new VCardLineReader(input);

            string n; string v;

            Assert.IsTrue(lr.ReadParameter(out n, out v), "1");

            Assert.IsFalse(lr.ReadParameter(out n, out v), "2");
        }
Exemplo n.º 6
0
        public void Read_Parameter_Returns_False_If_There_Are_No_Parameters()
        {
            const string input = "ATTENDEE:mailto:[email protected]";

            VCardLineReader lr = new VCardLineReader(input);

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

            Assert.IsFalse(gotParam, "Retrieved Parameter");
        }
Exemplo n.º 7
0
        public void Read_Parameter_Fails_For_Group_Beginning()
        {
            const string input = "BEGIN:VCARD";

            VCardLineReader lr = new VCardLineReader(input);

            string n; string v;
            lr.ReadParameter(out n, out v);
        }
Exemplo n.º 8
0
        public void Line_With_Param_Separator_But_No_Value_Separator_Fails()
        {
            const string input = "CREATED;P=20101114T222754Z";

            VCardLineReader lr = new VCardLineReader(input);

            string n; string v;
            lr.ReadParameter(out n, out v);
        }