private void Append(RollingFileAppender appender) { var task = appender.AppendAsync(BuildLogEvent()); task.Wait(); CheckLog(); _appender.Dispose(); }
public void Append_With_Changing_Of_Day_Test() { var fileInfoMock = SetupFileInfo(true); var fileInfo = fileInfoMock.Object; var factoryMock = Get <IFileInfoFactory>(); factoryMock.Setup(x => x.Build(_filePath)).Returns(fileInfo); var factory = factoryMock.Object; var fileSystemMock = Get <IFile>(); fileSystemMock.Setup(x => x.Exists(_filePathOne)).Returns(false); fileSystemMock.Setup(x => x.Move(_filePath, _filePathOne)); var fileSystem = fileSystemMock.Object; var directoryFileSystem = SetupDirectoryFileSystem(); _appender = new RollingFileAppender(MyFileWithExtension, DefaultLogFormatProvider.Instance, factory, fileSystem, directoryFileSystem, _timeProvider); fileInfoMock.SetupGet(f => f.Length).Returns(_appender.MaxLength + 1); var task = _appender.AppendAsync(BuildLogEvent()); task.Wait(); CheckLog(); _today = DateTime.MinValue.AddDays(1); SetupFileNames(); _stream = new MemoryStream(); fileInfoMock = Get <IFileInfo>(Lifetime.Instance); fileInfoMock.Setup(f => f.Refresh()); fileInfoMock.SetupGet(f => f.Exists).Returns(false); fileInfoMock.Setup(f => f.OpenWrite()).Returns(_stream); factoryMock.Setup(x => x.Build(_filePath)).Returns(fileInfoMock.Object); task = _appender.AppendAsync(BuildLogEvent()); task.Wait(); CheckLog(); }