public void EqualityGetsOverridden() { var bar = new Bar { Id = 1 }; var bar2 = new Bar { Id = 2 }; var anotherBar1 = new Bar { Id = 1 }; Bar nullBar1 = null; Bar nullBar2 = null; Assert.True(nullBar1 == nullBar2); Assert.False(nullBar1 != nullBar2); Assert.False(bar == nullBar1); Assert.True(bar != nullBar1); Assert.False(nullBar2 == bar); Assert.True(nullBar2 != bar); Assert.True(bar == anotherBar1); Assert.False(bar != anotherBar1); Assert.False(bar == bar2); Assert.True(bar != bar2); Assert.True(bar == bar); Assert.False(bar != bar); }
public void EntityIsSetLogger() { var bar = new Bar(); Assert.IsAssignableFrom<ISetLogger>(bar); }
public void SetPkNotSet() { var bar = new Bar(); bar.Id = 1; Assert.Empty(((ISetLogger)bar).GetSetProperties()); }
public void SetPropertiesMakesSet() { var bar = new Bar(); bar.Name = "Foo"; Assert.Equal(new[] { "Name" }, ((ISetLogger)bar).GetSetProperties()); }
public void NewEntityHasNoSetProperties() { var bar = new Bar(); Assert.Empty(((ISetLogger)bar).GetSetProperties()); }
public void AlreadyInstantiatedCollectionDoesNotGetInstantiatedInConstructor() { var bar = new Bar(); Assert.NotEmpty(bar.Ducks); }
public void NoIdReturnsBaseHashCode() { var bar = new Bar(); Assert.Equal(RuntimeHelpers.GetHashCode(bar), bar.GetHashCode()); }
public void ChangeFooChanges() { var bar = new Bar(); typeof(Bar).GetField("FooId").SetValue(bar, 3); bar.Foo = new Foo { FooId = 4 }; Assert.Equal(4, bar.Foo.FooId); }
public void SameInstanceIsEqual() { var bar = new Bar { Id = 3 }; Assert.True(bar.Equals(bar)); }
public void SamePrimaryKeyEqual() { var bar = new Bar { Id = 2 }; var otherBar = new Bar { Id = 2 }; Assert.True(bar.Equals(otherBar)); Assert.True(otherBar.Equals(bar)); }
public void NonSamePrimaryKeyNotEqual() { var bar = new Bar { Id = 1 }; var otherBar = new Bar { Id = 2 }; Assert.False(bar.Equals(otherBar)); Assert.False(otherBar.Equals(bar)); }
public void EqualsNonBarIsFalse() { var bar = new Bar(); Assert.False(bar.Equals(new Foo())); }
public void EqualsNullIsFalse() { var bar = new Bar(); Assert.False(bar.Equals(null)); }
public void SettingIdReturnsPrevIfGetHashCodeAlreadyCalled() { var bar = new Bar(); var hash = bar.GetHashCode(); bar.Id = 3; Assert.Equal(hash, bar.GetHashCode()); }
public void NullReturnsNull() { var bar = new Bar(); Assert.Null(bar.Foo); }
public void ReturnFooWithId() { var bar = new Bar(); typeof(Bar).GetField("FooId").SetValue(bar, 3); Assert.Equal(3, bar.Foo.FooId); }
public void SetToNullOnNonFetchedButNotNullProperty() { var barCheck = new Bar(); barCheck.GetType().GetField("FooId").SetValue(barCheck, 1); Assert.Equal(1, barCheck.Foo.FooId); var bar = new Bar(); var barAsTracked = (ITrackedEntity)bar; bar.GetType().GetField("FooId").SetValue(bar, 2); barAsTracked.EnableTracking(); bar.Foo = null; Assert.Equal(1, barAsTracked.GetDirtyProperties().Count()); Assert.True(barAsTracked.GetDirtyProperties().First() == "Foo"); Assert.Equal(2, ((Foo)barAsTracked.GetOldValue("Foo")).FooId); }
public void ChangeToNullResets() { var bar = new Bar(); typeof(Bar).GetField("FooId").SetValue(bar, 3); bar.Foo = null; Assert.Null(bar.Foo); }
public void GetHashCodeReturnsIdFactor() { var bar = new Bar { Id = 3 }; Assert.Equal(17 * 3, bar.GetHashCode()); }