• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Mocks.TestDirectedMessage类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中DotNetOpenAuth.Test.Mocks.TestDirectedMessage的典型用法代码示例。如果您正苦于以下问题:C# TestDirectedMessage类的具体用法?C# TestDirectedMessage怎么用?C# TestDirectedMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TestDirectedMessage类属于DotNetOpenAuth.Test.Mocks命名空间,在下文中一共展示了TestDirectedMessage类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: SendIndirectMessage301Get

		public void SendIndirectMessage301Get() {
			TestDirectedMessage message = new TestDirectedMessage(MessageTransport.Indirect);
			GetStandardTestMessage(FieldFill.CompleteBeforeBindings, message);
			message.Recipient = new Uri("http://provider/path");
			var expected = GetStandardTestFields(FieldFill.CompleteBeforeBindings);

			OutgoingWebResponse response = this.Channel.PrepareResponse(message);
			Assert.AreEqual(HttpStatusCode.Redirect, response.Status);
			StringAssert.StartsWith("http://provider/path", response.Headers[HttpResponseHeader.Location]);
			foreach (var pair in expected) {
				string key = MessagingUtilities.EscapeUriDataStringRfc3986(pair.Key);
				string value = MessagingUtilities.EscapeUriDataStringRfc3986(pair.Value);
				string substring = string.Format("{0}={1}", key, value);
				StringAssert.Contains(substring, response.Headers[HttpResponseHeader.Location]);
			}
		}
开发者ID:jsmale,项目名称:dotnetopenid,代码行数:16,代码来源:ChannelTests.cs


示例2: SendIndirectMessage301Get

		public void SendIndirectMessage301Get() {
			TestDirectedMessage message = new TestDirectedMessage(MessageTransport.Indirect);
			GetStandardTestMessage(FieldFill.CompleteBeforeBindings, message);
			message.Recipient = new Uri("http://provider/path");
			var expected = GetStandardTestFields(FieldFill.CompleteBeforeBindings);

			OutgoingWebResponse response = this.Channel.PrepareResponse(message);
			Assert.AreEqual(HttpStatusCode.Redirect, response.Status);
			Assert.AreEqual("text/html; charset=utf-8", response.Headers[HttpResponseHeader.ContentType]);
			Assert.IsTrue(response.Body != null && response.Body.Length > 0); // a non-empty body helps get passed filters like WebSense
			StringAssert.StartsWith("http://provider/path", response.Headers[HttpResponseHeader.Location]);
			foreach (var pair in expected) {
				string key = MessagingUtilities.EscapeUriDataStringRfc3986(pair.Key);
				string value = MessagingUtilities.EscapeUriDataStringRfc3986(pair.Value);
				string substring = string.Format("{0}={1}", key, value);
				StringAssert.Contains(substring, response.Headers[HttpResponseHeader.Location]);
			}
		}
开发者ID:OneCare,项目名称:dotnetopenid,代码行数:18,代码来源:ChannelTests.cs


示例3: GetNewRequestMessage

		public IDirectedProtocolMessage GetNewRequestMessage(MessageReceivingEndpoint recipient, IDictionary<string, string> fields) {
			if (fields.ContainsKey("age")) {
				if (this.signedMessages) {
					if (this.expiringMessages) {
						if (this.replayMessages) {
							return new TestReplayProtectedMessage();
						}
						return new TestExpiringMessage();
					}
					return new TestSignedDirectedMessage();
				}
				var result = new TestDirectedMessage();
				if (fields.ContainsKey("GetOnly")) {
					result.HttpMethods = HttpDeliveryMethods.GetRequest;
				}
				return result;
			}
			return null;
		}
开发者ID:jongalloway,项目名称:dotnetopenid,代码行数:19,代码来源:TestMessageFactory.cs


示例4: SendInvalidMessageTransport

 public void SendInvalidMessageTransport()
 {
     IProtocolMessage message = new TestDirectedMessage((MessageTransport)100);
     this.Channel.PrepareResponse(message);
 }
