From 50b5a229c4fe547a896539f24c96e5e9a86ebb80 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Tue, 20 Oct 2020 20:58:32 +0300 Subject: DATA STORE ! --- .../Tango.UnitTesting/DataStore/DataStore_TST.cs | 82 ++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 Software/Visual_Studio/Tango.UnitTesting/DataStore/DataStore_TST.cs (limited to 'Software/Visual_Studio/Tango.UnitTesting/DataStore') 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", 10); + int value = collection.Get("int"); + Assert.AreEqual(value, 10); + } + + { + collection.Put("float", 10f); + float value = collection.Get("float"); + Assert.AreEqual(value, 10f); + } + + { + collection.Put("double", 10d); + double value = collection.Get("double"); + Assert.AreEqual(value, 10d); + } + + { + collection.Put("bool", true); + bool value = collection.Get("bool"); + Assert.AreEqual(value, true); + } + + { + collection.Put("string", "some value"); + string value = collection.Get("string"); + Assert.AreEqual(value, "some value"); + } + + { + collection.Put("bytes", new byte[] { 255 }); + byte[] value = collection.Get("bytes"); + Assert.AreEqual(value[0], 255); + } + + Assert.IsTrue(collection.Count() == 6); + + Assert.ThrowsException(() => collection.Put("somekey", this)); + + collection.Delete("int"); + Assert.ThrowsException(() => collection.Get("int")); + + collection.Delete("float"); + Assert.ThrowsException(() => collection.Get("float")); + + Assert.IsTrue(collection.Count() == 4); + + collection.DeleteAll(); + Assert.IsTrue(collection.Count() == 0); + + manager.Dispose(); + tempFile.Delete(); + } + } +} -- cgit v1.3.1