Skip to content

Commit 7c362f9

Browse files
NikTJ777Nik Trevallyn-Jones
andauthored
[DOTNET-5] - Ntj/dotnet 5 (#49)
* Add vscode config to .gitignore * [DOTNET-5] Support new C# calendar types DateOnly and TimeOnly (introduced in dotNET 6) as return types from the driver. * Map SQL Date <-> C# DateOnly * Map SQL Time <-> C# TimeOnly * Map SQL Timestamp <-> C# DateTime - Use Environment.NewLine to make test expectations in GetCreateIfNotExistsScript_works platform-independent. Use Environment.NewLine in test expectations, to make tests platform independent. Add support for DateOnly and TimeOnly C# types, and map SQL Date -> DateOnly; and SQL Time to TimeOnly - and leave SQL Timestamp -> C# DateTime. * [DOTNET-5] UnitTests. Adjust the config of the NUnitTest fixtures. Due to VisualStudio / C# strangeness, it seems impossible to find a config for the existing NUnitTestProject that is acceptable o C#/VS. * Create a new NUnitTestProjectCore project, and copy tests from NUnitTestProject. The Date/Time tests were running, and the results from the database were correct, but the test expectation strings were causing false error reports. Rework the logic in TestDataType() to fix the false errors. * Fix NullReference errors in NuoDbCommand. * Do not add non-override methods to NuoDbDataReader. Add that logic in existing methods instead. * Uncomment and complete the TimeStamp and TimeOnly getter methods in ValueString. * Add a DateTime TimeStamp getter to ValueTime. * Add a specific TimeOnly handler to EncodedDatStream.encodeDotNetObject(). * [DONET-5] Rename local DateTime vars in EncodedDataStream to differentiate them from local Date and Time vars. * Bump version to 5.0.0. Update main README to reflect content of README in EntityFramework project. --------- Co-authored-by: Nik Trevallyn-Jones <Nicholas.TREAVLLYN-JONES@3ds.com>
1 parent 0a12ad0 commit 7c362f9

28 files changed

+6145
-1345
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ WebApplicationSample/WebApplicationSample.csproj.user
1111
*.user
1212
/*.nupkg
1313
.vs
14+
.vscode/settings.json
Binary file not shown.

.vs/ADO.NET/config/applicationhost.config

Lines changed: 1034 additions & 1034 deletions
Large diffs are not rendered by default.

ADO.NET.sln

Lines changed: 238 additions & 220 deletions
Large diffs are not rendered by default.

NUnitTestProjectCore/BugFixture.cs

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
using System;
2+
using NUnit.Framework;
3+
using NuoDb.Data.Client;
4+
using System.Data.Common;
5+
using System.Data;
6+
using System.Collections;
7+
8+
namespace NUnitTestProject
9+
{
10+
[TestFixture]
11+
public class BugFixture1
12+
{
13+
[SetUp]
14+
public static void Init()
15+
{
16+
}
17+
18+
[Test]
19+
public void DB4329()
20+
{
21+
using (NuoDbConnection connection = new NuoDbConnection(TestFixture1.connectionString))
22+
{
23+
connection.Open();
24+
Utils.DropTable(connection, "ExpenseTest");
25+
DbCommand createCommand = new NuoDbCommand("Create table ExpenseTest" +
26+
"(" +
27+
"SourceExpenseId int," +
28+
"ExpenseAmount numeric(15,2)" +
29+
")", connection);
30+
createCommand.ExecuteNonQuery();
31+
32+
DbCommand insertCommand = new NuoDbCommand("Insert Into ExpenseTest(SourceExpenseId, ExpenseAmount) Values (?,?)", connection);
33+
insertCommand.Prepare();
34+
35+
insertCommand.Parameters[0].Value = -1254524;
36+
insertCommand.Parameters[1].Value = -135.35;
37+
insertCommand.ExecuteNonQuery();
38+
39+
insertCommand.Parameters[0].Value = 100100100;
40+
insertCommand.Parameters[1].Value = -1325465.35;
41+
insertCommand.ExecuteNonQuery();
42+
43+
insertCommand.Parameters[0].Value = 100100101;
44+
insertCommand.Parameters[1].Value = 200000.35;
45+
insertCommand.ExecuteNonQuery();
46+
47+
DbCommand selectCommand = new NuoDbCommand("select SourceExpenseId, ExpenseAmount from ExpenseTest", connection);
48+
using (DbDataReader reader = selectCommand.ExecuteReader())
49+
{
50+
bool hasNext=reader.Read();
51+
Assert.IsTrue(hasNext);
52+
Assert.AreEqual(-1254524, reader[0]);
53+
Assert.AreEqual(-135.35, reader[1]);
54+
hasNext = reader.Read();
55+
Assert.IsTrue(hasNext);
56+
Assert.AreEqual(100100100, reader[0]);
57+
Assert.AreEqual(-1325465.35, reader[1]);
58+
hasNext = reader.Read();
59+
Assert.IsTrue(hasNext);
60+
Assert.AreEqual(100100101, reader[0]);
61+
Assert.AreEqual(200000.35, reader[1]);
62+
}
63+
64+
}
65+
}
66+
}
67+
}

0 commit comments

Comments
 (0)