mirror of
https://github.com/BDDSM/YY.EventLogReaderAssistant.git
synced 2025-02-20 07:48:21 +02:00
76 lines
2.0 KiB
C#
76 lines
2.0 KiB
C#
using System;
|
|
using System.IO;
|
|
using Xunit;
|
|
|
|
namespace YY.EventLogReaderAssistant.Services.Tests
|
|
{
|
|
public class StreamReaderExtensionsTests
|
|
{
|
|
#region Private Member Variables
|
|
|
|
private readonly string sampleDataDirectory;
|
|
private readonly string sampleDatabaseFile;
|
|
|
|
#endregion
|
|
|
|
#region Constructor
|
|
|
|
public StreamReaderExtensionsTests()
|
|
{
|
|
string currentDirectory = Directory.GetCurrentDirectory();
|
|
sampleDataDirectory = Path.Combine(currentDirectory, "SampleData");
|
|
sampleDatabaseFile = Path.Combine(sampleDataDirectory, "LGFFormatEventLog", "1Cv8.lgf");
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Public Methods
|
|
|
|
[Fact]
|
|
public void GetAndSetPosition_Test()
|
|
{
|
|
string checkString = string.Empty;
|
|
string resultString = string.Empty;
|
|
long position = 0;
|
|
|
|
using (StreamReader reader = new StreamReader(sampleDatabaseFile))
|
|
{
|
|
reader.ReadLine();
|
|
position = reader.GetPosition();
|
|
checkString = reader.ReadLine();
|
|
}
|
|
|
|
using (StreamReader reader = new StreamReader(sampleDatabaseFile))
|
|
{
|
|
reader.SetPosition(position);
|
|
resultString = reader.ReadLine();
|
|
}
|
|
|
|
Assert.Equal(checkString, resultString);
|
|
}
|
|
|
|
[Fact]
|
|
public void SkipLine_Test()
|
|
{
|
|
string checkString = string.Empty;
|
|
string resultString = string.Empty;
|
|
|
|
using (StreamReader reader = new StreamReader(sampleDatabaseFile))
|
|
{
|
|
reader.SkipLine(10);
|
|
checkString = reader.ReadLine();
|
|
}
|
|
|
|
using (StreamReader reader = new StreamReader(sampleDatabaseFile))
|
|
{
|
|
reader.SkipLine(10);
|
|
resultString = reader.ReadLine();
|
|
}
|
|
|
|
Assert.Equal(checkString, resultString);
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|