How do you setup Mvvmcross SQLite plugin to be tested? - sqlite

I'm quite new to mvvmcross and I'm working on an app that uses SQLite plugin as "backend" for the model. (WinRT and WP/8 only at the moment but porting it to Droid and IOS when firts two platforms work ok).
I would like to setup some tests using NUnit and VS2012 but having some difficulties to find examples on how to initialize the framework and the plugin in the SetupFixture class/setup for the test.
Can someone who already have done this point me in the right direction ?
Thank you very much for your time and help

I generally don't test at the SQLite interface level itself.
Instead, I generally wrap the use of SQLite inside very simple repositories. Each of these repositories provides an interface. Each of the repositories and SQLite itself is assumed to be a known good components - so it not tested. And this allows me to then test other code using Mocks for these repositories, rather than trying to mock or use SQLite itself.
If you want to test at the SQLite level:
You could write a ISQLiteConnection test implementation
Or you could write something that used one of the SQLite on Windows plugins for testing

Related

SQLite-Net-Pcl in Xamarin.Forms

I am trying to learn SQLite and its usage from Xamarin.Forms. I found that it is recommended to install Sqlite-net-pcl as NuGet package and make use of it to create, open, modify a database. Up to that point everything is fine. However, I am struggling to find more details about Sqlite-net-pcl on the web. It seems, a comprehensive documentation is not available for this library. And this reality brought some questions to my mind which I believe I could get answer from Stackoverflow seniors:
1-If there is no documentation of a library which you are trying to use, what is the best way to learn it quickly? Trial&Error? In that case full class hierarchy would be needed, I think.
2-As I understood, Sqlite-net-pcl is a partial implementation of Sqlite. For instance, in the documentation of Sqlite, it is said, Foreign key is supported but should be enabled. But, I couldnt find this attribute in Sqlite-net-Pcl when I used the ObjectBrowser tool of VisualStudio.
3-Considering, SQLite have better support, If I want to use SQLite directly in xamarin.forms(c#) instead of its derived versions(Sqlite-net-pcl) how can I achieve this?
It is preferable to use SQLite-net libraries. They are simply a wrapper around SQLite flow. You have everything that you need there. Also, if you want to use an ORM, you can also use EntityFrameworkCore via Microsoft.EntityFrameworkCore.Sqlite
Like it is said in the GitHub repository:
SQLite-net is an open source, minimal library to allow .NET, .NET Core, and Mono applications to store data in SQLite 3 databases. It was first designed to work with Xamarin.iOS, but has since grown up to work on all the platforms (Xamarin.*, .NET, UWP, Azure, etc.).
About the Foreign Key - there isn't any constraints. You can use it freely without any "enabling".
There are some other options like Microsoft.Data.SQLite & System.Data.SQLite, but I haven't tried them with Xamarin and, if they work, I don't think that they will have better support for Mono, like the one that you have with SQLite-net. The latter is also updated constantly.
Here is the official tutorial from Microsoft about using sqlite-net-pcl
If you want to use an ORM, you can follow this article from the official docs on how to setup the SQLite libraries, together with EFCore packages, migrations, etc.
Should you choose to use EFCore, please consider the Migration Limitations.

How effectively develop Azure blueprints?

I'm starting to develop Azure blueprints and I can see that structure of ARM template is different compared to one used in ARM deployment. I like to modularize code and trying to figure out how I can properly develop individual ARM templates and then incorporate into final blueprint properly. As of right now instead of directly putting ARM artifact into blueprint (along with 100 others) I just manually debug ARM template and then cut in paste into artifact. I'm wondering if there is more effective way doing that or I missing something? Based on documentation it seems to be suggested directly incorporate templates into artifacts then deploy/publish/assign blueprint which takes way to much when you just need to work on single ARM template
An effective / dynamic / automated way can be accomplished by leveraging this Blueprints as Code repository for management and dynamic way of configuring lifecycle of your blueprints which helps in reducing the effort compared to Portal way of managing the blueprints.
Other related references:
Functions for use with Blueprints
Blueprints REST API Reference
Blueprints Az PowerShell Reference

Ionic 2 storage module clarification

There is a lot of confusion when it comes to ionic 2 storage. There was a lot of changes in the new ionic version as Storage was moved to #ionic/strage . I am new to Ionic so some of the things are confusing for me. I have web-development background. From the documentation,
A simple key-value Storage module for Ionic apps based on LocalForage,
with out-of-the-box support for SQLite. This utility makes it easy to
use the best storage engine available without having to interact with
it directly. Currently the ordering is SQLite, IndexedDB, WebSQL, and
LocalStorage.
Installation
npm install #ionic/storage
If you'd like to use SQLite as a storage engine, install a SQLite plugin (only works while running in a simulator or on device):
cordova plugin add cordova-sqlite-storage --save
What I would like to know is, what happens when I run this in browser ? Where does it store the data? What would happen if I dont use cordova-sqlite-storage ? Where does it store the data then?
Ionic also supports SQLite plugin natively to store data in SQLite database .
import { SQLite } from 'ionic-native'
How is it different from Storage other than the fact that there is a fallback to IndexedDB, WebSQL, and LocalStorage ?
I hope my thoughts are in the right direction. A clear answer on how these modules work would be really helpful.
Ionic Storage is the first module written with proper web fallback in mind.
One near-term goal we have with Ionic is enabling devs to build 99% of their app in the browser. It's a much faster workflow. This means support for native plugins that have web fallbacks, as well as better mocking for ones that don't. - Max Lynch on Twitter
By default when running, #ionic/storage will prioritize the storage methods this way:
When running in a native app context, Storage will prioritize using
SQLite, as it's one of the most stable and widely used file-based
databases, and avoids some of the pitfalls of things like localstorage
and IndexedDB, such as the OS deciding to clear out such data in low
disk-space situations.
When running in the web or as a Progressive Web App, Storage will attempt to use IndexedDB, WebSQL, and localstorage, in that order.
- Official Documentation
So when your app is running in the browser (or on a device without the SQLite plugin) it will detect that SQLite is not available and will use IndexedDB/WebSQL instead.
How is it different from Storage other than the fact that there is a fallback to IndexedDB, WebSQL, and LocalStorage?
The SQLite plugin gives you low-level access to an SQLite database, which means you have to care about creating/updating your schemas, and write queries.
#ionic/storage is a wrapper which abstract away the differences of LocalForge and SQLite and provide a simple, unified API to store key/value pairs.
Also it takes care of serializing/deserializing of your objects.
From my understanding of the Ionic 2 RC Storage module, when you are running in the browser you are now only able to store key-value pairs (LocalStorage). You are currently not able to store anything more than that, so you should check out other options like PouchDB and LocalForage if you need full SQL support. This definitely isn't ideal for progressive web apps.

Combine Meteor and Express

I am evaluating Meteor as an alternative to developing real-time capabilities using socket.io and it looks like awesome framework for single page real-time apps. It is great time saver that enables developer focusing on the business logic of the app, rather than writing boilerplate code. However, I find it still pre-mature for a medium size app with multiple pages/routings and REST api. Plus, number of features like i18n are still not available which requires some time investment to develop by myself.
I think that it would be great if I could combine Meteor and Express and use Meteor in use cases where it really shines.
Is it possible to develop an app using standard Express/Mongo stack and use Meteor for only specific part of the app where I need real time collaboration?
For example, can I share a session between Express/Connect and Meteor?
Thanks!
This does not directly answer your question, but I thought I'd throw it out there:
You should check out the community packages on atmosphere. Specifically, I'd recommend having a look at iron-router and i18n (I'll note I have not used the latter).
I've built a large production app that uses iron-router and it's running smoothly. You may also be able to use its server-side-routing capabilities to implement your REST api.

