Esempio n. 1
0
        public async void ReadNextEntryAsync_ShouldReturnValidNumberOfEntries(string lineSeparator)
        {
            var faker       = new Faker();
            var testContent = faker.Lorem.Lines(2, lineSeparator);

            var stream = new MemoryStream();

            using (var streamWriter = new StreamWriter(stream, Encoding.UTF8, leaveOpen: true))
            {
                streamWriter.Write(testContent);
            }

            stream.Seek(0, SeekOrigin.Begin);

            var streamProviderMock = new Mock <IReadOnlyFileStreamProvider>();

            streamProviderMock.Setup(x => x.GetStream(It.IsAny <string>())).Returns(stream);

            var reader = new FileLogReader(streamProviderMock.Object);

            reader.NewLineSeparator = lineSeparator;

            var result = await reader.ReadNextEntriesAsync().ToArrayAsync();

            Assert.Equal(2, result.Length);
        }
Esempio n. 2
0
        /// <summary>
        /// TODO: Изменения нужно вносить в этом методе
        /// </summary>
        public void DoMethod()
        {
            var fileLogReader = new FileLogReader();
            var ftpClient     = new FtpClient();
            var importer      = new FtpClientAdapter(fileLogReader, ftpClient);

            importer.ImportLogs("ftp://log.txt");
            importer.ImportLogs("login", "password", "filePath");
        }
        public void Test1()
        {
            var s = GetType().Assembly.GetManifestResourceStream(GetType(), "data.logp");
            var l = FileLogReader.Read(s);

            Assert.AreEqual(1528, l.Items.Length);

            var dt1 = DateTime.Parse("2017-08-07 19:17:33");
            var dt2 = DateTime.Parse("2017-08-23 17:06:52");

            Assert.AreEqual(dt1, l.Items[0].TimeStamp());
            Assert.AreEqual(dt2, l.Items[1527].TimeStamp());
        }
Esempio n. 4
0
        public void TestReadFileDataToBuffer_Big()
        {
            var hint = log.CreateFile();

            logReader.Close();
            log.Close();
            var stream      = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
            var newFileSize = FileLogTestsHelper.CreateBigLogFile(hint.Hint, stream);

            stream.Close();
            log = new FileLog(filename, FileMode.Open);
            log.AppendDataToFile(hint, new ByteArray(new byte[] { 1, 2, 3, 4 }));
            byte[] buffer = new byte[128];
            buffer[0] = 15;
            logReader = log.CreateReader();
            logReader.ReadFileDataToBuffer(hint, buffer, newFileSize, 4, 1);
            Assert.Equal(15, buffer[0]);
            Assert.Equal(1, buffer[1]);
            Assert.Equal(2, buffer[2]);
        }
Esempio n. 5
0
 public Analyzer()
 {
     Reader = new FileLogReader();
 }
Esempio n. 6
0
 public FileLogReaderTests()
 {
     filename  = Path.GetTempFileName();
     log       = new FileLog(filename);
     logReader = log.CreateReader();
 }