Skip to content

Commit 27ea16d

Browse files
author
Marc Sallin
committed
#23: Added test for HistoryEntityTypeValidator.
1 parent 5e3fd2b commit 27ea16d

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

SQLite.CodeFirst.Test/SQLite.CodeFirst.Test.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393
<Compile Include="Statement\CreateIndexStatementCollectionTest.cs" />
9494
<Compile Include="Statement\ColumnStatementTest.cs" />
9595
<Compile Include="Utility\HashCreatorTest.cs" />
96+
<Compile Include="Utility\HistoryEntityTypeValidator.cs" />
9697
</ItemGroup>
9798
<ItemGroup>
9899
<Folder Include="Convention\" />
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
using System;
2+
using Microsoft.VisualStudio.TestTools.UnitTesting;
3+
using SQLite.CodeFirst.Utility;
4+
5+
namespace SQLite.CodeFirst.Test.Utility
6+
{
7+
[TestClass]
8+
public class HistoryEntityTypeValidatorTest
9+
{
10+
[TestMethod]
11+
[ExpectedException(typeof(InvalidOperationException))]
12+
public void EnsureValidTypeNotIHistory()
13+
{
14+
HistoryEntityTypeValidator.EnsureValidType(typeof(InvalidFakeHistoryType1));
15+
}
16+
17+
[TestMethod]
18+
[ExpectedException(typeof(InvalidOperationException))]
19+
public void EnsureValidTypeNoParamLessCtorTest()
20+
{
21+
HistoryEntityTypeValidator.EnsureValidType(typeof(InvalidFakeHistoryType2));
22+
}
23+
24+
[TestMethod]
25+
public void EnsureValidTypeTest()
26+
{
27+
HistoryEntityTypeValidator.EnsureValidType(typeof(ValidFakeHistoryType));
28+
}
29+
30+
private class ValidFakeHistoryType : IHistory
31+
{
32+
public int Id { get; set; }
33+
public string Hash { get; set; }
34+
public string Context { get; set; }
35+
public DateTime CreateDate { get; set; }
36+
}
37+
38+
private class InvalidFakeHistoryType1
39+
{
40+
public int Id { get; set; }
41+
public string Hash { get; set; }
42+
public string Context { get; set; }
43+
public DateTime CreateDate { get; set; }
44+
}
45+
46+
private class InvalidFakeHistoryType2 : IHistory
47+
{
48+
public InvalidFakeHistoryType2(string test)
49+
{ }
50+
51+
public int Id { get; set; }
52+
public string Hash { get; set; }
53+
public string Context { get; set; }
54+
public DateTime CreateDate { get; set; }
55+
}
56+
}
57+
}

0 commit comments

Comments
 (0)