コード例 #1
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"));
        }
コード例 #2
0
ファイル: EntityConfigTests.cs プロジェクト: artikh/CouchDude
        public void ShouldThrowOnNullInputToSetId()
        {
            var entityConfig = new EntityConfig(typeof(Entity));

            Assert.Throws<ArgumentNullException>(() => entityConfig.SetId(null, "entity1"));
            Assert.Throws<ArgumentNullException>(() => entityConfig.SetId(Entity.CreateStandard(), null));
            Assert.Throws<ArgumentNullException>(() => entityConfig.SetId(Entity.CreateStandard(), string.Empty));
        }
コード例 #3
0
ファイル: EntityConfigTests.cs プロジェクト: artikh/CouchDude
        public void ShouldDelegateSetEnityId()
        {
            string setId = null;
            object settingEntity = null;

            var idMemberMock = new Mock<ISpecialMember>();
            idMemberMock
                .Setup(m => m.SetValue(It.IsAny<object>(), It.IsAny<string>()))
                .Callback<object, string>((e, id) => { setId = id; settingEntity = e; });

            var entityConfig = new EntityConfig(typeof(Entity), idMember: idMemberMock.Object);

            object entity = Entity.CreateStandard();
            entityConfig.SetId(entity, "doc1");

            Assert.Equal("doc1", setId);
            Assert.Equal(entity, settingEntity);
        }