Пример #1
0
        private void SetupShims(bool canRead)
        {
            var fields = new SPFieldLookup[1];

            fields[0] = new ShimSPFieldLookup()
            {
                LookupListGet = () => Guid.Empty.ToString()
            };

            ShimSPField.AllInstances.TypeGet = _ => SPFieldType.Lookup;
            ShimSPBaseCollection.AllInstances.GetEnumerator = _ => fields.GetEnumerator();
            ShimCoreFunctions.getConfigSettingSPWebString   = (_, __) => DummyString;
            ShimCoreFunctions.getConnectionStringGuid       = _ => string.Empty;
            ShimSPFieldLookupValue.AllInstances.LookupIdGet = _ => 0;
            ShimSPFieldLookupValue.ConstructorString        = (_, __) => new ShimSPFieldLookupValue();
            ShimSPSecurity.RunWithElevatedPrivilegesSPSecurityCodeToRunElevated = codeToRun => codeToRun();

            ShimSqlConnection.AllInstances.Open = _ =>
            {
                _isConnectionOpenedCalled = true;
            };
            ShimSqlCommand.AllInstances.ExecuteNonQuery = _ =>
            {
                _isExecuteNonQueryCallCount++;
                return(0);
            };
            ShimSqlCommand.AllInstances.ExecuteReader = _ =>
            {
                _isExecuteNonQueryCallCount++;
                return(new ShimSqlDataReader());
            };
            ShimSqlConnection.AllInstances.DisposeBoolean = (_, __) =>
            {
                _isConnectionDisposeCalled = true;
            };
            ShimSqlCommand.AllInstances.DisposeBoolean = (_, __) =>
            {
                _sqlCommandDisposeCallCount++;
            };
            ShimSqlDataReader.AllInstances.Read = _ => canRead;
        }