Tag: 出口

VS2008unit testing – 断言方法退出

我正在尝试使用VS 2008的内置unit testing框架编写C#unit testing,我正在测试的方法是调用Environment.Exit(0) 。 当我在unit testing中调用此方法时,我的unit testing被中止。 该方法确实应该调用Exit ,我想要一种方法来测试它,并且还要测试它使用的退出代码。 我怎么能这样做? 我查看了Microsoft.VisualStudio.TestTools.UnitTesting命名空间,但没有看到任何看起来相关的内容。 [TestMethod] [DeploymentItem(“myprog.exe”)] public void MyProgTest() { // Want to ensure this Exit’s with code 0: MyProg_Accessor.myMethod(); } 同时,这是我要测试的代码的要点: static void myMethod() { Environment.Exit(0); } 编辑:这是我在测试方法中使用的解决方案,感谢RichardOD : Process proc; try { proc = Process.Start(path, myArgs); } catch (System.ComponentModel.Win32Exception ex) { proc = null; Assert.Fail(ex.Message); […]

是否有工具将C#导出为HTML,语法高亮

我正在寻找一些方法将.cs文件导出到.html文件以便在网上发布,但我的搜索没有多大帮助。 我记得几年前一个名为DevC ++的IDE可以为C代码做这个,但是我不知道我是怎么用C#4做的。 Visual Studio能以某种方式执行此操作吗?