开发者ID:jcp-xx,项目名称:dotnetopenid,代码行数:5,代码来源:ChannelTests.cs


示例5: SendIndirectMessageFormPostNullFields

 public void SendIndirectMessageFormPostNullFields()
 {
     TestBadChannel badChannel = new TestBadChannel(false);
     var message = new TestDirectedMessage(MessageTransport.Indirect);
     message.Recipient = new Uri("http://someserver");
     badChannel.CreateFormPostResponse(message, null);
 }
开发者ID:jcp-xx,项目名称:dotnetopenid,代码行数:7,代码来源:ChannelTests.cs


示例6: SendIndirectMessageFormPostEmptyRecipient

 public void SendIndirectMessageFormPostEmptyRecipient()
 {
     TestBadChannel badChannel = new TestBadChannel(false);
     var message = new TestDirectedMessage(MessageTransport.Indirect);
     badChannel.CreateFormPostResponse(message, new Dictionary<string, string>());
 }
开发者ID:jcp-xx,项目名称:dotnetopenid,代码行数:6,代码来源:ChannelTests.cs


示例7: SendIndirectMessageFormPost

 public void SendIndirectMessageFormPost()
 {
     // We craft a very large message to force fallback to form POST.
     // We'll also stick some HTML reserved characters in the string value
     // to test proper character escaping.
     var message = new TestDirectedMessage(MessageTransport.Indirect) {
         Age = 15,
         Name = "c<b" + new string('a', 10 * 1024),
         Location = new Uri("http://host/path"),
         Recipient = new Uri("http://provider/path"),
     };
     OutgoingWebResponse response = this.Channel.PrepareResponse(message);
     Assert.AreEqual(HttpStatusCode.OK, response.Status, "A form redirect should be an HTTP successful response.");
     Assert.IsNull(response.Headers[HttpResponseHeader.Location], "There should not be a redirection header in the response.");
     string body = response.Body;
     StringAssert.Contains(body, "<form ");
     StringAssert.Contains(body, "action=\"http://provider/path\"");
     StringAssert.Contains(body, "method=\"post\"");
     StringAssert.Contains(body, "<input type=\"hidden\" name=\"age\" value=\"15\" />");
     StringAssert.Contains(body, "<input type=\"hidden\" name=\"Location\" value=\"http://host/path\" />");
     StringAssert.Contains(body, "<input type=\"hidden\" name=\"Name\" value=\"" + HttpUtility.HtmlEncode(message.Name) + "\" />");
     StringAssert.Contains(body, ".submit()", "There should be some javascript to automate form submission.");
 }
开发者ID:jcp-xx,项目名称:dotnetopenid,代码行数:23,代码来源:ChannelTests.cs


示例8: RequestUsingAuthorizationHeaderScattered

		public void RequestUsingAuthorizationHeaderScattered() {
			TestDirectedMessage request = new TestDirectedMessage(MessageTransport.Direct) {
				Age = 15,
				Name = "Andrew",
				Location = new Uri("http://hostb/pathB"),
				Recipient = new Uri("http://localtest"),
				Timestamp = DateTime.UtcNow,
				HttpMethods = HttpDeliveryMethods.AuthorizationHeaderRequest,
			};

			// ExtraData should appear in the form since this is a POST request,
			// and only official message parts get a place in the Authorization header.
			((IProtocolMessage)request).ExtraData["appearinform"] = "formish";
			request.Recipient = new Uri("http://localhost/?appearinquery=queryish");
			request.HttpMethods = HttpDeliveryMethods.AuthorizationHeaderRequest | HttpDeliveryMethods.PostRequest;

			HttpWebRequest webRequest = this.channel.InitializeRequest(request);
			Assert.IsNotNull(webRequest);
			Assert.AreEqual("POST", webRequest.Method);
			Assert.AreEqual(request.Recipient, webRequest.RequestUri);

			var declaredParts = new Dictionary<string, string> {
					{ "age", request.Age.ToString() },
					{ "Name", request.Name },
					{ "Location", request.Location.AbsoluteUri },
					{ "Timestamp", XmlConvert.ToString(request.Timestamp, XmlDateTimeSerializationMode.Utc) },
				};

			Assert.AreEqual(CreateAuthorizationHeader(declaredParts), webRequest.Headers[HttpRequestHeader.Authorization]);
			Assert.AreEqual("appearinform=formish", this.webRequestHandler.RequestEntityAsString);
		}
