public void ShouldThrowOnIncorrectEntityTypeOnSetterAndGetterMethods() { var entityConfig = new EntityConfig(typeof(Entity)); Assert.Throws<ArgumentException>(() => entityConfig.GetRevision(new EntityWithoutRevision())); Assert.Throws<ArgumentException>(() => entityConfig.GetId(new EntityWithoutRevision())); Assert.Throws<ArgumentException>(() => entityConfig.SetRevision(new EntityWithoutRevision(), "rev1")); Assert.Throws<ArgumentException>(() => entityConfig.SetId(new EntityWithoutRevision(), "entity1")); }
public void ShouldThrowOnNullInputToGetRevision() { var entityConfig = new EntityConfig(typeof(Entity)); Assert.Throws<ArgumentNullException>(() => entityConfig.GetRevision(null)); }
public void ShouldDelegateGetEntityRevision() { object gettingEntity = null; var revisionMemberMock = new Mock<ISpecialMember>(); revisionMemberMock .Setup(m => m.GetValue(It.IsAny<object>())) .Returns<object>(e => { gettingEntity = e; return "rev1"; }); var entityConfig = new EntityConfig(typeof(Entity), revisionMember: revisionMemberMock.Object); object entity = Entity.CreateStandard(); var revision = entityConfig.GetRevision(entity); Assert.Equal("rev1", revision); Assert.Equal(entity, gettingEntity); }