Will using dblinq to SQLite in a Windows Store app pass store validation?

I've been trying to figure out how to get a decent LINQ to something working for ORM database access in a Windows Store app.
All I've found is SQLite and the sqlite-net NuGet package. The latter sucks a bit, as I don't get any .dbml like structure which resolves relationships and provides navigation properties for easy querying (no manual joins needed then).
I was wondering:
Does dblinq in comnbination with SQLite offer this?
Will using this pass Windows Store validation?
Thank you !
Update: Some links I used in my research:
The famous Tim Heuer post on SQLite and Windows 8: http://timheuer.com/blog/archive/2012/08/07/updated-how-to-using-sqlite-from-windows-store-apps.aspx
DBlinq: http://code.google.com/p/dblinq2007/
sqlite-net: http://code.google.com/p/sqlite-net/
Interesting discussion stating ADO.NET is not possible: http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/e9cdd75d-03e4-4577-988e-4c02a52e3f50
I'm not familiar with dblinq but by looking at the sqlite tests in the project, it seems the library is offering what you're looking for, i.e. navigation properties for relationships between different tables.
Since dblinq is a .NET library, using it shouldn't make the store validation fail. There is another problem though: you can't use such a .NET library in a Windows Store application, only Windows Store class libraries and portable class libraries are allowed. Since the source for the library is available, you can try compiling it as a Windows Store class library, but I'm afraid there are going to be some classes missing that dblinq is depending on which might make it difficult to port.

Resources