开发者ID:CooPzZ,项目名称:dotnetopenid,代码行数:31,代码来源:OAuthChannelTests.cs


示例9: RequestNullRecipient

		public void RequestNullRecipient() {
			IDirectedProtocolMessage message = new TestDirectedMessage(MessageTransport.Direct);
			this.channel.Request(message);
		}
开发者ID:CooPzZ,项目名称:dotnetopenid,代码行数:4,代码来源:OAuthChannelTests.cs


示例10: RequestBadPreferredScheme

		public async Task RequestBadPreferredScheme() {
			TestDirectedMessage message = new TestDirectedMessage(MessageTransport.Direct);
			message.Recipient = new Uri("http://localtest");
			message.HttpMethods = HttpDeliveryMethods.None;
			await this.channel.RequestAsync(message, CancellationToken.None);
		}
开发者ID:hnlshzx,项目名称:DotNetOpenAuth,代码行数:6,代码来源:OAuthChannelTests.cs


示例11: RequestNullRecipient

		public async Task RequestNullRecipient() {
			IDirectedProtocolMessage message = new TestDirectedMessage(MessageTransport.Direct);
			await this.channel.RequestAsync(message, CancellationToken.None);
		}
开发者ID:hnlshzx,项目名称:DotNetOpenAuth,代码行数:4,代码来源:OAuthChannelTests.cs


示例12: SendDirectMessageResponse

		public async Task SendDirectMessageResponse() {
			IProtocolMessage message = new TestDirectedMessage {
				Age = 15,
				Name = "Andrew",
				Location = new Uri("http://hostb/pathB"),
			};

			var response = await this.channel.PrepareResponseAsync(message);
			Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
			Assert.AreEqual(Channel.HttpFormUrlEncodedContentType.MediaType, response.Content.Headers.ContentType.MediaType);

			NameValueCollection body = HttpUtility.ParseQueryString(await response.Content.ReadAsStringAsync());
			Assert.AreEqual("15", body["age"]);
			Assert.AreEqual("Andrew", body["Name"]);
			Assert.AreEqual("http://hostb/pathB", body["Location"]);
		}
开发者ID:hnlshzx,项目名称:DotNetOpenAuth,代码行数:16,代码来源:OAuthChannelTests.cs


示例13: GetStandardTestMessage

		internal static TestMessage GetStandardTestMessage(FieldFill fill) {
			TestMessage message = new TestDirectedMessage();
			GetStandardTestMessage(fill, message);
			return message;
		}
开发者ID:437072341,项目名称:dotnetopenid,代码行数:5,代码来源:MessagingTestBase.cs


示例14: SendInvalidMessageTransport

		public async Task SendInvalidMessageTransport() {
			IProtocolMessage message = new TestDirectedMessage((MessageTransport)100);
			await this.Channel.PrepareResponseAsync(message);
		}
开发者ID:Balamir,项目名称:DotNetOpenAuth,代码行数:4,代码来源:ChannelTests.cs


示例15: SendDirectedNoRecipientMessage

		public async Task SendDirectedNoRecipientMessage() {
			IProtocolMessage message = new TestDirectedMessage(MessageTransport.Indirect);
			await this.Channel.PrepareResponseAsync(message);
		}
开发者ID:Balamir,项目名称:DotNetOpenAuth,代码行数:4,代码来源:ChannelTests.cs


示例16: DirectResponseMessageMock

			internal DirectResponseMessageMock(TestDirectedMessage request) {
				this.OriginatingRequest = request;
			}
开发者ID:hnlshzx,项目名称:DotNetOpenAuth,代码行数:3,代码来源:StandardMessageFactoryTests.cs


