本文整理汇总了C#中IExpectation类的典型用法代码示例。如果您正苦于以下问题:C# IExpectation类的具体用法?C# IExpectation怎么用?C# IExpectation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IExpectation类属于命名空间,在下文中一共展示了IExpectation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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");
}
示例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);
}
}
示例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();
}
示例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);
}
}
示例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);
}
示例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
}
示例7: SetupExpectation
protected static void SetupExpectation(IExpectation expectation, Range r, int actual)
{
expectation.Expected = r;
for (int i = 0; i < actual; i++)
{
expectation.AddActualCall();
}
}
示例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;
}
示例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));
}
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}