Skip to content

Commit dad4591

Browse files
committed
more unit tests.
1 parent 155a7ab commit dad4591

3 files changed

Lines changed: 62 additions & 0 deletions

File tree

SQLitePCL.pretty.tests/ImplementationTests.cs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717

1818
using NUnit.Framework;
1919
using System;
20+
using System.Collections;
2021
using System.Collections.Generic;
2122
using System.IO;
2223
using System.Linq;
@@ -130,6 +131,21 @@ public void TestBackup()
130131
[TestFixture]
131132
public class StatementTests
132133
{
134+
[Test]
135+
public void TestCurrent()
136+
{
137+
using (var db = SQLite3.Open(":memory:"))
138+
using (var stmt = db.PrepareStatement("SELECT 1"))
139+
{
140+
stmt.MoveNext();
141+
Assert.AreEqual(stmt.Current[0].ToInt(), 1);
142+
143+
var ienumCurrent = ((IEnumerator)stmt).Current;
144+
var ienumResultSet = (IReadOnlyList<IResultSetValue>) ienumCurrent;
145+
Assert.AreEqual(ienumResultSet[0].ToInt(), 1);
146+
}
147+
}
148+
133149
[Test]
134150
public void TestDispose()
135151
{
@@ -150,6 +166,7 @@ public void TestDispose()
150166
Assert.Throws<ObjectDisposedException>(() => { stmt.ClearBindings(); });
151167
Assert.Throws<ObjectDisposedException>(() => { stmt.MoveNext(); });
152168
Assert.Throws<ObjectDisposedException>(() => { stmt.Reset(); });
169+
Assert.Throws<ObjectDisposedException>(() => { stmt.Status(StatementStatusCode.Sort, false); });
153170
}
154171
}
155172

@@ -286,6 +303,8 @@ public void TestGetBindParameters()
286303
Assert.Throws<KeyNotFoundException>(() => { var x = stmt.BindParameters[":nope"]; });
287304
Assert.Throws<ArgumentOutOfRangeException>(() => { var x = stmt.BindParameters[-1]; });
288305
Assert.Throws<ArgumentOutOfRangeException>(() => { var x = stmt.BindParameters[100]; });
306+
307+
Assert.NotNull(((IEnumerable) stmt.BindParameters).GetEnumerator());
289308
}
290309
}
291310
}
@@ -386,6 +405,24 @@ public void TestStatus()
386405
[TestFixture]
387406
public class BindParameters
388407
{
408+
[Test]
409+
public void TestBindOnDisposedStatement()
410+
{
411+
using (var db = SQLite3.Open(":memory:"))
412+
{
413+
db.Execute("CREATE TABLE foo (v int);");
414+
415+
IReadOnlyOrderedDictionary<string, IBindParameter> bindParams;
416+
417+
using (var stmt = db.PrepareStatement("INSERT INTO foo (v) VALUES (?)"))
418+
{
419+
bindParams = stmt.BindParameters;
420+
}
421+
422+
Assert.Throws<ObjectDisposedException>(() => { var x = bindParams[0]; });
423+
}
424+
}
425+
389426
[Test]
390427
public void TestBindObject()
391428
{

SQLitePCL.pretty.tests/SQLitePCL.pretty.tests.x86.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
<Compile Include="SQLite3Tests.cs" />
8282
<Compile Include="SQLiteValueTests.cs" />
8383
<Compile Include="SQLiteVersionTests.cs" />
84+
<Compile Include="TableColumnMetadataTests.cs" />
8485
</ItemGroup>
8586
<ItemGroup>
8687
<ProjectReference Include="..\SQLitePCL.pretty.Async\SQLitePCL.pretty.Async.csproj">
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using NUnit.Framework;
2+
using System;
3+
4+
namespace SQLitePCL.pretty.tests
5+
{
6+
[TestFixture]
7+
public class TableColumnMetadataTests
8+
{
9+
[Test]
10+
public void TestEquality()
11+
{
12+
}
13+
14+
[Test]
15+
public void TestGetHashcode()
16+
{
17+
}
18+
19+
[Test]
20+
public void TestComparison()
21+
{
22+
}
23+
}
24+
}

0 commit comments

Comments
 (0)