Exemplo n.º 1
0
        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"));
        }
Exemplo n.º 2
0
        public void ShouldThrowOnNullInputToGetRevision()
        {
            var entityConfig = new EntityConfig(typeof(Entity));

            Assert.Throws<ArgumentNullException>(() => entityConfig.GetRevision(null));
        }
Exemplo n.º 3
0
        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);
        }