public void TestUpdate()
        {
            string body = null;
            WebDavQueryBuilder queryBuilder = new WebDavQueryBuilder();
            Property up2 = new Property("up2", "NS1");
            FreeBusyProperty up3 = new FreeBusyProperty("up3", "FB", "type1");
            FreeBusyProperty up4 = new FreeBusyProperty("up4", "MV", "mv.type2");
            FreeBusyProperty up5 = new FreeBusyProperty("up5", "MV", "mv.type5");
            List<string> emptyList = new List<string>();
            List<string> up4Values = new List<string>();
            List<string> up5Values = new List<string>();
            string expectedBody =
                "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<a:propertyupdate " +
                "xmlns:a=\"DAV:\" " +
                "xmlns:b=\"urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/\" " +
                "xmlns:c=\"xml:\" " +
                "xmlns:d=\"NS1\" " +
                "xmlns:e=\"FB\" " +
                "xmlns:f=\"MV\">" +
                "<a:set>" +
                "<a:prop>" +
                "<a:up1>" +
                "1" +
                "</a:up1>" +
                "<d:up2>" +
                "2" +
                "</d:up2>" +
                "<e:up3 b:dt=\"type1\">" +
                "3" +
                "</e:up3>" +
                "<f:up4 b:dt=\"mv.type2\">" +
                "<c:v>" +
                "one" +
                "</c:v>" +
                "</f:up4>" +
                "<f:up5 b:dt=\"mv.type5\">" +
                "<c:v>" +
                "0x1234" +
                "</c:v>" +
                "<c:v>" +
                "0xabcd" +
                "</c:v>" +
                "</f:up5>" +
                "</a:prop>" +
                "</a:set>" +
                "</a:propertyupdate>";

            up4Values.Add("one");

            up5Values.Add("0x1234");
            up5Values.Add("0xabcd");

            VerifyWellFormedXml(expectedBody);

            for (int i = 0; i < 2; i++)
            {
                bool exceptionCaught = false;
                try
                {
                    body = queryBuilder.BuildQueryBody();
                }
                catch (Exception)
                {
                    exceptionCaught = true;
                }
                Assert.IsTrue(exceptionCaught);

                queryBuilder.AddUpdateProperty("up1", "DAV:", "1");
                queryBuilder.AddUpdateProperty(up2, "2");
                queryBuilder.AddUpdateProperty(up3, "3");

                try
                {
                    queryBuilder.AddUpdateProperty(up4, emptyList);
                }
                catch (Exception)
                {
                    exceptionCaught = true;
                }
                Assert.IsTrue(exceptionCaught);

                queryBuilder.AddUpdateProperty(up4, up4Values);
                queryBuilder.AddUpdateProperty(up5, up5Values);

                body = queryBuilder.BuildQueryBody();
                VerifyWellFormedXml(body);
                Assert.IsTrue(CompareXml(body, expectedBody));
                queryBuilder.Reset();
            }
        }
