public void TestCyclePositiveCase() { var test = new CycleClass { Id = 1, Value = 1 }; var child = new CycleClass { Id = 2, Value = 5 }; test.ChildCycle = child; child.ChildCycle = test; // this creates our cycle condition _databaseInstance.SaveAsync(test).Wait(); var actual = _databaseInstance.LoadAsync <CycleClass>(1).Result; Assert.AreEqual(test.Id, actual.Id, "Failed to load cycle with non-null child: key mismatch."); Assert.AreEqual(test.Value, actual.Value, "Failed to load cycle with non-null child: value mismatch."); Assert.IsNotNull(test.ChildCycle, "Failed to load cycle with non-null child: child is null."); Assert.AreEqual(child.Id, actual.ChildCycle.Id, "Failed to load cycle with non-null child: child key mismatch."); Assert.AreEqual(child.Value, actual.ChildCycle.Value, "Failed to load cycle with non-null child: value mismatch."); actual = _databaseInstance.LoadAsync <CycleClass>(2).Result; Assert.AreEqual(child.Id, actual.Id, "Failed to load cycle with non-null child: key mismatch on direct child load."); Assert.AreEqual(child.Value, actual.Value, "Failed to load cycle with non-null child: value mismatch on direct child load."); }
public void TestCycleNegativeCase() { var test = new CycleClass { Id = 1, Value = 1 }; var child = new CycleClass {Id = 2, Value = 5 }; test.ChildCycle = child; _databaseInstance.SaveAsync( test ).Wait(); var actual = _databaseInstance.LoadAsync<CycleClass>( 1 ).Result; Assert.AreEqual(test.Id, actual.Id, "Failed to load cycle with non-null child: key mismatch."); Assert.AreEqual(test.Value, actual.Value, "Failed to load cycle with non-null child: value mismatch."); Assert.IsNotNull(test.ChildCycle, "Failed to load cycle with non-null child: child is null."); Assert.AreEqual(child.Id, actual.ChildCycle.Id, "Failed to load cycle with non-null child: child key mismatch."); Assert.AreEqual(child.Value, actual.ChildCycle.Value, "Failed to load cycle with non-null child: value mismatch."); actual = _databaseInstance.LoadAsync<CycleClass>( 2 ).Result; Assert.AreEqual(child.Id, actual.Id, "Failed to load cycle with non-null child: key mismatch on direct child load."); Assert.AreEqual(child.Value, actual.Value, "Failed to load cycle with non-null child: value mismatch on direct child load."); }