public void UpdateMany_Success() { var icarus = IcarusClient.Instance; var collection = icarus.GetDataStore(_dataStore).GetCollection <SomeObject2>(_collection); var obj1 = new SomeObject2() { SomeInt = 1, SomeString = "Hello1", Temp = "Anything1" }; var obj2 = new SomeObject2() { SomeInt = 2, SomeString = "Hello2", Temp = "Anything2" }; var items = collection.InsertMany(new SomeObject2[] { obj1, obj2 }); Assert.AreEqual(1, items[0]._id); Assert.AreEqual(2, items[1]._id); obj1.SomeString = "Updated"; obj2.SomeString = "Updated"; items = collection.UpdateMany(new SomeObject2[] { obj1, obj2 }); Assert.IsNotNull(items); Assert.AreEqual("Hello1", items[0].SomeString); Assert.AreEqual(1, items[0].SomeInt); Assert.AreEqual(1, items[0]._id); var item = collection.Find(1); Assert.IsNotNull(item); Assert.AreEqual("Updated", item.SomeString); Assert.AreEqual(1, item.SomeInt); Assert.AreEqual(1, item._id); }
//[TestCase(100, 60)] //[TestCase(1000, 600)] //[TestCase(10000, 6000)] //[TestCase(100000, 60000)] public void LargeDataSet(int amount, int toFind) { var icarus = IcarusClient.Instance; var collection = icarus.GetDataStore(_dataStore).GetCollection <SomeObject2>(_collection); for (var i = 1; i <= amount; i++) { var _obj = new SomeObject2() { SomeInt = i, SomeString = "Hello" + i, Temp = "Anything" + i }; var _item = collection.Insert(_obj, false); Assert.AreEqual(i, _item._id); } collection.Persist(); collection.Refresh(); var item = collection.Find(toFind); Assert.IsNotNull(item); Assert.AreEqual("Hello" + toFind, item.SomeString); Assert.AreEqual(toFind, item.SomeInt); Assert.AreEqual(toFind, item._id); }
public void RemoveMany_Success() { var icarus = IcarusClient.Instance; var obj1 = new SomeObject2() { SomeInt = 1, SomeString = "Hello1", Temp = "Anything1" }; var obj2 = new SomeObject2() { SomeInt = 2, SomeString = "Hello2", Temp = "Anything2" }; var items = icarus.GetDataStore(_dataStore).GetCollection <SomeObject2>(_collection).InsertMany(new[] { obj1, obj2 }); Assert.AreEqual(2, items.Count); Assert.AreEqual(1, items[0]._id); Assert.AreEqual(2, items[1]._id); var items2 = icarus.GetDataStore(_dataStore).GetCollection <SomeObject2>(_collection).RemoveMany(new[] { 1L, 2L }); Assert.IsNotNull(items2); Assert.AreEqual(2, items2.Count); Assert.AreEqual("Hello1", items2[0].SomeString); Assert.AreEqual(1, items2[0].SomeInt); Assert.AreEqual(1, items2[0]._id); var item = icarus.GetDataStore(_dataStore).GetCollection <SomeObject2>(_collection).Find(1); Assert.IsNull(item); }
public void Update_Success() { var icarus = IcarusClient.Instance; var obj1 = new SomeObject2() { SomeInt = 1, SomeString = "Hello1", Temp = "Anything1" }; var item = icarus.GetDataStore(_dataStore).GetCollection <SomeObject2>(_collection).Insert(obj1); Assert.AreEqual(1, item._id); obj1.SomeString = "Updated"; item = icarus.GetDataStore(_dataStore).GetCollection <SomeObject2>(_collection).Update(obj1); Assert.IsNotNull(item); Assert.AreEqual("Hello1", item.SomeString); Assert.AreEqual(1, item.SomeInt); Assert.AreEqual(1, item._id); item = icarus.GetDataStore(_dataStore).GetCollection <SomeObject2>(_collection).Find(1); Assert.IsNotNull(item); Assert.AreEqual("Updated", item.SomeString); Assert.AreEqual(1, item.SomeInt); Assert.AreEqual(1, item._id); }
public void FindMany_Filter_Success(object value, IcarusEqualityFilter filter, int expectedAmount, bool isNull) { var icarus = IcarusClient.Instance; var obj1 = new SomeObject2() { SomeInt = 1, SomeString = "Hello1", Temp = "Anything1" }; var obj2 = new SomeObject2() { SomeInt = 2, SomeString = "Hello2", Temp = "Anything2" }; var items = icarus.GetDataStore(_dataStore).GetCollection <SomeObject2>(_collection).InsertMany(new[] { obj1, obj2 }); Assert.AreEqual(2, items.Count); Assert.AreEqual(1, items[0]._id); Assert.AreEqual(2, items[1]._id); var items2 = icarus.GetDataStore(_dataStore).GetCollection <SomeObject2>(_collection).FindMany("SomeInt", value, filter); if (isNull) { Assert.IsNull(items2); } else { Assert.IsNotNull(items2); Assert.AreEqual(expectedAmount, items2.Count); } }
public void Find_JsonPath_Boolean_Success(bool value) { var icarus = IcarusClient.Instance; var obj1 = new SomeObject2() { SomeInt = 1, SomeBool = true, Temp = "Anything1" }; var obj2 = new SomeObject2() { SomeInt = 1, SomeBool = false, Temp = "Anything2" }; var collection = icarus.GetDataStore(_dataStore).GetCollection <SomeObject2>(_collection); var items = collection.InsertMany(new[] { obj1, obj2 }); Assert.AreEqual(2, items.Count); Assert.AreEqual(1, items[0]._id); Assert.AreEqual(2, items[1]._id); var item = collection.Find("$[?(@.SomeBool == " + value.ToString().ToLower() + ")]"); Assert.IsNotNull(item); Assert.AreEqual(1, item.SomeInt); Assert.AreEqual(value, item.SomeBool); Assert.AreEqual(value ? 1 : 2, item._id); }
public void InsertMany_Fail_NullReference() { var icarus = IcarusClient.Instance; var obj = new SomeObject2() { SomeInt = 1, SomeString = "Hello" }; var items = icarus.GetDataStore(_dataStore).GetCollection <SomeObject2>(_collection).InsertMany(new[] { obj }); }
public void Insert_Success() { var icarus = IcarusClient.Instance; var obj = new SomeObject2() { SomeInt = 1, SomeString = "Hello", Temp = "Anything" }; var item = icarus.GetDataStore(_dataStore).GetCollection <SomeObject2>(_collection).Insert(obj); Assert.AreEqual(1, item._id); }
public void Find_Filter_SuccessOnDates(IcarusEqualityFilter filter, bool isNull) { var icarus = IcarusClient.Instance; var now = DateTime.Now; var obj1 = new SomeObject2() { SomeDate = now, Temp = "Anything1" }; var obj2 = new SomeObject2() { SomeDate = now.AddDays(1), Temp = "Anything2" }; var items = icarus.GetDataStore(_dataStore).GetCollection <SomeObject2>(_collection).InsertMany(new[] { obj1, obj2 }); Assert.AreEqual(2, items.Count); Assert.AreEqual(1, items[0]._id); Assert.AreEqual(2, items[1]._id); var item = default(SomeObject2); switch (filter) { case IcarusEqualityFilter.Equal: item = icarus.GetDataStore(_dataStore).GetCollection <SomeObject2>(_collection).Find("SomeDate", now, filter); break; case IcarusEqualityFilter.NotEqual: item = icarus.GetDataStore(_dataStore).GetCollection <SomeObject2>(_collection).Find("SomeDate", now.AddDays(-1), filter); break; case IcarusEqualityFilter.GreaterThan: item = icarus.GetDataStore(_dataStore).GetCollection <SomeObject2>(_collection).Find("SomeDate", now.AddMinutes(5), filter); break; } if (isNull) { Assert.IsNull(item); } else { Assert.IsNotNull(item); } }
public void TwoIcarusLocations_Insert_Success() { IcarusClient.Instance.Initialise(".\\Test", "test2"); var icarus = IcarusClient.Instance; var obj = new SomeObject2() { SomeInt = 1, SomeString = "Hello", Temp = "Anything" }; var item = icarus.GetDataStore("InnerTest", "test2").GetCollection <SomeObject2>(_collection).Insert(obj); Assert.AreEqual(1, item._id); var path = Path.GetFullPath(".\\Test\\InnerTest\\" + _collection + ".json"); Assert.IsTrue(File.Exists(path)); }
public void InsertMany_Success() { var icarus = IcarusClient.Instance; var obj1 = new SomeObject2() { SomeInt = 1, SomeString = "Hello1", Temp = "Anything1" }; var obj2 = new SomeObject2() { SomeInt = 1, SomeString = "Hello2", Temp = "Anything2" }; var items = icarus.GetDataStore(_dataStore).GetCollection <SomeObject2>(_collection).InsertMany(new[] { obj1, obj2 }); Assert.AreEqual(2, items.Count); Assert.AreEqual(1, items[0]._id); Assert.AreEqual(2, items[1]._id); }
public void FindMany_Ids_Success_Nothing() { var icarus = IcarusClient.Instance; var obj1 = new SomeObject2() { SomeInt = 1, SomeString = "Hello1", Temp = "Anything1" }; var item = icarus.GetDataStore(_dataStore).GetCollection <SomeObject2>(_collection).Insert(obj1); var items = icarus.GetDataStore(_dataStore).GetCollection <SomeObject2>(_collection).FindMany(new[] { 1L, 2L }); Assert.IsNotNull(items); Assert.AreEqual(2, items.Count); Assert.AreEqual("Hello1", items[0].SomeString); Assert.AreEqual(1, items[0].SomeInt); Assert.AreEqual(1, items[0]._id); Assert.IsNull(items[1]); }
public void Find_JsonPath_FailForMultiple() { var icarus = IcarusClient.Instance; var obj1 = new SomeObject2() { SomeInt = 2, SomeString = "Hello1", Temp = "Anything1" }; var obj2 = new SomeObject2() { SomeInt = 2, SomeString = "Hello2", Temp = "Anything2" }; var items = icarus.GetDataStore(_dataStore).GetCollection <SomeObject2>(_collection).InsertMany(new[] { obj1, obj2 }); Assert.AreEqual(2, items.Count); Assert.AreEqual(1, items[0]._id); Assert.AreEqual(2, items[1]._id); var item = icarus.GetDataStore(_dataStore).GetCollection <SomeObject2>(_collection).Find("$[?(@.SomeInt == 2)]"); }
public void Find_Filter_FailForMultiple(object value, IcarusEqualityFilter filter) { var icarus = IcarusClient.Instance; var obj1 = new SomeObject2() { SomeInt = 1, SomeString = "Hello1", Temp = "Anything1" }; var obj2 = new SomeObject2() { SomeInt = 2, SomeString = "Hello2", Temp = "Anything2" }; var items = icarus.GetDataStore(_dataStore).GetCollection <SomeObject2>(_collection).InsertMany(new[] { obj1, obj2 }); Assert.AreEqual(2, items.Count); Assert.AreEqual(1, items[0]._id); Assert.AreEqual(2, items[1]._id); var item = icarus.GetDataStore(_dataStore).GetCollection <SomeObject2>(_collection).Find("SomeInt", value, filter); }
public void CheckIsNew_Success() { var icarus = IcarusClient.Instance; var obj = new SomeObject2() { SomeInt = 1, SomeString = "Hello", Temp = "Anything" }; var expectedDataStore = !Directory.Exists(".\\Test"); var expectedCollection = !File.Exists(".\\Test\\" + _collection + ".json"); var isNewDataStore = true; var isNewCollection = true; var item = icarus.GetDataStore(_dataStore, out isNewDataStore).GetCollection <SomeObject2>(_collection, out isNewCollection).Insert(obj); Assert.AreEqual(1, item._id); Assert.AreEqual(expectedDataStore, isNewDataStore, "Data store check incorrect"); Assert.AreEqual(expectedCollection, isNewCollection, "Collection check incorrect"); }
public void Find_Filter_Boolean_Success(IcarusEqualityFilter filter, bool value) { var icarus = IcarusClient.Instance; var obj1 = new SomeObject2() { SomeInt = 1, SomeBool = true, Temp = "Anything1" }; var obj2 = new SomeObject2() { SomeInt = 1, SomeBool = false, Temp = "Anything2" }; var collection = icarus.GetDataStore(_dataStore).GetCollection <SomeObject2>(_collection); var items = collection.InsertMany(new[] { obj1, obj2 }); Assert.AreEqual(2, items.Count); Assert.AreEqual(1, items[0]._id); Assert.AreEqual(2, items[1]._id); var item = collection.Find("SomeBool", value, filter); Assert.IsNotNull(item); Assert.AreEqual(1, item.SomeInt); if (filter == IcarusEqualityFilter.Equal) { Assert.AreEqual(value, item.SomeBool); Assert.AreEqual(value ? 1 : 2, item._id); } else { Assert.AreEqual(!value, item.SomeBool); Assert.AreEqual(value ? 2 : 1, item._id); } }