public void DeleteTest() { //arrange var exp1 = new Experiment("exp1"); var exp11 = new Experiment("exp1-1"); var exp12 = new Experiment("exp1-2"); var sig121 = new Signal("sig1-2-1"); var sig111 = new Signal("sig1-1-1"); myCoreService.AddJdbcEntityToAsync(Guid.Empty, exp1).Wait(); myCoreService.AddJdbcEntityToAsync(exp1.Id, exp11).Wait(); myCoreService.AddJdbcEntityToAsync(exp1.Id, exp12).Wait(); myCoreService.AddJdbcEntityToAsync(exp12.Id, sig121).Wait(); myCoreService.AddJdbcEntityToAsync(exp11.Id, sig111).Wait(); var data = generateDummyData(); for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { var oneDim = new List <double>(8); for (int k = 0; k < 8; k++) { oneDim.Add(data[i, j, k]); } //notice that this has only 2 interations for 3 dimention arry storageEngine.AppendSampleAsync(sig111.Id, new List <long> { i, j }, oneDim).Wait(); } } myCoreService.DuplicateAsync(exp11.Id, exp1.Id, "exp1-1-c", true, true).Wait(); //old tree /* * /exp1/exp11/sig111/payload1-1-1-1 * /exp12/sig121 * /exp11c/sig111/payload-1-1-1 */ //act //var cursor = storageEngine.GetCursorAsync<double>(sig111.Id, new List<long> { 2, 1, 3 }, new List<long> { 2, 2, 2 }).Result; //List<double> result = cursor.Read(3).Result.ToList(); //double[] assertresult = { 213, 214, 223 }; //CollectionAssert.AreEqual(assertresult, result); myCoreService.DeleteAsync(exp11.Id, true).Wait(); var exp11Result = myCoreService.GetChildByNameAsync(exp1.Id, "exp1-1").Result; Assert.AreEqual(null, exp11Result); var sig111Duplicate = myCoreService.GetOneByPathAsync("/exp1/exp1-1-c/sig1-1-1").Result; var cursor = storageEngine.GetCursorAsync <double>(sig111Duplicate.Id, new List <long> { 2, 1, 3 }, new List <long> { 2, 2, 2 }).Result; List <double> result = cursor.Read(3).Result.ToList(); double[] assertresult = { 213, 214, 223 }; CollectionAssert.AreEqual(assertresult, result); storageEngine.DeleteDataAsync(sig111Duplicate.Id); try { var cursor1 = storageEngine.GetCursorAsync <double>(sig111Duplicate.Id, new List <long> { 2, 1, 3 }, new List <long> { 2, 2, 3 }).Result; List <double> result1 = cursor1.Read(3).Result.ToList(); } catch (Exception e) { Assert.AreEqual(e.InnerException.Message, ErrorMessages.OutOfRangeError); } }
public void DeleteTest() { //arrange //arrange var exp1 = new Experiment("exp1"); var exp2 = new Experiment("exp2"); var exp11 = new Experiment("exp1-1"); var exp111 = new Experiment("exp1-1-1"); var exp12 = new Experiment("exp1-2"); var sig121 = new Signal("sig1-2-1"); var sig111 = new Signal("sig1-1-1"); //add 2 root myCoreService.AddJdbcEntityToAsync(Guid.Empty, exp1).Wait(); myCoreService.AddJdbcEntityToAsync(Guid.Empty, exp2).Wait(); //add child myCoreService.AddJdbcEntityToAsync(exp1.Id, exp11).Wait(); myCoreService.AddJdbcEntityToAsync(exp1.Id, exp12).Wait(); myCoreService.AddJdbcEntityToAsync(exp12.Id, sig121).Wait(); myCoreService.AddJdbcEntityToAsync(exp11.Id, sig111).Wait(); myCoreService.AddJdbcEntityToAsync(exp11.Id, exp111).Wait(); var data = generateDummyData(); for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { var oneDim = new List <double>(8); for (int k = 0; k < 8; k++) { oneDim.Add(data[i, j, k]); } //notice that this has only 2 interations for 3 dimention arry mongoEngine.AppendSampleAsync(sig111.Id, new List <long> { i, j }, oneDim).Wait(); } } //old tree /* * /exp1/exp11/sig111/payload1-1-1-1 * /exp111 * /exp12/sig121 * /exp2 * */ //act //try delet exp12 error expetced var errorDelete = ""; try { myCoreService.DeleteAsync(exp12.Id).Wait(); } catch (Exception e) { errorDelete = e.InnerException.Message; } myCoreService.DeleteAsync(exp12.Id, true).Wait(); myCoreService.DeleteAsync(exp2.Id).Wait(); //the deleted entity is non exist, error expected string errorDeleteNonExist = ""; try { myCoreService.DeleteAsync(exp2.Id).Wait(); } catch (Exception e) { //this is async call so exception is wrapped errorDeleteNonExist = e.InnerException.Message; } //get for assert var root = myCoreService.GetAllChildrenAsync().Result; var nSig121 = myCoreService.GetOneByIdAsync(sig121.Id).Result; var nExp12 = myCoreService.GetChildIdByNameAsync(exp1.Id, exp12.Name).Result; //assert Assert.AreEqual(ErrorMessages.DeleteEntityWithChildError, errorDelete); Assert.AreEqual(ErrorMessages.EntityNotFoundError, errorDeleteNonExist); CollectionAssert.AreEquivalent(new List <Guid> { exp1.Id }, root.Select(r => r.Id).ToList()); Assert.IsNull(nSig121); Assert.AreEqual(Guid.Empty, nExp12); var payloads = mongoEngine.GetPayloadIdsByParentIdAsync(sig111.Id).Result; Assert.AreEqual(64, payloads.Count()); myCoreService.DeleteAsync(sig111.Id, true).Wait(); var payloadZero = mongoEngine.GetPayloadIdsByParentIdAsync(sig111.Id).Result; Assert.AreEqual(0, payloadZero.Count()); }
public void DeleteTest() { var exp1 = new Experiment("exp1"); var exp2 = new Experiment("exp2"); var exp11 = new Experiment("exp1-1"); var exp111 = new Experiment("exp1-1-1"); var exp12 = new Experiment("exp1-2"); var sig121 = new Signal("sig1-2-1"); var sig111 = new Signal("sig1-1-1"); var sigerror = new Signal("sigerror"); //add 2 root myCoreService.AddJdbcEntityToAsync(Guid.Empty, exp1).Wait(); myCoreService.AddJdbcEntityToAsync(Guid.Empty, exp2).Wait(); //add child myCoreService.AddJdbcEntityToAsync(exp1.Id, exp11).Wait(); myCoreService.AddJdbcEntityToAsync(exp1.Id, exp12).Wait(); myCoreService.AddJdbcEntityToAsync(exp12.Id, sig121).Wait(); myCoreService.AddJdbcEntityToAsync(exp11.Id, sig111).Wait(); myCoreService.AddJdbcEntityToAsync(exp11.Id, exp111).Wait(); //old tree /* * /exp1/exp11/sig111 * /exp111 * /exp12/sig121 * /exp2 */ //act //try delet exp12 error expetced //1 cannot delete the parent nod if not set recuresive. var errorDelete = ""; try { myCoreService.DeleteAsync(exp12.Id).Wait(); } catch (Exception e) { errorDelete = e.InnerException.Message; } Assert.AreEqual(ErrorMessages.DeleteEntityWithChildError, errorDelete); //2 the deleted entity is non exist, error expected. myCoreService.DeleteAsync(exp12.Id, true).Wait(); myCoreService.DeleteAsync(exp2.Id).Wait(); string errorDeleteNonExist = ""; try { myCoreService.DeleteAsync(exp2.Id).Wait(); } catch (Exception e) { //this is async call so exception is wrapped errorDeleteNonExist = e.InnerException.Message; } Assert.AreEqual(ErrorMessages.EntityNotFoundError, errorDeleteNonExist); //3 get for assert var root = myCoreService.GetAllChildrenAsync().Result; CollectionAssert.AreEquivalent(new List <Guid> { exp1.Id }, root.Select(r => r.Id).ToList()); var nSig121 = myCoreService.GetOneByIdAsync(sig121.Id).Result; Assert.IsNull(nSig121); var nExp12 = myCoreService.GetChildIdByNameAsync(exp1.Id, exp12.Name).Result; Assert.AreEqual(Guid.Empty, nExp12); }