示例#1
0
        public void UpdateData_NoConditions_ProperFunctionsCalled()
        {
            var sqlConnectionMock        = new Mock <ISqlConnectionWrapper>();
            var updateCommandFactoryMock = new Mock <ICommandFactory>();
            var updateCommandMock        = new Mock <IDbCommand>();

            var entity = new Entity()
            {
                Type  = EntityType.Type0,
                Value = 11
            };

            updateCommandFactoryMock.Setup(x => x.RetriveUpdateEntityCommand(It.IsAny <SqlConnection>(), It.IsAny <Entity>(), It.IsAny <int>()))
            .Returns(updateCommandMock.Object);

            var dataHandler = new SqlDataHandler(updateCommandFactoryMock.Object, sqlConnectionMock.Object);

            dataHandler.UpdateDataFieldInEntity(entity);

            updateCommandMock.Verify(x => x.ExecuteNonQuery());
        }