本文整理汇总了C#中XDoc.ToCompactString方法的典型用法代码示例。如果您正苦于以下问题:C# XDoc.ToCompactString方法的具体用法?C# XDoc.ToCompactString怎么用?C# XDoc.ToCompactString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XDoc
的用法示例。
在下文中一共展示了XDoc.ToCompactString方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Can_list_directory
public void Can_list_directory()
{
var doc = new XDoc("files").Elem("x", StringUtil.CreateAlphaNumericKey(10));
_s3ClientMock.Setup(x => x.GetDataInfo(_storageRoot + "/foo/bar/", false)).Returns(new AmazonS3DataInfo(doc)).AtMostOnce().Verifiable();
var response = _mockService.CallStorage(storage =>
storage.At("foo", "bar").WithTrailingSlash().Get(new Result<DreamMessage>())
);
Assert.IsTrue(response.IsSuccessful);
Assert.AreEqual(doc.ToCompactString(), response.ToDocument().ToCompactString());
_s3ClientMock.VerifyAll();
}
示例2: Can_use_xdoc_as_feature_return_type
public void Can_use_xdoc_as_feature_return_type()
{
var msg = new XDoc("doc").Elem("woot", "true");
var response = _plug.At("xdoc").Post(msg);
Assert.AreEqual(msg.ToCompactString(), response.ToDocument().ToCompactString());
}
示例3: AssertFeature
private void AssertFeature(string pattern, Result<DreamMessage> result, XDoc expected)
{
var feature = _blueprint[string.Format("features/feature[pattern='{0}']", pattern)];
Assert.IsTrue(feature.Any(), string.Format("service doesn't have a feature for {0}", pattern));
var doc = new XDoc("response").Elem("method", feature["method"].AsText);
if(expected != null) {
doc.Add(expected);
}
var response = result.Wait();
Assert.IsTrue(response.IsSuccessful, response.GetErrorString());
Assert.AreEqual(doc.ToCompactString(), response.ToDocument().ToCompactString());
}
示例4: XmlNullChar_in_xml_element_ToCompactString
public void XmlNullChar_in_xml_element_ToCompactString()
{
var doc = new XDoc("root").Value("foo\0bar");
Assert.AreEqual("<root>foobar</root>", doc.ToCompactString());
}
示例5: XmlNullChar_in_xml_attribute_ToCompactString
public void XmlNullChar_in_xml_attribute_ToCompactString()
{
var doc = new XDoc("root").Attr("name", "foo\0bar");
Assert.AreEqual("<root name=\"foobar\" />", doc.ToCompactString());
}
示例6: Can_roundtrip_DispatchItem_with_complex_event
public void Can_roundtrip_DispatchItem_with_complex_event()
{
var body = new XDoc("msg").Elem("foo", "bar");
var channel = new XUri("channel://foo.com/bar");
var resource = new XUri("http://foo.com/baz/0");
var origin1 = new XUri("http://foo.com/baz/1");
var origin2 = new XUri("http://foo.com/baz/2");
var recipient1 = new DispatcherRecipient(new XUri("http://recipient1"));
var recipient2 = new DispatcherRecipient(new XUri("http://recipient2"));
var via1 = new XUri("http://via1");
var via2 = new XUri("http://via2");
var ev = new DispatcherEvent(body, channel, resource, origin1, origin2);
ev = ev.WithRecipient(false, recipient1, recipient2).WithVia(via1).WithVia(via2);
var item = new DispatchItem(
new XUri("http://foo"),
ev,
"abc"
);
var serializer = new DispatchItemSerializer();
var stream = serializer.ToStream(item);
var item2 = serializer.FromStream(stream);
Assert.AreEqual(item.Uri, item2.Uri, "uri mismatch");
Assert.AreEqual(item.Location, item2.Location, "location mismatch");
Assert.AreEqual(item.Event.Id, item2.Event.Id, "id mismatch");
Assert.AreEqual(body.ToCompactString(), item2.Event.AsDocument().ToCompactString(), "body mismatch");
Assert.AreEqual(channel, item2.Event.Channel, "channel mismatch");
Assert.AreEqual(resource, item2.Event.Resource, "resource mismatch");
Assert.AreEqual(origin1, item2.Event.Origins[0], "first origin mismatch");
Assert.AreEqual(origin2, item2.Event.Origins[1], "second origin mismatch");
Assert.AreEqual(recipient1.Uri, item2.Event.Recipients[0].Uri, "first recipient mismatch");
Assert.AreEqual(recipient2.Uri, item2.Event.Recipients[1].Uri, "second recipient mismatch");
Assert.AreEqual(via1, item2.Event.Via[0], "first via mismatch");
Assert.AreEqual(via2, item2.Event.Via[1], "second via mismatch");
}
示例7: FromBodyDocument
//--- Class Methods ---
public static AwsSqsMessage FromBodyDocument(XDoc body)
{
return new AwsSqsMessage { Body = body.ToCompactString() };
}
示例8: Dispatch_for_expiring_set_happens_only_once_for_an_event
public void Dispatch_for_expiring_set_happens_only_once_for_an_event()
{
// Arrange
var doc = new XDoc("msg").Elem("foo", StringUtil.CreateAlphaNumericKey(10));
var ev = new DispatcherEvent(
doc,
new XUri("channel:///foo/bar"),
new XUri("http://foobar.com/some/page"));
var setUpdated = false;
_dispatcher.CombinedSetUpdated += delegate {
setUpdated = true;
};
var recipientUri = new XUri("http://recipient");
XDoc dispatched = null;
var dispatchCount = 0;
MockPlug.Register(recipientUri, (plug, verb, uri, request, response) => {
dispatchCount++;
dispatched = request.ToDocument();
response.Return(DreamMessage.Ok());
});
var dispatchQueue = new MockPubSubDispatchQueue(_dequeueHandler);
var queueResolved = false;
_queueRepositoryMock.Setup(x => x[It.Is<PubSubSubscriptionSet>(y => y.Location == "abc")])
.Callback(() => queueResolved = true)
.Returns(dispatchQueue)
.Verifiable();
_dispatcher.RegisterSet(
"abc",
new XDoc("subscription-set")
.Attr("max-failure-duration", 100)
.Elem("uri.owner", "http:///owner1")
.Start("subscription")
.Attr("id", "1")
.Elem("channel", "channel:///foo/bar")
.Start("recipient").Elem("uri", recipientUri).End()
.End(),
"def"
);
// combinedset updates happen asynchronously, so give'em a chance
Assert.IsTrue(Wait.For(() => setUpdated, 10.Seconds()), "combined set didn't update in time");
// Act
_dispatcher.Dispatch(ev);
// Assert
// dispatch happens asynchronously so we need to wait until our mock repository was accessed
Assert.IsTrue(
Wait.For(() => dispatched != null, 10.Seconds()),
"dispatch didn't happen"
);
Assert.IsFalse(
Wait.For(() => dispatchCount > 1, 2.Seconds()),
"more than one dispatch happened"
);
_queueRepositoryMock.VerifyAll();
Assert.AreEqual(doc.ToCompactString(), dispatched.ToCompactString());
}