示例17: SendDirectMessageResponse

		public void SendDirectMessageResponse() {
			IProtocolMessage message = new TestDirectedMessage {
				Age = 15,
				Name = "Andrew",
				Location = new Uri("http://hostb/pathB"),
			};

			OutgoingWebResponse response = this.channel.PrepareResponse(message);
			Assert.AreSame(message, response.OriginalMessage);
			Assert.AreEqual(HttpStatusCode.OK, response.Status);
			Assert.AreEqual(2, response.Headers.Count);

			NameValueCollection body = HttpUtility.ParseQueryString(response.Body);
			Assert.AreEqual("15", body["age"]);
			Assert.AreEqual("Andrew", body["Name"]);
			Assert.AreEqual("http://hostb/pathB", body["Location"]);
		}
开发者ID:CooPzZ,项目名称:dotnetopenid,代码行数:17,代码来源:OAuthChannelTests.cs


示例18: ParameterizedRequestTestAsync

		private async Task ParameterizedRequestTestAsync(HttpDeliveryMethods scheme) {
			var request = new TestDirectedMessage(MessageTransport.Direct) {
				Age = 15,
				Name = "Andrew",
				Location = new Uri("http://hostb/pathB"),
				Recipient = new Uri("http://localtest"),
				Timestamp = DateTime.UtcNow,
				HttpMethods = scheme,
			};

			Handle(request.Recipient).By(
				async (req, ct) => {
					Assert.IsNotNull(req);
					Assert.AreEqual(MessagingUtilities.GetHttpVerb(scheme), req.Method);
					var incomingMessage = (await this.channel.ReadFromRequestAsync(req, CancellationToken.None)) as TestMessage;
					Assert.IsNotNull(incomingMessage);
					Assert.AreEqual(request.Age, incomingMessage.Age);
					Assert.AreEqual(request.Name, incomingMessage.Name);
					Assert.AreEqual(request.Location, incomingMessage.Location);
					Assert.AreEqual(request.Timestamp, incomingMessage.Timestamp);

					var responseFields = new Dictionary<string, string> {
						{ "age", request.Age.ToString() },
						{ "Name", request.Name },
						{ "Location", request.Location.AbsoluteUri },
						{ "Timestamp", XmlConvert.ToString(request.Timestamp, XmlDateTimeSerializationMode.Utc) },
					};
					var rawResponse = new HttpResponseMessage();
					rawResponse.Content = new StringContent(MessagingUtilities.CreateQueryString(responseFields));
					return rawResponse;
				});

			IProtocolMessage response = await this.channel.RequestAsync(request, CancellationToken.None);
			Assert.IsNotNull(response);
			Assert.IsInstanceOf<TestMessage>(response);
			TestMessage responseMessage = (TestMessage)response;
			Assert.AreEqual(request.Age, responseMessage.Age);
			Assert.AreEqual(request.Name, responseMessage.Name);
			Assert.AreEqual(request.Location, responseMessage.Location);
		}
开发者ID:hnlshzx,项目名称:DotNetOpenAuth,代码行数:40,代码来源:OAuthChannelTests.cs


示例19: RequestBadPreferredScheme

		public void RequestBadPreferredScheme() {
			TestDirectedMessage message = new TestDirectedMessage(MessageTransport.Direct);
			message.Recipient = new Uri("http://localtest");
			message.HttpMethods = HttpDeliveryMethods.None;
			this.channel.Request(message);
		}
开发者ID:CooPzZ,项目名称:dotnetopenid,代码行数:6,代码来源:OAuthChannelTests.cs


示例20: SendDirectMessageResponse

 public void SendDirectMessageResponse()
 {
     IProtocolMessage message = new TestDirectedMessage {
         Age = 15,
         Name = "Andrew",
         Location = new Uri("http://host/path"),
     };
     this.Channel.PrepareResponse(message);
 }
开发者ID:jcp-xx,项目名称:dotnetopenid,代码行数:9,代码来源:ChannelTests.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# DotNetWikiBot.Page类代码示例发布时间:2022-05-24
下一篇:
C# RelyingParty.OpenIdRelyingParty类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap