diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-10-20 20:58:32 +0300 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-10-20 20:58:32 +0300 |
| commit | 50b5a229c4fe547a896539f24c96e5e9a86ebb80 (patch) | |
| tree | 653f78a466296564862e5bcba38422284f693545 /Software/Visual_Studio/Tango.UnitTesting/DataStore | |
| parent | b732167cbc51f0b19447d67687af5c514cf4f65a (diff) | |
| download | Tango-50b5a229c4fe547a896539f24c96e5e9a86ebb80.tar.gz Tango-50b5a229c4fe547a896539f24c96e5e9a86ebb80.zip | |
DATA STORE !
Diffstat (limited to 'Software/Visual_Studio/Tango.UnitTesting/DataStore')
| -rw-r--r-- | Software/Visual_Studio/Tango.UnitTesting/DataStore/DataStore_TST.cs | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Tango.UnitTesting/DataStore/DataStore_TST.cs b/Software/Visual_Studio/Tango.UnitTesting/DataStore/DataStore_TST.cs new file mode 100644 index 000000000..4a7d55e1e --- /dev/null +++ b/Software/Visual_Studio/Tango.UnitTesting/DataStore/DataStore_TST.cs @@ -0,0 +1,82 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks; +using Tango.PMR; +using Tango.PMR.Embroidery; +using Tango.DataStore; +using Tango.DataStore.Lite; +using Tango.Core.IO; + +namespace Tango.UnitTesting.DataStore +{ + [TestClass] + [TestCategory("DataStore")] + public class DataStore_TST + { + [TestMethod] + public void LiteDB_DataStore_Working() + { + var tempFile = TemporaryManager.Default.CreateImaginaryFile(); + IDataStoreManager manager = new LiteDBDataStoreManager(tempFile); + IDataStoreCollection collection = manager.GetCollection("TEST"); + + { + collection.Put<int>("int", 10); + int value = collection.Get<int>("int"); + Assert.AreEqual<int>(value, 10); + } + + { + collection.Put<float>("float", 10f); + float value = collection.Get<float>("float"); + Assert.AreEqual<float>(value, 10f); + } + + { + collection.Put<double>("double", 10d); + double value = collection.Get<double>("double"); + Assert.AreEqual<double>(value, 10d); + } + + { + collection.Put<bool>("bool", true); + bool value = collection.Get<bool>("bool"); + Assert.AreEqual<bool>(value, true); + } + + { + collection.Put<string>("string", "some value"); + string value = collection.Get<string>("string"); + Assert.AreEqual<string>(value, "some value"); + } + + { + collection.Put<byte[]>("bytes", new byte[] { 255 }); + byte[] value = collection.Get<byte[]>("bytes"); + Assert.AreEqual<byte>(value[0], 255); + } + + Assert.IsTrue(collection.Count() == 6); + + Assert.ThrowsException<NotSupportedException>(() => collection.Put<DataStore_TST>("somekey", this)); + + collection.Delete("int"); + Assert.ThrowsException<KeyNotFoundException>(() => collection.Get<int>("int")); + + collection.Delete("float"); + Assert.ThrowsException<KeyNotFoundException>(() => collection.Get<float>("float")); + + Assert.IsTrue(collection.Count() == 4); + + collection.DeleteAll(); + Assert.IsTrue(collection.Count() == 0); + + manager.Dispose(); + tempFile.Delete(); + } + } +} |
