UpdateCommand() public method

Create an update query from the entity.
/// command /// or /// entity /// /// At least one property (other than primary keys) must be specified. /// or ///
public UpdateCommand ( IDbCommand command, object entity ) : void
command IDbCommand Command to modify
entity object Entity to update
return void
        public void field_without_value_is_added_with_DbNull_in_the_update_query()
        {
            var mapper = Substitute.For<ICrudEntityMapper>();
            mapper.TableName.Returns("Users");
            mapper.Properties.Returns(new Dictionary<string, IPropertyMapping>
            {
                {"Name", new FakePropertyMapping("Name", "real_name") {CanRead = true} },
                {"Id", new FakePropertyMapping("Id", "id"){Value = "Hello", IsPrimaryKey = true}}
            });
            var command = new AdoNetFakes.FakeCommand();
            var entity = new { Id = "Hello" };


            var sut = new CommandBuilder(mapper);
            sut.UpdateCommand(command, entity);

            command.CommandText.Should().Be("UPDATE Users SET real_name=@Name WHERE id=@Id");
            command.Parameters[0].ParameterName.Should().Be("Name");
            command.Parameters[0].Value.Should().Be(DBNull.Value);
            command.Parameters[1].ParameterName.Should().Be("Id");
            command.Parameters[1].Value.Should().Be("Hello");
        }
        public void key_must_a_value_in_the_update_Query()
        {
            var mapper = Substitute.For<ICrudEntityMapper>();
            mapper.TableName.Returns("Users");
            mapper.Properties.Returns(new Dictionary<string, IPropertyMapping>
            {
                {"Name", new FakePropertyMapping("Name", "real_name"){Value = "Hello" }},
                {"Id", new FakePropertyMapping("Id", "id"){IsPrimaryKey = true}}
            });
            var command = new AdoNetFakes.FakeCommand();
            var entity = new { Id = "Hello" };


            var sut = new CommandBuilder(mapper);
            Action actual = () => sut.UpdateCommand(command, entity);

            actual.ShouldThrow<DataException>();
        }
        public void key_may_not_be_the_only_field_in_an_update_query()
        {
            var mapper = Substitute.For<IEntityMapper>();
            mapper.TableName.Returns("Users");
            mapper.Properties.Returns(new Dictionary<string, IPropertyMapping>
            {
                {"Id", new FakePropertyMapping("Id", "id"){Value = "Hello", IsPrimaryKey = true}}
            });
            var command = new AdoNetFakes.FakeCommand();
            var entity = new { Id = "Hello" };


            var sut = new CommandBuilder(mapper);
            Action actual = () => sut.UpdateCommand(command, entity);

            actual.ShouldThrow<DataException>();
        }