public void TestSaveForeign() { var expected = TestAggregateModel.MakeAggregateModel(); _databaseInstance.SaveAsync(expected).Wait(); var actual = _databaseInstance.LoadAsync <TestAggregateModel>(expected.Key).Result; var actualTestModel = _databaseInstance.LoadAsync <TestModel>(expected.TestModelInstance.Key).Result; var actualForeignModel = _databaseInstance.LoadAsync <TestForeignModel>(expected.TestForeignInstance.Key).Result; var actualDerivedModel = _databaseInstance.LoadAsync <TestDerivedClassAModel>(expected.TestBaseClassInstance.Key).Result; Assert.AreEqual(expected.Key, actual.Key, "Load with foreign key failed: key mismatch."); Assert.AreEqual(expected.TestForeignInstance.Key, actual.TestForeignInstance.Key, "Load failed: foreign key mismatch."); Assert.AreEqual(expected.TestForeignInstance.Data, actual.TestForeignInstance.Data, "Load failed: foreign data mismatch."); Assert.AreEqual(expected.TestModelInstance.Key, actual.TestModelInstance.Key, "Load failed: test model key mismatch."); Assert.AreEqual(expected.TestModelInstance.Data, actual.TestModelInstance.Data, "Load failed: test model data mismatch."); Assert.AreEqual(expected.TestForeignInstance.Key, actualForeignModel.Key, "Load failed: foreign key mismatch on direct load."); Assert.AreEqual(expected.TestForeignInstance.Data, actualForeignModel.Data, "Load failed: foreign data mismatch on direct load."); Assert.AreEqual(expected.TestModelInstance.Key, actualTestModel.Key, "Load failed: test model key mismatch on direct load."); Assert.AreEqual(expected.TestModelInstance.Data, actualTestModel.Data, "Load failed: test model data mismatch on direct load."); Assert.AreEqual(expected.TestBaseClassInstance.Key, actual.TestBaseClassInstance.Key, "Load failed: base class key mismatch."); Assert.AreEqual(expected.TestBaseClassInstance.BaseProperty, actual.TestBaseClassInstance.BaseProperty, "Load failed: base class data mismatch."); Assert.AreEqual(expected.TestBaseClassInstance.GetType(), actual.TestBaseClassInstance.GetType(), "Load failed: base class type mismatch."); }
public void TestSaveForeignNull() { var expected = TestAggregateModel.MakeAggregateModel(); expected.TestForeignInstance = null; _databaseInstance.SaveAsync(expected).Wait(); var actual = _databaseInstance.LoadAsync <TestAggregateModel>(expected.Key).Result; var actualTestModel = _databaseInstance.LoadAsync <TestModel>(expected.TestModelInstance.Key).Result; Assert.AreEqual(expected.Key, actual.Key, "Load with foreign key failed: key mismatch."); Assert.IsNull(actual.TestForeignInstance, "Load failed: foreign key not set to null."); Assert.AreEqual(expected.TestModelInstance.Key, actual.TestModelInstance.Key, "Load failed: test model key mismatch."); Assert.AreEqual(expected.TestModelInstance.Data, actual.TestModelInstance.Data, "Load failed: test model data mismatch."); Assert.AreEqual(expected.TestModelInstance.Key, actualTestModel.Key, "Load failed: test model key mismatch on direct load."); Assert.AreEqual(expected.TestModelInstance.Data, actualTestModel.Data, "Load failed: test model data mismatch on direct load."); }