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


C# Mocks.TestDirectedMessage类代码示例

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


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


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