public static void FKAttributeTest() { var bar = new KeyKey { Id = "hello!".ToKey <KeyKey>(), E = float.MinValue, }; var foo = new StringKey { Id = "Hello world!", E = float.Epsilon, }; var x = new Fk { Id = "Hello world!".ToKey <KeyKey>(), FooId = foo.Id, Foo = foo, BarId = bar.Id, Bar = bar, }; var e = Entity <Fk> .To(new Entity(), x); Assert.Null(e["Foo"]); Assert.Null(e["Bar"]); Assert.NotNull(e["FooId"]); Assert.NotNull(e["BarId"]); var rt = Entity <Fk> .From(new Fk(), e); Assert.Equal(x.Id, rt.Id); Assert.Equal(x.BarId, rt.BarId); Assert.Null(rt.Bar); Assert.Equal(x.FooId, rt.FooId); Assert.Null(rt.Foo); }
public static void KeyKeyTest() { var x = new KeyKey { Id = "Hello world!".ToKey <KeyKey>(), E = float.Epsilon, Foo = new Entity { ["Bar"] = "hello world!", }, }; var e = Entity <KeyKey> .To(new Entity(), x); var rt = Entity <KeyKey> .From(new KeyKey(), e); Assert.Equal(x.Id, rt.Id); Assert.Equal(x.E, rt.E); Assert.Equal(x.Foo, rt.Foo); Assert.True(ReferenceEquals(x.Foo, rt.Foo)); }