mirror of
https://github.com/BDDSM/YY.EventLogReaderAssistant.git
synced 2024-11-21 10:05:51 +02:00
Добавил тесты для класса "StreamLineReader"
This commit is contained in:
parent
36a0daec08
commit
597d30c16f
@ -0,0 +1,26 @@
|
||||
1CV8LOG(ver 2.0)
|
||||
75765565-b320-41d2-af9a-e453cb9b1b3f
|
||||
{1,071523a4-516f-4fce-ba4b-0d11ab7a1893,"",1},
|
||||
{2,"SRV-1C-01-VM",1},
|
||||
{3,"Designer",1},
|
||||
{4,"_$Session$_.Start",1},
|
||||
{6,"SRV-1C-01-VM",1},
|
||||
{7,1560,1},
|
||||
{11,
|
||||
{0},1},
|
||||
{12,
|
||||
{0},1},
|
||||
{13,1,1},
|
||||
{3,"1CV8C",2},
|
||||
{4,"СлучайноеИнформативноеСообщение",2},
|
||||
{5,c2528bcd-aa16-4c70-bfca-730e3c2f81a3,"Справочник.Справочник1",1},
|
||||
{4,"СформироватьСобытиеПримечание",3},
|
||||
{5,553dc55b-e2ce-493b-a76c-a79e7868b21e,"Справочник.Справочник4",2},
|
||||
{5,e606390e-da98-4ebe-a68b-e4f66075965c,"Справочник.Справочник5",3},
|
||||
{4,"СформироватьПредупреждающееСобытие",4},
|
||||
{5,0f7e2f59-f461-41c7-aa79-1a2f30e35ba2,"Справочник.Справочник2",4},
|
||||
{4,"СформироватьСобытиеОбОшибке",5},
|
||||
{5,bb27ca84-1955-41c8-bf0b-876a079aa5b2,"Справочник.Справочник3",5},
|
||||
{4,"_$Transaction$_.Begin",6},
|
||||
{4,"_$Transaction$_.Commit",7},
|
||||
{4,"_$Session$_.Finish",8}
|
File diff suppressed because it is too large
Load Diff
@ -1,8 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Xunit;
|
||||
using YY.EventLogAssistant.Services;
|
||||
|
||||
namespace YY.EventLogAssistant.Services.Tests
|
||||
{
|
||||
|
@ -1,6 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Xunit;
|
||||
|
||||
namespace YY.EventLogAssistant.Services.Tests
|
||||
|
@ -1,11 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SQLite;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
using Xunit;
|
||||
using YY.EventLogAssistant.Services;
|
||||
|
||||
namespace YY.EventLogAssistant.Services.Tests
|
||||
{
|
||||
|
@ -0,0 +1,99 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Xunit;
|
||||
|
||||
namespace YY.EventLogAssistant.Services.Tests
|
||||
{
|
||||
public class StreamLineReaderTests
|
||||
{
|
||||
#region Private Member Variables
|
||||
|
||||
private string sampleDataDirectory;
|
||||
private string sampleDatabaseFile;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
|
||||
public StreamLineReaderTests()
|
||||
{
|
||||
string currentDirectory = Directory.GetCurrentDirectory();
|
||||
sampleDataDirectory = Path.Combine(currentDirectory, "SampleData");
|
||||
sampleDatabaseFile = Path.Combine(sampleDataDirectory, "LGFFormatEventLog", "1Cv8.lgf");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
[Fact]
|
||||
public void GoToLine_Test()
|
||||
{
|
||||
string lineContent = string.Empty;
|
||||
using (StreamReader reader = new StreamReader(sampleDatabaseFile))
|
||||
{
|
||||
using(StreamLineReader lineReader = new StreamLineReader(reader.BaseStream))
|
||||
{
|
||||
if(lineReader.GoToLine(1))
|
||||
{
|
||||
lineContent = lineReader.ReadLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Guid eventLogGuid = Guid.Empty;
|
||||
Guid.TryParse(lineContent, out eventLogGuid);
|
||||
|
||||
Assert.NotEqual(Guid.Empty, eventLogGuid);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetCount_Test()
|
||||
{
|
||||
long lineCounterNative = 0;
|
||||
using (var reader = new StreamReader(sampleDatabaseFile))
|
||||
{
|
||||
while (reader.ReadLine() != null)
|
||||
{
|
||||
lineCounterNative++;
|
||||
}
|
||||
}
|
||||
|
||||
long lineCounterLibrary = 0;
|
||||
using (StreamReader reader = new StreamReader(sampleDatabaseFile))
|
||||
{
|
||||
using (StreamLineReader lineReader = new StreamLineReader(reader.BaseStream))
|
||||
{
|
||||
lineCounterLibrary = lineReader.GetCount();
|
||||
}
|
||||
}
|
||||
|
||||
Assert.Equal(lineCounterNative, lineCounterLibrary);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReadLine_Test()
|
||||
{
|
||||
string correctFirstLine = string.Empty;
|
||||
using (var reader = new StreamReader(sampleDatabaseFile))
|
||||
{
|
||||
correctFirstLine = reader.ReadLine();
|
||||
}
|
||||
|
||||
string resultFirstLine = string.Empty;
|
||||
using (StreamReader reader = new StreamReader(sampleDatabaseFile))
|
||||
{
|
||||
using (StreamLineReader lineReader = new StreamLineReader(reader.BaseStream))
|
||||
{
|
||||
resultFirstLine = lineReader.ReadLine();
|
||||
}
|
||||
}
|
||||
|
||||
Assert.Equal(correctFirstLine, resultFirstLine);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Xunit;
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="SampleData\" />
|
||||
<Folder Include="SampleData\LGFFormatEventLog\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@ -23,6 +23,12 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="SampleData\LGFFormatEventLog\1Cv8.lgf">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="SampleData\LGFFormatEventLog\20200412130000.lgp">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="SampleData\SQLiteFormatEventLog\1Cv8.lgd">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
|
@ -29,9 +29,15 @@ namespace YY.EventLogAssistant.Services
|
||||
|
||||
public StreamLineReader(Stream stream) { _Base = stream; }
|
||||
|
||||
public bool GoToLine(long goToLine) { return IGetCount(goToLine, true) == goToLine; }
|
||||
public bool GoToLine(long goToLine)
|
||||
{
|
||||
return IGetCount(goToLine, true) == goToLine;
|
||||
}
|
||||
|
||||
public long GetCount(long goToLine) { return IGetCount(goToLine, false); }
|
||||
public long GetCount(long goToLine = 0)
|
||||
{
|
||||
return IGetCount(goToLine, false);
|
||||
}
|
||||
|
||||
public string ReadLine()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user