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


C# Mock.MockWriteAttributeString方法代码示例

本文整理汇总了C#中Mock.MockWriteAttributeString方法的典型用法代码示例。如果您正苦于以下问题:C# Mock.MockWriteAttributeString方法的具体用法?C# Mock.MockWriteAttributeString怎么用?C# Mock.MockWriteAttributeString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mock的用法示例。


在下文中一共展示了Mock.MockWriteAttributeString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例3: ImportFileMovesFile

 public void ImportFileMovesFile()
 {
     var source = "C:\\data.tst";
     var destination = Path.Combine(
         Environment.CurrentDirectory,
         "Test",
         "20100101120101",
         Path.GetFileName(source));
     var writerMock = new Mock<XmlWriter>(MockBehavior.Strict);
     writerMock.Setup(w => w.WriteStartElement(null, "file", null)).Verifiable();
     writerMock.MockWriteAttributeString("time", "2010-01-01T12:01:01");
     writerMock.Setup(w => w.WriteString(Path.GetFileName(destination))).Verifiable();
     writerMock.Setup(w => w.WriteEndElement()).Verifiable();
     var fileSystemMock = new Mock<IFileSystem>(MockBehavior.Strict);
     fileSystemMock.Setup(fs => fs.MoveFile(source, destination)).Verifiable();
     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,
                 FileSystem = fileSystemMock.Object,
                 Clock = clockMock.Object,
                 Project = new Project("Test"),
                 BuildName = "20100101120101"
             });
     context.ImportFile(source, true);
     writerMock.Verify();
     fileSystemMock.Verify();
 }
开发者ID:kascomp,项目名称:CruiseControl.NET,代码行数:30,代码来源:TaskExecutionContextTests.cs

示例4: StartOutputStreamStartsANewStream

 public void StartOutputStreamStartsANewStream()
 {
     var source = "data.tst";
     var destination = Path.Combine(
         Environment.CurrentDirectory,
         "Test",
         "20100101120101",
         source);
     var writerMock = new Mock<XmlWriter>(MockBehavior.Strict);
     writerMock.Setup(w => w.WriteStartElement(null, "file", null)).Verifiable();
     writerMock.MockWriteAttributeString("time", "2010-01-01T12:01:01");
     writerMock.Setup(w => w.WriteString(source)).Verifiable();
     writerMock.Setup(w => w.WriteEndElement()).Verifiable();
     var fileSystemMock = new Mock<IFileSystem>(MockBehavior.Strict);
     var expected = new MemoryStream();
     fileSystemMock.Setup(fs => fs.OpenFileForWrite(destination)).Returns(expected).Verifiable();
     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,
                 FileSystem = fileSystemMock.Object,
                 Clock = clockMock.Object,
                 Project = new Project("Test"),
                 BuildName = "20100101120101"
             });
     var actual = context.StartOutputStream(source);
     writerMock.Verify();
     fileSystemMock.Verify();
     Assert.AreSame(expected, actual);
 }
开发者ID:kascomp,项目名称:CruiseControl.NET,代码行数:32,代码来源:TaskExecutionContextTests.cs

示例5: AddEntryToBuildLogAddsElement

 public void AddEntryToBuildLogAddsElement()
 {
     var writerMock = new Mock<XmlWriter>(MockBehavior.Strict);
     writerMock.Setup(w => w.WriteStartElement(null, "entry", null)).Verifiable();
     writerMock.MockWriteAttributeString("time", "2010-01-01T12:01:01");
     writerMock.Setup(w => w.WriteString("This is a test")).Verifiable();
     writerMock.Setup(w => w.WriteEndElement()).Verifiable();
     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.AddEntryToBuildLog("This is a test");
     writerMock.Verify();
 }
开发者ID:kascomp,项目名称:CruiseControl.NET,代码行数:18,代码来源:TaskExecutionContextTests.cs


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