public void ShouldOpenFileForWrite() { var file = IoTestHelper.GetTempFileName(); var stream = _sut.OpenFile(file, FileMode.Open, FileAccess.Write); Assert.IsTrue(stream.CanWrite); stream.Close(); }
public void ShouldMoveFile() { var source = IoTestHelper.GetTempFileName(); var target = GetNonExistentTempFileName(); _sut.MoveFile(source, target); Assert.IsTrue(File.Exists(target)); Assert.IsFalse(File.Exists(source)); }
protected override ILogManager CreateLogManager() { Registry.RegisterComponent <ILogger>(new ConsoleLogger()); _ioUtilMock = new Mock <IIoUtils>(); _ioUtilMock.Setup(io => io.OpenFile(It.IsAny <string>(), It.IsAny <FileMode>(), It.IsAny <FileAccess>())) .Returns(() => new MemoryStream()); _ioUtilMock.Setup(io => io.DeleteFile(It.IsAny <string>())) .Callback <string>(fileName => _existingLogsPaths.Remove(fileName)); _ioUtilMock.Setup(io => io.MoveFile(It.IsAny <string>(), It.IsAny <string>())) .Callback <string, string>( (oldName, newName) => { _existingLogsPaths.Remove(oldName); _existingLogsPaths.Add(newName); }); Registry.RegisterComponent(_ioUtilMock.Object); _baseDirectory = IoTestHelper.GetTempDirectoryName(); _uut = new LogFileManager(_baseDirectory); return(_uut); }
private static string GetNonExistentTempFileName() { return(Path.Combine(IoTestHelper.GetTempDirectoryName(), "ArbitraryFileName" + System.DateTime.Now.Ticks)); }