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


C# Mock.MockWriteElementString方法代码示例

本文整理汇总了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();
 }
开发者ID:BiYiTuan,项目名称:CruiseControl.NET,代码行数:28,代码来源:TaskExecutionFactoryTests.cs

示例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);
 }
开发者ID:kascomp,项目名称:CruiseControl.NET,代码行数:20,代码来源:TaskExecutionContextTests.cs

示例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);
 }
开发者ID:kascomp,项目名称:CruiseControl.NET,代码行数:20,代码来源:TaskExecutionContextTests.cs

示例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();
 }
开发者ID:kascomp,项目名称:CruiseControl.NET,代码行数:22,代码来源:TaskExecutionContextTests.cs


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