コード例 #1
0
        public void ContainsFile_Test()
        {
            var contentDirMock = new Mock <IContentDirectoryProvider>();

            contentDirMock.Setup(g => g.ApplicationData).Returns(new DirectoryInfo(Path.GetTempPath())
                                                                 .CreateSubdirectory(Path.GetFileNameWithoutExtension(Path.GetTempFileName())));
            var sfp      = new SystemFileProvider(contentDirMock.Object);
            var file     = Path.GetTempFileName();
            var biosFile = new BiosFile("testFile", "testHash");

            Assert.False(sfp.ContainsSystemFile(biosFile));
        }
コード例 #2
0
        public void ThrowsUnknownFile_Test()
        {
            var contentDirMock = new Mock <IContentDirectoryProvider>();

            contentDirMock.Setup(g => g.ApplicationData).Returns(new DirectoryInfo(Path.GetTempPath())
                                                                 .CreateSubdirectory(Path.GetFileNameWithoutExtension(Path.GetTempFileName())));
            var sfp      = new SystemFileProvider(contentDirMock.Object);
            var file     = Path.GetTempFileName();
            var biosFile = new BiosFile("testFile", "testHash");

            Assert.Throws <FileNotFoundException>(() => sfp.GetSystemFilePath(biosFile));
        }
コード例 #3
0
        public async Task AddSystemAsyncFile_Test()
        {
            var contentDirMock = new Mock <IContentDirectoryProvider>();

            contentDirMock.Setup(g => g.ApplicationData).Returns(new DirectoryInfo(Path.GetTempPath())
                                                                 .CreateSubdirectory(Path.GetFileNameWithoutExtension(Path.GetTempFileName())));
            var sfp        = new SystemFileProvider(contentDirMock.Object);
            var testStream = new MemoryStream(new byte[] { 0, 1, 2, 3, 4 });
            var biosFile   = new BiosFile("testFile", "testHash");
            await sfp.AddSystemFileAsync(biosFile, testStream);

            var newStream = sfp.GetSystemFile(biosFile);

            Assert.Equal(testStream.Length, newStream.Length);
        }
コード例 #4
0
        public void AddSystemFileByPathFile_Test()
        {
            var contentDirMock = new Mock <IContentDirectoryProvider>();

            contentDirMock.Setup(g => g.ApplicationData).Returns(new DirectoryInfo(Path.GetTempPath())
                                                                 .CreateSubdirectory(Path.GetFileNameWithoutExtension(Path.GetTempFileName())));
            var sfp      = new SystemFileProvider(contentDirMock.Object);
            var file     = Path.GetTempFileName();
            var biosFile = new BiosFile("testFile", "testHash");

            sfp.AddSystemFile(biosFile, new FileInfo(file));
            var filePath = sfp.GetSystemFilePath(biosFile);

            Assert.Equal($"{biosFile.Md5Hash}.{biosFile.FileName}", Path.GetFileName(filePath.FullName));
        }
コード例 #5
0
 public void TestInitialize()
 {
     systemFileProvider = new SystemFileProvider();
 }