Exemplo n.º 2
0
        public void TestUpdate()
        {
            string             body         = null;
            WebDavQueryBuilder queryBuilder = new WebDavQueryBuilder();
            Property           up2          = new Property("up2", "NS1");
            FreeBusyProperty   up3          = new FreeBusyProperty("up3", "FB", "type1");
            FreeBusyProperty   up4          = new FreeBusyProperty("up4", "MV", "mv.type2");
            FreeBusyProperty   up5          = new FreeBusyProperty("up5", "MV", "mv.type5");
            List <string>      emptyList    = new List <string>();
            List <string>      up4Values    = new List <string>();
            List <string>      up5Values    = new List <string>();
            string             expectedBody =
                "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<a:propertyupdate " +
                "xmlns:a=\"DAV:\" " +
                "xmlns:b=\"urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/\" " +
                "xmlns:c=\"xml:\" " +
                "xmlns:d=\"NS1\" " +
                "xmlns:e=\"FB\" " +
                "xmlns:f=\"MV\">" +
                "<a:set>" +
                "<a:prop>" +
                "<a:up1>" +
                "1" +
                "</a:up1>" +
                "<d:up2>" +
                "2" +
                "</d:up2>" +
                "<e:up3 b:dt=\"type1\">" +
                "3" +
                "</e:up3>" +
                "<f:up4 b:dt=\"mv.type2\">" +
                "<c:v>" +
                "one" +
                "</c:v>" +
                "</f:up4>" +
                "<f:up5 b:dt=\"mv.type5\">" +
                "<c:v>" +
                "0x1234" +
                "</c:v>" +
                "<c:v>" +
                "0xabcd" +
                "</c:v>" +
                "</f:up5>" +
                "</a:prop>" +
                "</a:set>" +
                "</a:propertyupdate>";

            up4Values.Add("one");

            up5Values.Add("0x1234");
            up5Values.Add("0xabcd");

            VerifyWellFormedXml(expectedBody);

            for (int i = 0; i < 2; i++)
            {
                bool exceptionCaught = false;
                try
                {
                    body = queryBuilder.BuildQueryBody();
                }
                catch (Exception)
                {
                    exceptionCaught = true;
                }
                Assert.IsTrue(exceptionCaught);

                queryBuilder.AddUpdateProperty("up1", "DAV:", "1");
                queryBuilder.AddUpdateProperty(up2, "2");
                queryBuilder.AddUpdateProperty(up3, "3");

                try
                {
                    queryBuilder.AddUpdateProperty(up4, emptyList);
                }
                catch (Exception)
                {
                    exceptionCaught = true;
                }
                Assert.IsTrue(exceptionCaught);

                queryBuilder.AddUpdateProperty(up4, up4Values);
                queryBuilder.AddUpdateProperty(up5, up5Values);

                body = queryBuilder.BuildQueryBody();
                VerifyWellFormedXml(body);
                Assert.IsTrue(CompareXml(body, expectedBody));
                queryBuilder.Reset();
            }
        }
        public void TestUpdateAndRemove()
        {
            string body = null;
            WebDavQueryBuilder queryBuilder = new WebDavQueryBuilder();
            Property up2 = new Property("up2", "NS1");
            FreeBusyProperty up3 = new FreeBusyProperty("up3", "FB", "type1");
            Property del2 = new Property("del2", "NS2");
            FreeBusyProperty del3 = new FreeBusyProperty("del3", "FB", "type2");
            string expectedBody =
                "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<a:propertyupdate " +
                "xmlns:a=\"DAV:\" " +
                "xmlns:b=\"urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/\" " +
                "xmlns:c=\"xml:\" " +
                "xmlns:d=\"NS1\" " +
                "xmlns:e=\"FB\" " +
                "xmlns:f=\"NS2\">" +
                "<a:set>" +
                "<a:prop>" +
                "<a:up1>" +
                "1" +
                "</a:up1>" +
                "<d:up2>" +
                "2" +
                "</d:up2>" +
                "<e:up3 b:dt=\"type1\">" +
                "3" +
                "</e:up3>" +
                "</a:prop>" +
                "</a:set>" +
                "<a:remove>" +
                "<a:prop>" +
                "<d:del1/>" +
                "<f:del2/>" +
                "<e:del3/>" +
                "</a:prop>" +
                "</a:remove>" +
                "</a:propertyupdate>";

            VerifyWellFormedXml(expectedBody);

            for (int i = 0; i < 2; i++)
            {
                bool exceptionCaught = false;
                try
                {
                    body = queryBuilder.BuildQueryBody();
                }
                catch (Exception)
                {
                    exceptionCaught = true;
                }
                Assert.IsTrue(exceptionCaught);

                queryBuilder.AddUpdateProperty("up1", "DAV:", "1");
                queryBuilder.AddUpdateProperty(up2, "2");
                queryBuilder.AddUpdateProperty(up3, "3");

                queryBuilder.AddRemoveProperty("del1", "NS1");
                queryBuilder.AddRemoveProperty(del2);
                queryBuilder.AddRemoveProperty(del3);

                body = queryBuilder.BuildQueryBody();
                VerifyWellFormedXml(body);
                Assert.IsTrue(CompareXml(body, expectedBody));
                queryBuilder.Reset();
            }
        }
Exemplo n.º 4
0
        public void TestUpdateAndRemove()
        {
            string             body         = null;
            WebDavQueryBuilder queryBuilder = new WebDavQueryBuilder();
            Property           up2          = new Property("up2", "NS1");
            FreeBusyProperty   up3          = new FreeBusyProperty("up3", "FB", "type1");
            Property           del2         = new Property("del2", "NS2");
            FreeBusyProperty   del3         = new FreeBusyProperty("del3", "FB", "type2");
            string             expectedBody =
                "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<a:propertyupdate " +
                "xmlns:a=\"DAV:\" " +
                "xmlns:b=\"urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/\" " +
                "xmlns:c=\"xml:\" " +
                "xmlns:d=\"NS1\" " +
                "xmlns:e=\"FB\" " +
                "xmlns:f=\"NS2\">" +
                "<a:set>" +
                "<a:prop>" +
                "<a:up1>" +
                "1" +
                "</a:up1>" +
                "<d:up2>" +
                "2" +
                "</d:up2>" +
                "<e:up3 b:dt=\"type1\">" +
                "3" +
                "</e:up3>" +
                "</a:prop>" +
                "</a:set>" +
                "<a:remove>" +
                "<a:prop>" +
                "<d:del1/>" +
                "<f:del2/>" +
                "<e:del3/>" +
                "</a:prop>" +
                "</a:remove>" +
                "</a:propertyupdate>";

            VerifyWellFormedXml(expectedBody);

            for (int i = 0; i < 2; i++)
            {
                bool exceptionCaught = false;
                try
                {
                    body = queryBuilder.BuildQueryBody();
                }
                catch (Exception)
                {
                    exceptionCaught = true;
                }
                Assert.IsTrue(exceptionCaught);

                queryBuilder.AddUpdateProperty("up1", "DAV:", "1");
                queryBuilder.AddUpdateProperty(up2, "2");
                queryBuilder.AddUpdateProperty(up3, "3");

                queryBuilder.AddRemoveProperty("del1", "NS1");
                queryBuilder.AddRemoveProperty(del2);
                queryBuilder.AddRemoveProperty(del3);

                body = queryBuilder.BuildQueryBody();
                VerifyWellFormedXml(body);
                Assert.IsTrue(CompareXml(body, expectedBody));
                queryBuilder.Reset();
            }
        }