欧美一级特黄大片做受成人-亚洲成人一区二区电影-激情熟女一区二区三区-日韩专区欧美专区国产专区

IO擴(kuò)展控件(System.IO.Abstractions)

剛看到這個Namespace的時候還以為是.Net Framework里自帶的包,結(jié)果查了一圈無任何結(jié)果。

創(chuàng)新互聯(lián)建站網(wǎng)站建設(shè)公司,提供成都網(wǎng)站設(shè)計、成都做網(wǎng)站,網(wǎng)頁設(shè)計,建網(wǎng)站,PHP網(wǎng)站建設(shè)等專業(yè)做網(wǎng)站服務(wù);可快速的進(jìn)行網(wǎng)站開發(fā)網(wǎng)頁制作和功能擴(kuò)展;專業(yè)做搜索引擎喜愛的網(wǎng)站,是專業(yè)的做網(wǎng)站團(tuán)隊(duì),希望更多企業(yè)前來合作!

果斷上Github,一擊即中https://github.com/tathamoddie/System.IO.Abstractions

先翻譯下開發(fā)者給出的簡單說明,今后再慢慢使用

類似于System.Web.Abstractions的用法,System.IO也被擴(kuò)展了,它能針對IO對象進(jìn)行訪問

Just like System.Web.Abstractions, but for System.IO. Yay for testable IO access!

只能用NuGet方式下載

NuGet only:

Install-Package System.IO.Abstractions

如果有需要可以下載測試幫助包

and/or:

Install-Package System.IO.Abstractions.TestingHelpers

本庫最核心的2個文件是IFileSystem和FileSystem。使用IFileSystem.File.ReadAllText等方法替換掉之前的File.ReadAllText等方法。其他API也基本完全相同,除了一些我們擴(kuò)展和進(jìn)行測試的方法。

At the core of the library is IFileSystem and FileSystem. Instead of calling methods like File.ReadAllText directly, use IFileSystem.File.ReadAllText. We have exactly the same API, except that ours is injectable and testable.

public class MyComponent
{
    readonly IFileSystem fileSystem;

    // <summary>Create MyComponent with the given fileSystem implementation</summary>
    public MyComponent(IFileSystem fileSystem)
    {
        this.fileSystem = fileSystem;
    }
    /// <summary>Create MyComponent</summary>
    public MyComponent() : this( 
        fileSystem: new FileSystem() //use default implementation which calls System.IO
    ) 
    {
    }

    public void Validate()
    {
        foreach (var textFile in fileSystem.Directory.GetFiles(@"c:\", "*.txt", SearchOption.TopDirectoryOnly))
        {
            var text = fileSystem.File.ReadAllText(textFile);
            if (text != "Testing is awesome.")
                throw new NotSupportedException("We can't go on together. It's not me, it's you.");
        }
    }
}

這個庫中還包含了一系列測試程序,來幫助你熟悉它。雖然它不是一個成熟的文件系統(tǒng),但是它一定會給你帶來幫助的。

The library also ships with a series of test helpers to save you from having to mock out every call, for basic scenarios. They are not a complete copy of a real-life file system, but they'll get you most of the way there.

[Test]
public void MyComponent_Validate_ShouldThrowNotSupportedExceptionIfTestingIsNotAwesome()
{
    // Arrange
    var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData>
    {
        { @"c:\myfile.txt", new MockFileData("Testing is meh.") },
        { @"c:\demo\jQuery.js", new MockFileData("some js") },
        { @"c:\demo\p_w_picpath.gif", new MockFileData(new byte[] { 0x12, 0x34, 0x56, 0xd2 }) }
    });
    var component = new MyComponent(fileSystem);

    try
    {
        // Act
        component.Validate();
    }
    catch (NotSupportedException ex)
    {
        // Assert
        Assert.AreEqual("We can't go on together. It's not me, it's you.", ex.Message);
        return;
    }

    Assert.Fail("The expected exception was not thrown.");
}

我們甚至支持把.NET框架里不可測試的類型加入到測試程序里

We even support casting from the .NET Framework's untestable types to our testable wrappers:

FileInfo SomeBadApiMethodThatReturnsFileInfo()
{
    return new FileInfo("a");
}

void MyFancyMethod()
{
    var testableFileInfo = (FileInfoBase)SomeBadApiMethodThatReturnsFileInfo();
    //...
}



當(dāng)前題目:IO擴(kuò)展控件(System.IO.Abstractions)
文章起源:http://www.aaarwkj.com/article14/iijhge.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供用戶體驗(yàn)品牌網(wǎng)站設(shè)計、網(wǎng)站設(shè)計公司、響應(yīng)式網(wǎng)站移動網(wǎng)站建設(shè)、做網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

搜索引擎優(yōu)化
最新国产不卡一区二区| 丁香六月五月色婷婷网| 国产av综合一区二区| 欧美日韩免费爱爱视频| 国产日韩亚洲欧美精品专区 | 中文字幕日韩精品亚洲精品| 欧美日韩欧美国产精品| 欧美偷拍一区二区三区| 91精品欧美综合在线| 夜福利国产视频大屁股| 强暴美女视频大全久久久| 懂色一区二区三区精品视频| 成人国产精品2021| 欧美制服丝袜亚洲自拍偷拍| 久久国产精品亚洲av四虎| 成人午夜福利视频免费观看| 亚洲综合日韩欧美一区二区三区| 怡红院怡春院视频免费看| 欧美十日本亚洲激情视频| 亚洲一品道在线观看| 国产一级成人免费视频| 亚洲成人av日韩在线| 欧美αv一区二区三区| 日韩欧美亚洲精品中文字幕αv| 亚洲区自拍偷拍一区二区| 国产日韩亚洲欧美在线| 国产毛毛片一区二区三区| 国产av剧情一区二区| 午夜免费视频观看在线| 丝袜亚洲激情欧美日韩偷拍| 欧美在线观看日韩精品| 国产一级二级三级久久| 成人性生交大片免费看久久| 国产成人自拍视频网站| 婷婷激情综合亚洲五月色| 日韩成人在线视频观看| 国产日韩久久免费电影| 日韩在线不卡播放视频| 关于男女性生活的视频| 欧美午夜福利一级高清| 欧美精品激情在线不卡|