public void ShouldThrowOnNullInputToGetId() { var entityConfig = new EntityConfig(typeof(Entity)); Assert.Throws<ArgumentNullException>(() => entityConfig.GetId(null)); }
public void ShouldDelegateGetEntityId() { object gettingEntity = null; var idMemberMock = new Mock<ISpecialMember>(); idMemberMock .Setup(m => m.GetValue(It.IsAny<object>())) .Returns<object>(e => { gettingEntity = e; return "doc1"; }); var entityConfig = new EntityConfig(typeof(Entity), idMember: idMemberMock.Object); object entity = Entity.CreateStandard(); string id = entityConfig.GetId(entity); Assert.Equal("doc1", id); Assert.Equal(entity, gettingEntity); }
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")); }