本文整理汇总了C#中Mock.MockWriteElementString方法的典型用法代码示例。如果您正苦于以下问题:C# Mock.MockWriteElementString方法的具体用法?C# Mock.MockWriteElementString怎么用?C# Mock.MockWriteElementString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mock
的用法示例。
在下文中一共展示了Mock.MockWriteElementString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StartNewStartsANewContext
public void StartNewStartsANewContext()
{
var path = Path.Combine(
Environment.CurrentDirectory,
"Test",
"20100101120101");
var writerMock = new Mock<XmlWriter>(MockBehavior.Strict);
writerMock.Setup(w => w.WriteStartElement(null, "project", null)).Verifiable();
writerMock.MockWriteAttributeString("name", "Test");
writerMock.MockWriteElementString("start", "2010-01-01T12:01:01");
var clockMock = new Mock<IClock>(MockBehavior.Strict);
clockMock.Setup(c => c.Now).Returns(new DateTime(2010, 1, 1, 12, 1, 1));
var fileSystemMock = new Mock<IFileSystem>(MockBehavior.Strict);
fileSystemMock.Setup(fs => fs.EnsureFolderExists(path));
fileSystemMock.Setup(fs => fs.CreateXmlWriter(Path.Combine(path, "build.log"))).Returns(writerMock.Object);
var factory = new TaskExecutionFactory
{
Clock = clockMock.Object,
FileSystem = fileSystemMock.Object
};
var project = new Project("Test");
var request = new IntegrationRequest("Testing");
var actual = factory.StartNew(project, request);
Assert.IsNotNull(actual);
Assert.AreSame(project, actual.Project);
Assert.AreSame(request, actual.Request);
writerMock.Verify();
}
示例2: CompleteDoesNothingIfAlreadyClosed
public void CompleteDoesNothingIfAlreadyClosed()
{
var action = 0;
var writerMock = new Mock<XmlWriter>(MockBehavior.Strict);
writerMock.Setup(w => w.WriteEndDocument()).Callback(() => action++);
writerMock.Setup(w => w.Close()).Callback(() => action++);
writerMock.MockWriteElementString("finish", "2010-01-01T12:01:01");
writerMock.MockWriteElementString("status", "Success");
var clockMock = new Mock<IClock>(MockBehavior.Strict);
clockMock.Setup(c => c.Now).Returns(new DateTime(2010, 1, 1, 12, 1, 1));
var context = new TaskExecutionContext(
new TaskExecutionParameters
{
XmlWriter = writerMock.Object,
Clock = clockMock.Object
});
context.Complete();
context.Complete();
Assert.AreEqual(2, action);
}
示例3: CompleteClosesWriter
public void CompleteClosesWriter()
{
var writerMock = new Mock<XmlWriter>(MockBehavior.Strict);
writerMock.Setup(w => w.WriteEndDocument()).Verifiable();
writerMock.Setup(w => w.Close()).Verifiable();
writerMock.MockWriteElementString("finish", "2010-01-01T12:01:01");
writerMock.MockWriteElementString("status", "Success");
var clockMock = new Mock<IClock>(MockBehavior.Strict);
clockMock.Setup(c => c.Now).Returns(new DateTime(2010, 1, 1, 12, 1, 1));
var context = new TaskExecutionContext(
new TaskExecutionParameters
{
XmlWriter = writerMock.Object,
Clock = clockMock.Object
});
Assert.IsFalse(context.IsCompleted);
context.Complete();
writerMock.Verify();
Assert.IsTrue(context.IsCompleted);
}
示例4: StartChildStartsANewChildContext
public void StartChildStartsANewChildContext()
{
var writerMock = new Mock<XmlWriter>(MockBehavior.Strict);
writerMock.Setup(w => w.WriteStartElement(null, "task", null)).Verifiable();
writerMock.MockWriteAttributeString("name", "TestComment");
writerMock.MockWriteAttributeString("type", "Comment");
writerMock.MockWriteElementString("start", "2010-01-01T12:01:01");
var clockMock = new Mock<IClock>(MockBehavior.Strict);
clockMock.Setup(c => c.Now).Returns(new DateTime(2010, 1, 1, 12, 1, 1));
var task = new Comment("TestComment");
var context = new TaskExecutionContext(
new TaskExecutionParameters
{
XmlWriter = writerMock.Object,
Clock = clockMock.Object
});
var child = context.StartChild(task);
Assert.IsNotNull(child);
Assert.AreSame(context, child.Parent);
Assert.AreSame(context.ModificationSets, child.ModificationSets);
writerMock.Verify();
}