コード例 #1
0
ファイル: EntityConfigTests.cs プロジェクト: artikh/CouchDude
        public void ShouldThrowOnNullInputToGetId()
        {
            var entityConfig = new EntityConfig(typeof(Entity));

            Assert.Throws<ArgumentNullException>(() => entityConfig.GetId(null));
        }
コード例 #2
0
ファイル: EntityConfigTests.cs プロジェクト: artikh/CouchDude
        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);
        }
コード例 #3
0
ファイル: EntityConfigTests.cs プロジェクト: artikh/CouchDude
        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"));
        }