1
0
mirror of https://github.com/BDDSM/YY.EventLogReaderAssistant.git synced 2024-11-21 10:05:51 +02:00

Добавил тесты для расширения работы с классом "StreamReader"

This commit is contained in:
YPermitin 2020-04-12 23:53:18 +05:00
parent 549e8246ec
commit cd309668c7

View File

@ -0,0 +1,75 @@
using System;
using System.IO;
using Xunit;
namespace YY.EventLogAssistant.Services.Tests
{
public class StreamReaderExtensionsTests
{
#region Private Member Variables
private string sampleDataDirectory;
private 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
}
}