public void DatabaseQueryRelationTest() { var config1Row1 = NSubstitute.Substitute.For <IColumnProvidable>();; config1Row1.GetColumns().Returns(DataProvider._ReturnColumn1); var config1 = NSubstitute.Substitute.For <IRowProvidable>(); config1.GetRows().Returns(new IColumnProvidable[] { config1Row1 }); config1.GetTableType().Returns(typeof(TestConfig1)); var config1Row3 = NSubstitute.Substitute.For <IColumnProvidable>();; config1Row3.GetColumns().Returns(DataProvider._ReturnColumn3); var config3 = NSubstitute.Substitute.For <IRowProvidable>(); config3.GetRows().Returns(new IColumnProvidable[] { config1Row3 }); config3.GetTableType().Returns(typeof(TestConfig3)); var db = new Regulus.RelationalTables.Database(new IRowProvidable[] { config3, config1 }); var config = db.Query <TestConfig3>().First(); Assert.AreEqual(1, config.Field1.Field1); Assert.AreEqual("2", config.Field1.Field2); Assert.AreEqual(3f, config.Field1.Field3); }
public void Test() { var table1Row1 = NSubstitute.Substitute.For <Raw.IColumnProvidable>();; table1Row1.GetColumns().Returns(_Table1Row1); var table1 = NSubstitute.Substitute.For <Raw.IRowProvidable>(); table1.GetRows().Returns(new Raw.IColumnProvidable[] { table1Row1 }); table1.GetTableType().Returns(typeof(Table1)); var table2Row1 = NSubstitute.Substitute.For <Raw.IColumnProvidable>();; table2Row1.GetColumns().Returns(_Table2Row1); var table2Row2 = NSubstitute.Substitute.For <Raw.IColumnProvidable>();; table2Row2.GetColumns().Returns(_Table2Row2); var table2 = NSubstitute.Substitute.For <Raw.IRowProvidable>(); table2.GetRows().Returns(new Raw.IColumnProvidable[] { table2Row1, table2Row2 }); table2.GetTableType().Returns(typeof(Table2)); var db = new Regulus.RelationalTables.Database(new Raw.IRowProvidable[] { table1, table2 }); var table1Config = db.Query <Table1>().First(); NUnit.Framework.Assert.AreEqual(1, table1Config.Table2s[0].Data); NUnit.Framework.Assert.AreEqual(2, table1Config.Table2s[1].Data); }