forked from LittleDigital/InterviewTest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFileComparisonReportGenerator.cs
47 lines (39 loc) · 1.46 KB
/
FileComparisonReportGenerator.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FundsLibraryTest
{
class FileComparisonReportGenerator
{
private readonly IEnumerable<FileComparisonEntry> m_resultData;
private readonly FileStream m_fileStreamA;
private readonly FileStream m_fileStreamB;
private readonly List<IFileComparisonExclusion> m_exclusions = new List<IFileComparisonExclusion>();
public FileComparisonReportGenerator(FileComparisonEntry[] initialResultData, FileStream fileStreamA, FileStream fileStreamB)
{
m_resultData = initialResultData;
m_fileStreamA = fileStreamA;
m_fileStreamB = fileStreamB;
if (m_resultData.Any(x => x.Equals(FileComparisonEntry.Unknown)))
{
throw new ArgumentException("data contains unknown entries");
}
}
internal void AddExclusion(IFileComparisonExclusion idExclusion)
{
m_exclusions.Add(idExclusion);
}
internal FileComparisonReport Generate()
{
var workingCopy = m_resultData.ToArray();//take a copy of the preliminary report
foreach (var exclusion in m_exclusions)
{
exclusion.ApplyExclusion(workingCopy, m_fileStreamA, m_fileStreamB);
}
return new FileComparisonReport(workingCopy);
}
}
}