openactive / OpenActive.Server.NET

.NET server library, including an OpenActive Reference Implementation
MIT License
0 stars 7 forks source link

Refactor OpenActive.FakeDatabase.NET to use SQLite #7

Closed nickevansuk closed 4 years ago

nickevansuk commented 4 years ago

Swap the POCO-based implementation of OpenActive.FakeDatabase.NET to use in-memory SQLite. This continues the work started in https://github.com/openactive/OpenActive.Server.NET/pull/6.

Suggest using System.Data.SQLite instead of Microsoft.Data.SQLite to ensure that FakeDatabase.NET builds both in .NET Core and .NET 4.5.

Although the work done in #6 uses NPoco and hacks together a code-first attempt to use to use in-memory SQLite, OrmLite offers better functionality and a true code-first solution.

So as a definition-of-done we should have removed these old POCO lists and replace with in-memory SQLite + OrmLite: https://github.com/openactive/OpenActive.Server.NET/blob/c3f5f85be0444427332ce042d19eccc297e8ba0d/Fakes/OpenActive.FakeDatabase.NET/FakeBookingSystem.cs#L73-L78

And updated references to FakeDatabase.NET within the reference implementation to use OrmLite too, such as the following: https://github.com/openactive/OpenActive.Server.NET/blob/c3f5f85be0444427332ce042d19eccc297e8ba0d/Examples/BookingSystem.AspNetCore/Feeds/SessionsFeeds.cs#L18-L22

The resulting PR should have all tests OpenActive Test Suite tests passing, as well as .NET tests, including those additional tests added in #6. The CI is setup with GitHub Actions to run both of this.

nickevansuk commented 4 years ago

Most of the work to achieve this has been completed in #9, however there is still some kind of race condition here: https://github.com/openactive/OpenActive.Server.NET/pull/9#issuecomment-671034383

This may be related to the SQLlite transaction mode?

nickevansuk commented 4 years ago

This has been resolved within this PR, by switching to SQLite to use a file instead of in-memory, and using Microsoft.Data.Sqlite instead of System.Data.SQLite: https://github.com/openactive/OpenActive.Server.NET/pull/21. Also by implementing transactions within the booking engine.