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)); }
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)); }
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); }
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)); }
public void TestInitialize() { systemFileProvider = new SystemFileProvider(); }