当前位置: 首页>>代码示例>>C#>>正文


C# DnaTestURLRequest.ClearCookieContainer方法代码示例

本文整理汇总了C#中Tests.DnaTestURLRequest.ClearCookieContainer方法的典型用法代码示例。如果您正苦于以下问题:C# DnaTestURLRequest.ClearCookieContainer方法的具体用法?C# DnaTestURLRequest.ClearCookieContainer怎么用?C# DnaTestURLRequest.ClearCookieContainer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tests.DnaTestURLRequest的用法示例。


在下文中一共展示了DnaTestURLRequest.ClearCookieContainer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateCommentForum_CreateCommentAsNonAgreedTermsAndConditionsUser

        public void CreateCommentForum_CreateCommentAsNonAgreedTermsAndConditionsUser()
        {
            Console.WriteLine("Before CreateCommentAsNonAgreedTermsAndConditionsUser");

            var request = new DnaTestURLRequest("identity606");

            string userName = "CommentForumCreateUser" + DateTime.Now.Ticks;
            string userEmail = userName + "@bbc.co.uk";
            request.SetCurrentUserSuperUser();
            /*
            Assert.IsTrue(
                request.SetCurrentUserAsNewIdentityUser(userName, "password", "Comment User", userEmail, "1989-12-31",
                                                        TestUserCreator.IdentityPolicies.Adult, "identity606",
                                                        TestUserCreator.UserType.SuperUser),
                "Failed to create a test identity user");
            */
            string id = "FunctiontestCommentForum-" + Guid.NewGuid(); //have to randomize the string to post
            string title = "Functiontest Title";
            string parentUri = "http://www.bbc.co.uk/dna/h2g2/";
            string commentForumXml = String.Format("<commentForum xmlns=\"BBC.Dna.Api\">" +
                                                   "<id>{0}</id>" +
                                                   "<title>{1}</title>" +
                                                   "<parentUri>{2}</parentUri>" +
                                                   "</commentForum>", id, title, parentUri);

            // Setup the request url
            string url = String.Format("http://" + _server + "/dna/api/comments/CommentsService.svc/V1/site/{0}/",
                                       "identity606");

            try
            {
                // now get the response
                request.RequestPageWithFullURL(url, commentForumXml, "text/xml");
            }
            catch
            {
            }
            ;

            Assert.IsTrue(request.CurrentWebResponse.StatusCode == HttpStatusCode.OK);

            userName = "CommentCreateUser" + DateTime.Now.Ticks;
            userEmail = userName + "@bbc.co.uk";
            //Assert.IsTrue(request.SetCurrentUserAsNewIdentityUser(userName, "password", "Comment User", userEmail, "1989-12-31", TestUserCreator.IdentityPolicies.Adult, true, false, 1, false), "Failed to create a test identity user");

            Cookie cookie;
            Cookie secureCookie;
            string identityUserID;
            Assert.IsTrue(TestUserCreator.CreateIdentityUser(userName, "password", "1989-12-31", userEmail,
                                                             "Comment User", true,
                                                             TestUserCreator.IdentityPolicies.Adult, false, 0,
                                                             out cookie,
                                                             out secureCookie,
                                                             out identityUserID));

            request.UseDebugUser = false;
            request.ClearCookieContainer();
            request.UseIdentitySignIn = true;

            request.CurrentCookie = cookie.Value;
            request.CurrentSecureCookie = secureCookie.Value;

            string text = "Functiontest Title" + Guid.NewGuid();
            commentForumXml = String.Format("<comment xmlns=\"BBC.Dna.Api\">" +
                                            "<text>{0}</text>" +
                                            "</comment>", text);

            // Setup the comment request url - needs to be secure
            url =
                String.Format(
                    "https://" + _secureServer + "/dna/api/comments/CommentsService.svc/V1/site/{0}/commentsforums/{1}/",
                    "identity606", id);

            try
            {
                // now get the response
                request.RequestPageWithFullURL(url, commentForumXml, "text/xml");
            }
            catch
            {
            }
            ;

            Assert.IsTrue(request.CurrentWebResponse.StatusCode == HttpStatusCode.Unauthorized);

            // Check to make sure that the page returned with the correct information
            XmlDocument xml = request.GetLastResponseAsXML();

            var nsmgr = new XmlNamespaceManager(xml.NameTable);
            nsmgr.AddNamespace("bda", "BBC.Dna.Api");
            Assert.IsNotNull(xml.SelectSingleNode("//bda:error/bda:code", nsmgr), "Failed to find the error code");
            Assert.AreEqual("FailedTermsAndConditions", xml.SelectSingleNode("//bda:error/bda:code", nsmgr).InnerText);
            Assert.IsNotNull(xml.SelectSingleNode("//bda:error/bda:detail", nsmgr), "Failed to find the error deatils");
            Assert.AreEqual("comment",
                            xml.SelectSingleNode("//bda:error/bda:detail", nsmgr).InnerText);

            Console.WriteLine("After CreateCommentAsNonAgreedTermsAndConditionsUser");
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:98,代码来源:commentforums_v1.cs


注:本文中的Tests.DnaTestURLRequest.ClearCookieContainer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。