예제 #1
0
        public void ShouldOpenFileForWrite()
        {
            var file = IoTestHelper.GetTempFileName();

            var stream = _sut.OpenFile(file, FileMode.Open, FileAccess.Write);

            Assert.IsTrue(stream.CanWrite);
            stream.Close();
        }
예제 #2
0
        public void ShouldMoveFile()
        {
            var source = IoTestHelper.GetTempFileName();
            var target = GetNonExistentTempFileName();

            _sut.MoveFile(source, target);

            Assert.IsTrue(File.Exists(target));
            Assert.IsFalse(File.Exists(source));
        }
예제 #3
0
        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);
        }
예제 #4
0
 private static string GetNonExistentTempFileName()
 {
     return(Path.Combine(IoTestHelper.GetTempDirectoryName(), "ArbitraryFileName" + System.DateTime.Now.Ticks));
 }