Skip to content

Commit

Permalink
Add a test for an unknown header + fix
Browse files Browse the repository at this point in the history
  • Loading branch information
rfavreau committed Sep 11, 2022
1 parent ad26ed4 commit 6d83fee
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion OFX-Tool.Library/Core/Load.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private HeaderDocument LoadHeader()
else if (setting[0] == Entity.GetHeader(nameof(HeaderDocument.NewFileUid)))
header.NewFileUid = setting[1];
else
throw new InvalidOperationException($"Unexpected header! [{setting[0]}]");
throw new InvalidOperationException($"Unexpected header! [{line}]");
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions OFX-Tool.Test/Core/LoadTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,13 @@ public void LoadTest()
Assert.AreEqual(ofx.Response, load.Ofx.Response);
Assert.AreEqual(ofx, load.Ofx);
}

[TestMethod]
[ExpectedException(typeof(OFXToolException))]
public void LoadTest_UnknownHeader()
{
var ofxFile = "TestFiles/LoadTest_UnknownHeader.ofx";
new Load(ofxFile);
}
}
}
3 changes: 3 additions & 0 deletions OFX-Tool.Test/OFX-Tool.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
<None Update="Ofx.xsd">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="TestFiles\LoadTest_UnknownHeader.ofx">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="TestFiles\LoadTest1.ofx">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down
11 changes: 11 additions & 0 deletions OFX-Tool.Test/TestFiles/LoadTest_UnknownHeader.ofx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

OFXHEADER:000
DATA:AZERTY
VERSION:111
SECURITY:SECU
No correct line ....
ENCODING:ENCO
CHARSET:1234
COMPRESSION:COMP
OLDFILEUID:OLD
NEWFILEUID:NEW

0 comments on commit 6d83fee

Please sign in to comment.