本文整理汇总了C#中IExpectation类的典型用法代码示例。如果您正苦于以下问题:C# IExpectation类的具体用法?C# IExpectation怎么用?C# IExpectation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IExpectation类属于命名空间,在下文中一共展示了IExpectation类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ApplyExpectation
public void ApplyExpectation(IExpectation expectation)
{
if (expectation is HasTypeExpectation)
{
HandleHasTypeExpectation(expectation as HasTypeExpectation);
return;
}
if (expectation is HasInstanceExpectation)
{
HandleHasInstanceExpectation(expectation as HasInstanceExpectation);
return;
}
if (expectation is DoesNotHaveTypeExpectation)
{
HandleDoesNotHaveTypeExpectation(expectation as DoesNotHaveTypeExpectation);
return;
}
if (expectation is DoesNotHaveInstanceExpectation)
{
HandleDoesNotHaveInstanceExpectation(expectation as DoesNotHaveInstanceExpectation);
return;
}
// TODO: Open/Closed priciple!?
// TODO: Refactor to Expectation applyer!? Use extension methods?
throw new ArgumentOutOfRangeException("expectation");
}
开发者ID:cguedes,项目名称:FluentSecurity,代码行数:31,代码来源:ExpectationGroup.cs
示例2: AddToBatch
public override void AddToBatch(IExpectation expectation)
{
totalExpectedRowsAffected += expectation.ExpectedRowCount;
var batchUpdate = CurrentCommand;
string lineWithParameters = null;
var sqlStatementLogger = Factory.Settings.SqlStatementLogger;
if (sqlStatementLogger.IsDebugEnabled || log.IsDebugEnabled)
{
lineWithParameters = sqlStatementLogger.GetCommandLineWithParameters(batchUpdate);
var formatStyle = sqlStatementLogger.DetermineActualStyle(FormatStyle.Basic);
lineWithParameters = formatStyle.Formatter.Format(lineWithParameters);
currentBatchCommandsLog.Append("command ")
.Append(currentBatch.CountOfCommands)
.Append(":")
.AppendLine(lineWithParameters);
}
if (log.IsDebugEnabled)
{
log.Debug("Adding to batch:" + lineWithParameters);
}
currentBatch.Append(((ProfiledSqlDbCommand)batchUpdate).Command);
if (currentBatch.CountOfCommands >= batchSize)
{
ExecuteBatchWithTiming(batchUpdate);
}
}
开发者ID:nategreenwood,项目名称:nategreenwood.com,代码行数:28,代码来源:ProfiledSqlClientBatchingBatcher.cs
示例3: ConstraintsExpectation
/// <summary>
/// Creates a new <see cref="ConstraintsExpectation"/> instance.
/// </summary>
/// <param name="expectation">Expectation.</param>
/// <param name="constraints">Constraints.</param>
public ConstraintsExpectation(IExpectation expectation, AbstractConstraint[] constraints)
: base(expectation)
{
Validate.IsNotNull(() => constraints);
this.constraints = constraints;
ConstraintsMatchMethod();
}
开发者ID:sneal,项目名称:rhino-mocks,代码行数:12,代码来源:ConstraintsExpectation.cs
示例4: AddToBatch
public override void AddToBatch(IExpectation expectation)
{
_totalExpectedRowsAffected += expectation.ExpectedRowCount;
var batchUpdate = CurrentCommand;
Driver.AdjustCommand(batchUpdate);
var sqlStatementLogger = Factory.Settings.SqlStatementLogger;
if (sqlStatementLogger.IsDebugEnabled)
{
var lineWithParameters = sqlStatementLogger.GetCommandLineWithParameters(batchUpdate);
var formatStyle = sqlStatementLogger.DetermineActualStyle(FormatStyle.Basic);
lineWithParameters = formatStyle.Formatter.Format(lineWithParameters);
_currentBatchCommandsLog.Append("command ")
.Append(_currentBatch.CountOfCommands)
.Append(":")
.AppendLine(lineWithParameters);
}
var update = batchUpdate as ProfiledGenericDbCommand<SqlCommand>;
if (update != null)
{
_currentBatch.Append(update.Command);
}
else
{
_currentBatch.Append((SqlCommand)batchUpdate);
}
if (_currentBatch.CountOfCommands >= _batchSize)
{
ExecuteBatchWithTiming(batchUpdate);
}
}
开发者ID:juanema,项目名称:MiniProfiler.NHibernate,代码行数:32,代码来源:ProfiledSqlClientBatchingBatcher.cs
示例5: AddToBatch
/// <summary>
/// Executes the current <see cref="IDbCommand"/> and compares the row Count
/// to the <c>expectedRowCount</c>.
/// </summary>
/// <param name="expectation">
/// The expected number of rows affected by the query. A value of less than <c>0</c>
/// indicates that the number of rows to expect is unknown or should not be a factor.
/// </param>
/// <exception cref="HibernateException">
/// Thrown when there is an expected number of rows to be affected and the
/// actual number of rows is different.
/// </exception>
public override void AddToBatch(IExpectation expectation)
{
IDbCommand cmd = CurrentCommand;
Driver.AdjustCommand(cmd);
int rowCount = ExecuteNonQuery(cmd);
expectation.VerifyOutcomeNonBatched(rowCount, cmd);
}
开发者ID:hoangduc007,项目名称:nhibernate-core,代码行数:19,代码来源:NonBatchingBatcher.cs
示例6: AddToBatch
public override void AddToBatch(IExpectation expectation)
{
#region NHibernate code
_totalExpectedRowsAffected += expectation.ExpectedRowCount;
IDbCommand batchUpdate = CurrentCommand;
Driver.AdjustCommand(batchUpdate);
string lineWithParameters = null;
var sqlStatementLogger = Factory.Settings.SqlStatementLogger;
if (sqlStatementLogger.IsDebugEnabled || Log.IsDebugEnabled)
{
lineWithParameters = sqlStatementLogger.GetCommandLineWithParameters(batchUpdate);
var formatStyle = sqlStatementLogger.DetermineActualStyle(FormatStyle.Basic);
lineWithParameters = formatStyle.Formatter.Format(lineWithParameters);
_currentBatchCommandsLog.Append("command ")
.Append(_currentBatch.CountOfCommands)
.Append(":")
.AppendLine(lineWithParameters);
}
if (Log.IsDebugEnabled)
{
Log.Debug("Adding to batch:" + lineWithParameters);
}
#endregion
_currentBatch.Append((System.Data.SqlClient.SqlCommand)(ReliableSqlCommand)batchUpdate);
#region NHibernate code
if (_currentBatch.CountOfCommands >= _batchSize)
{
ExecuteBatchWithTiming(batchUpdate);
}
#endregion
}
开发者ID:BishoyDemian,项目名称:NHibernate.SqlAzure,代码行数:31,代码来源:ReliableSqlClientBatchingBatcher.cs
示例7: SetupExpectation
protected static void SetupExpectation(IExpectation expectation, Range r, int actual)
{
expectation.Expected = r;
for (int i = 0; i < actual; i++)
{
expectation.AddActualCall();
}
}
开发者ID:ChuangYang,项目名称:RhinoMocks,代码行数:8,代码来源:AbstractExpectationTests.cs
示例8: ProxyMethodExpectationTriplet
/// <summary>
/// Creates a new <see cref="ProxyMethodExpectationTriplet"/> instance.
/// </summary>
/// <param name="proxy">Proxy.</param>
/// <param name="method">Method.</param>
/// <param name="expectation">Expectation.</param>
public ProxyMethodExpectationTriplet(object proxy, MethodInfo method, IExpectation expectation)
{
Validate.IsNotNull(proxy, "proxy");
Validate.IsNotNull(method, "method");
Validate.IsNotNull(expectation, "expectation");
this.proxy = proxy;
this.method = method;
this.expectation = expectation;
}
开发者ID:brumschlag,项目名称:rhino-tools,代码行数:15,代码来源:ProxyMethodExpectationTriplet.cs
示例9: LogRecordedExpectation
/// <summary>
/// Logs the expectation as is was recorded
/// </summary>
/// <param name="invocation">
/// The invocation.
/// </param>
/// <param name="expectation">
/// The expectation.
/// </param>
public void LogRecordedExpectation(IInvocation invocation, IExpectation expectation)
{
if (_logRecorded)
{
string methodCall =
MethodCallUtil.StringPresentation(invocation, invocation.Method, invocation.Arguments);
Trace.WriteLine(string.Format("Recorded expectation: {0}", methodCall));
}
}
开发者ID:bjornbouetsmith,项目名称:mammock,代码行数:18,代码来源:TraceWriterExpectationLogger.cs
示例10: AddToBatch
public override void AddToBatch(IExpectation expectation)
{
totalExpectedRowsAffected += expectation.ExpectedRowCount;
log.Debug("Adding to batch:");
IDbCommand batchUpdate = CurrentCommand;
LogCommand(batchUpdate);
CurrentBatch.Append(batchUpdate);
if (CurrentBatch.CountOfCommands >= batchSize)
{
DoExecuteBatch(batchUpdate);
}
}
开发者ID:Novthirteen,项目名称:sconit_timesseiko,代码行数:13,代码来源:CommandSetBatchingBatcher.cs
示例11: CreateTestResultFromExpectation
TestResult CreateTestResultFromExpectation(IExpectation expectation)
{
var result = new TestResult(new TestName { Name = expectation.Message });
if (expectation.IsFail)
result.Failure(expectation.ToString(), "");
else if (expectation.IsPass)
result.Success();
else if (expectation.IsPending)
result.Ignore(expectation.ToString(), "");
return result;
}
开发者ID:nspec,项目名称:NSpec,代码行数:13,代码来源:TestResultExampleReporter.cs
示例12: AddToBatch
public override void AddToBatch(IExpectation expectation)
{
bool firstOnBatch = true;
totalExpectedRowsAffected += expectation.ExpectedRowCount;
log.Info("Adding to batch");
LogCommand(CurrentCommand);
if (currentBatch == null)
{
// use first command as the batching command
currentBatch = CurrentCommand;
parameterValueArrayHashTable = new Hashtable();
//oracle does not allow array containing all null values
// so this HashTable is keeping track if all values are null or not
parameterIsAllNullsHashTable = new Hashtable();
}
else
{
firstOnBatch = false;
}
ArrayList parameterValueArray;
foreach (IDataParameter currentParameter in CurrentCommand.Parameters)
{
if (firstOnBatch)
{
parameterValueArray = new ArrayList();
parameterValueArrayHashTable.Add(currentParameter.ParameterName, parameterValueArray);
parameterIsAllNullsHashTable.Add(currentParameter.ParameterName, true);
}
else
{
parameterValueArray = parameterValueArrayHashTable[currentParameter.ParameterName] as ArrayList;
}
if (currentParameter.Value != System.DBNull.Value)
{
parameterIsAllNullsHashTable[currentParameter.ParameterName] = false;
}
parameterValueArray.Add(currentParameter.Value);
}
countOfCommands++;
if (countOfCommands >= batchSize)
{
DoExecuteBatch(currentBatch);
}
}
开发者ID:Novthirteen,项目名称:sconit_timesseiko,代码行数:51,代码来源:OracleDataClientBatchingBatcher.cs
示例13: AddToBatch
public override void AddToBatch(IExpectation expectation)
{
totalExpectedRowsAffected += expectation.ExpectedRowCount;
log.Debug("Adding to batch:");
IDbCommand batchUpdate = CurrentCommand;
string commandLoggedText = GetCommandLogString(batchUpdate);
currentBatchCommandsLog.Append("Batch command: ").
AppendLine(commandLoggedText);
currentBatch.Append((System.Data.SqlClient.SqlCommand) batchUpdate);
if (currentBatch.CountOfCommands >= batchSize)
{
DoExecuteBatch(batchUpdate);
}
}
开发者ID:pallmall,项目名称:WCell,代码行数:14,代码来源:SqlClientBatchingBatcher.cs
示例14: AddToBatch
public override void AddToBatch(IExpectation expectation)
{
bool firstOnBatch = true;
totalExpectedRowsAffected += expectation.ExpectedRowCount;
log.Info("Adding to batch");
LogCommand(CurrentCommand);
if (currentBatch == null)
{
// use first command as the batching command
currentBatch = CurrentCommand;
parameterValueListHashTable = new Dictionary<string, List<object>>();
//oracle does not allow array containing all null values
// so this Dictionary is keeping track if all values are null or not
parameterIsAllNullsHashTable = new Dictionary<string, bool>();
}
else
{
firstOnBatch = false;
}
List<object> parameterValueList;
foreach (IDataParameter currentParameter in CurrentCommand.Parameters)
{
if (firstOnBatch)
{
parameterValueList = new List<object>();
parameterValueListHashTable.Add(currentParameter.ParameterName, parameterValueList);
parameterIsAllNullsHashTable.Add(currentParameter.ParameterName, true);
}
else
{
parameterValueList = parameterValueListHashTable[currentParameter.ParameterName];
}
if (currentParameter.Value != DBNull.Value)
{
parameterIsAllNullsHashTable[currentParameter.ParameterName] = false;
}
parameterValueList.Add(currentParameter.Value);
}
countOfCommands++;
if (countOfCommands >= batchSize)
{
ExecuteBatchWithTiming(currentBatch);
}
}
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:49,代码来源:OracleDataClientBatchingBatcher.cs
示例15: AddToBatch
public override void AddToBatch(IExpectation expectation)
{
this.totalExpectedRowsAffected += expectation.ExpectedRowCount;
IDbCommand batchUpdate = CurrentCommand;
Driver.AdjustCommand(batchUpdate);
string lineWithParameters = null;
var sqlStatementLogger = Factory.Settings.SqlStatementLogger;
if (sqlStatementLogger.IsDebugEnabled || Log.IsDebugEnabled)
{
lineWithParameters = sqlStatementLogger.GetCommandLineWithParameters(batchUpdate);
var formatStyle = sqlStatementLogger.DetermineActualStyle(FormatStyle.Basic);
lineWithParameters = formatStyle.Formatter.Format(lineWithParameters);
this.currentBatchCommandsLog.Append("command ")
.Append(this.currentBatch.CountOfCommands)
.Append(":")
.AppendLine(lineWithParameters);
}
if (Log.IsDebugEnabled)
{
Log.Debug("Adding to batch:" + lineWithParameters);
}
if (batchUpdate is ProfiledSqlCommand)
{
var sqlCommand = ((ProfiledSqlCommand)batchUpdate).SqlCommand;
this.currentBatch.Append(sqlCommand);
if (this.profiler != null)
{
this.profiler.ExecuteStart(sqlCommand, ExecuteType.NonQuery);
}
}
else
{
this.currentBatch.Append((System.Data.SqlClient.SqlCommand)batchUpdate);
}
if (this.currentBatch.CountOfCommands >= this.batchSize)
{
this.ExecuteBatchWithTiming(batchUpdate);
}
}
开发者ID:bigfont,项目名称:CertifiedOverheadCrane,代码行数:41,代码来源:ProfiledSqlClientBatchingBatcher.cs
示例16: AddToBatch
public override void AddToBatch(IExpectation expectation)
{
bool firstOnBatch = true;
totalExpectedRowsAffected += expectation.ExpectedRowCount;
string lineWithParameters = null;
var sqlStatementLogger = Factory.Settings.SqlStatementLogger;
if (sqlStatementLogger.IsDebugEnabled || log.IsDebugEnabled)
{
lineWithParameters = sqlStatementLogger.GetCommandLineWithParameters(CurrentCommand);
var formatStyle = sqlStatementLogger.DetermineActualStyle(FormatStyle.Basic);
lineWithParameters = formatStyle.Formatter.Format(lineWithParameters);
currentBatchCommandsLog.Append("command ")
.Append(countOfCommands)
.Append(":")
.AppendLine(lineWithParameters);
}
if (log.IsDebugEnabled)
{
log.Debug("Adding to batch:" + lineWithParameters);
}
if (currentBatch == null)
{
// use first command as the batching command
currentBatch = CurrentCommand;
parameterValueListHashTable = new Dictionary<string, List<object>>();
//oracle does not allow array containing all null values
// so this Dictionary is keeping track if all values are null or not
parameterIsAllNullsHashTable = new Dictionary<string, bool>();
}
else
{
firstOnBatch = false;
}
List<object> parameterValueList;
foreach (IDataParameter currentParameter in CurrentCommand.Parameters)
{
if (firstOnBatch)
{
parameterValueList = new List<object>();
parameterValueListHashTable.Add(currentParameter.ParameterName, parameterValueList);
parameterIsAllNullsHashTable.Add(currentParameter.ParameterName, true);
}
else
{
parameterValueList = parameterValueListHashTable[currentParameter.ParameterName];
}
if (currentParameter.Value != DBNull.Value)
{
parameterIsAllNullsHashTable[currentParameter.ParameterName] = false;
}
parameterValueList.Add(currentParameter.Value);
}
countOfCommands++;
if (countOfCommands >= batchSize)
{
ExecuteBatchWithTiming(currentBatch);
}
}
开发者ID:pruiz,项目名称:nhibernate-old,代码行数:63,代码来源:OracleDataClientBatchingBatcher.cs
示例17: AddToBatch
/// <summary>
/// Adds the expected row count into the batch.
/// </summary>
/// <param name="expectation">The number of rows expected to be affected by the query.</param>
/// <remarks>
/// If Batching is not supported, then this is when the Command should be executed. If Batching
/// is supported then it should hold of on executing the batch until explicitly told to.
/// </remarks>
public abstract void AddToBatch(IExpectation expectation);
开发者ID:pallmall,项目名称:WCell,代码行数:9,代码来源:AbstractBatcher.cs
示例18: DoReplaceExpectation
protected override void DoReplaceExpectation(object proxy, MethodInfo method, IExpectation oldExpectation, IExpectation newExpectation)
{
DoReplaceExpectationCalled = true;
}
开发者ID:bcraytor,项目名称:rhino-mocks,代码行数:4,代码来源:MethodRecorderBaseTests.cs
示例19: PerformInsert
protected object PerformInsert(object ownerId, IPersistentCollection collection, IExpectation expectation,
object entry, int index, bool useBatch, bool callable, ISessionImplementor session)
{
object entryId = null;
int offset = 0;
IDbCommand st = useBatch
? session.Batcher.PrepareBatchCommand(SqlInsertRowString.CommandType, SqlInsertRowString.Text,
SqlInsertRowString.ParameterTypes)
: session.Batcher.PrepareCommand(SqlInsertRowString.CommandType, SqlInsertRowString.Text,
SqlInsertRowString.ParameterTypes);
try
{
//offset += expectation.Prepare(st, factory.ConnectionProvider.Driver);
offset = WriteKey(st, ownerId, offset, session);
if (hasIdentifier)
{
entryId = collection.GetIdentifier(entry, index);
offset = WriteIdentifier(st, entryId, offset, session);
}
if (hasIndex)
{
offset = WriteIndex(st, collection.GetIndex(entry, index, this), offset, session);
}
WriteElement(st, collection.GetElement(entry), offset, session);
if (useBatch)
{
session.Batcher.AddToBatch(expectation);
}
else
{
expectation.VerifyOutcomeNonBatched(session.Batcher.ExecuteNonQuery(st), st);
}
}
catch (Exception e)
{
if (useBatch)
{
session.Batcher.AbortBatch(e);
}
throw;
}
finally
{
if (!useBatch)
{
session.Batcher.CloseCommand(st, null);
}
}
return entryId;
}
开发者ID:khaliyo,项目名称:Spring.net-NHibernate.net-Asp.net-MVC-DWZ-,代码行数:50,代码来源:AbstractCollectionPersister.cs
示例20: LogReplayedExpectation
/// <summary>
/// Logs the expectation as it was recorded
/// </summary>
/// <param name="invocation">
/// The invocation.
/// </param>
/// <param name="expectation">
/// The expectation.
/// </param>
public void LogReplayedExpectation(IInvocation invocation, IExpectation expectation)
{
string methodCall = MethodCallUtil.StringPresentation(invocation, invocation.Method, invocation.Arguments);
WriteLine("Replayed expectation: {0}", methodCall);
WriteCurrentMethod();
}
开发者ID:bjornbouetsmith,项目名称:mammock,代码行数:15,代码来源:TraceWriterWithStackTraceExpectationWriter.cs
注:本文中的IExpectation类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论