本文整理汇总了C#中MockFactory.VerifyAllExpectationsHaveBeenMet方法的典型用法代码示例。如果您正苦于以下问题:C# MockFactory.VerifyAllExpectationsHaveBeenMet方法的具体用法?C# MockFactory.VerifyAllExpectationsHaveBeenMet怎么用?C# MockFactory.VerifyAllExpectationsHaveBeenMet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MockFactory
的用法示例。
在下文中一共展示了MockFactory.VerifyAllExpectationsHaveBeenMet方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShouldCreateAndEvaluateSelectorKeyTest
public void ShouldCreateAndEvaluateSelectorKeyTest()
{
TransientActivatorAutoWiringDependencyResolution<MockDependantObject> transientActivatorAutoWiringDependencyResolution;
IDependencyManager mockDependencyManager;
MockDependantObject result;
MockFactory mockFactory;
string _unusedString = null;
bool _unusedBoolean = false;
Type _unusedType = null;
mockFactory = new MockFactory();
mockDependencyManager = mockFactory.CreateInstance<IDependencyManager>();
Expect.On(mockDependencyManager).One.Method(m => m.ResolveDependency(_unusedType, _unusedString, _unusedBoolean)).With(typeof(MockDependantObject), string.Empty, true).Will(Return.Value(new MockDependantObject("both")));
transientActivatorAutoWiringDependencyResolution = new TransientActivatorAutoWiringDependencyResolution<MockDependantObject>();
Assert.AreEqual(DependencyLifetime.Transient, transientActivatorAutoWiringDependencyResolution.DependencyLifetime);
result = transientActivatorAutoWiringDependencyResolution.Resolve(mockDependencyManager, "named_dep_obj");
Assert.IsNotNull(result);
Assert.IsInstanceOf<MockDependantObject>(result);
Assert.IsNotNull(result.Text);
Assert.AreEqual(string.Empty, result.Text);
Assert.IsNotNull(result.Left);
Assert.IsNotNull(result.Right);
Assert.AreEqual("both", result.Left.Text);
Assert.AreEqual("both", result.Right.Text);
transientActivatorAutoWiringDependencyResolution.Dispose();
mockFactory.VerifyAllExpectationsHaveBeenMet();
}
开发者ID:textmetal,项目名称:main,代码行数:34,代码来源:TransientActivatorAutoWiringDependencyResolutionArity1Tests.cs
示例2: DoNotIssueMoveIntoStationaryAnt
public void DoNotIssueMoveIntoStationaryAnt()
{
var mock = new MockFactory();
var outputAdapterMock = mock.CreateMock<IGameOutputAdapter>();
using (mock.Ordered)
{
outputAdapterMock.Expects.One.MethodWith(adapter => adapter.NotifyEndOfTurn());
}
var trackerManager = new OwnAntTrackingManager(outputAdapterMock.MockObject);
MapTile origin = GameContext.Map.At(3, 4);
MapTile destination = origin.North;
var ant = new Ant(origin);
destination.CurrentAnt = new Ant(destination);
origin.CurrentAnt = ant;
trackerManager.HasProcessedAllInputMoves();
trackerManager.EnrollToMove(ant, destination);
trackerManager.FinalizeAllMoves();
Assert.IsNotNull(origin.CurrentAnt);
Assert.AreEqual(ant, origin.CurrentAnt);
mock.VerifyAllExpectationsHaveBeenMet();
}
示例3: TestPersist
public void TestPersist()
{
MockFactory factory = new MockFactory();
//Create mocks
Mock<IUserGateway> mockGateway = factory.CreateMock<IUserGateway>();
Mock<IUserValidator> mockValidator = factory.CreateMock<IUserValidator>();
//Create user
User user = new User();
//Expectations
using(factory.Ordered)
{
mockValidator.Expects.One.MethodWith(m => m.Validate(user)).WillReturn(true);
mockGateway.Expects.One.MethodWith(m => m.Persist(user)).WillReturn(true);
}
//Assign gateway
user.Gateway = mockGateway.MockObject;
//Test method
Assert.AreEqual(true, user.Persist(mockValidator.MockObject));
factory.VerifyAllExpectationsHaveBeenMet();
}
示例4: ShouldCreateAndEvaluateTest
public void ShouldCreateAndEvaluateTest()
{
TransientFactoryMethodDependencyResolution transientFactoryMethodDependencyResolution;
IDependencyManager mockDependencyManager;
Func<object> value;
object result;
MockFactory mockFactory;
mockFactory = new MockFactory();
mockDependencyManager = mockFactory.CreateInstance<IDependencyManager>();
value = () => 11;
transientFactoryMethodDependencyResolution = new TransientFactoryMethodDependencyResolution(value);
Assert.AreEqual(DependencyLifetime.Transient, transientFactoryMethodDependencyResolution.DependencyLifetime);
result = transientFactoryMethodDependencyResolution.Resolve(mockDependencyManager, typeof(object), string.Empty);
Assert.IsNotNull(result);
Assert.AreEqual(11, result);
transientFactoryMethodDependencyResolution.Dispose();
mockFactory.VerifyAllExpectationsHaveBeenMet();
}
示例5: ShouldCreateAndEvaluateTest
public void ShouldCreateAndEvaluateTest()
{
InstanceDependencyResolution instanceDependencyResolution;
IDependencyManager mockDependencyManager;
int value;
object result;
MockFactory mockFactory;
mockFactory = new MockFactory();
mockDependencyManager = mockFactory.CreateInstance<IDependencyManager>();
value = 11;
instanceDependencyResolution = new InstanceDependencyResolution(value);
Assert.AreEqual(DependencyLifetime.Instance, instanceDependencyResolution.DependencyLifetime);
result = instanceDependencyResolution.Resolve(mockDependencyManager, typeof(object), string.Empty);
Assert.IsNotNull(result);
Assert.AreEqual(11, result);
instanceDependencyResolution.Dispose();
mockFactory.VerifyAllExpectationsHaveBeenMet();
}
示例6: ShouldExecuteReaderCloseConnectionSprocWithParametersTest
public void ShouldExecuteReaderCloseConnectionSprocWithParametersTest()
{
IAdoNetYieldingFascade adoNetYieldingFascade;
MockFactory mockFactory;
DbConnection mockDbConnection;
DbCommand mockDbCommand;
DbParameterCollection mockDbParameterCollection;
DbParameter[] mockDbParameters;
DbParameter mockDbParameter0;
DbParameter mockDbParameter1;
DbDataReader mockDbDataReader;
IReflectionFascade mockReflectionFascade;
DbDataReader dbDataReader;
CommandBehavior _unusedCommandBehavior = CommandBehavior.Default;
DbParameter _unusedDbParameter = null;
mockFactory = new MockFactory();
mockDbConnection = mockFactory.CreateInstance<DbConnection>();
mockDbCommand = mockFactory.CreateInstance<DbCommand>();
mockDbParameterCollection = mockFactory.CreateInstance<DbParameterCollection>();
mockDbParameter0 = mockFactory.CreateInstance<DbParameter>();
mockDbParameter1 = mockFactory.CreateInstance<DbParameter>();
mockDbParameters = new DbParameter[] { mockDbParameter0, mockDbParameter1 };
mockDbDataReader = mockFactory.CreateInstance<DbDataReader>();
mockReflectionFascade = mockFactory.CreateInstance<IReflectionFascade>();
Expect.On(mockDbConnection).One.Method(x => x.CreateCommand()).Will(Return.Value(mockDbCommand));
Expect.On(mockDbCommand).Exactly(2).GetProperty(x => x.Parameters).Will(Return.Value(mockDbParameterCollection));
Expect.On(mockDbCommand).One.Method(x => x.Dispose());
Expect.On(mockDbCommand).One.SetProperty(x => x.CommandType).To(CommandType.StoredProcedure);
Expect.On(mockDbCommand).One.SetProperty(x => x.CommandText).To("blah blah blah");
Expect.On(mockDbCommand).One.SetProperty(x => x.Transaction).To(null);
Expect.On(mockDbCommand).One.Method(x => x.ExecuteReader(_unusedCommandBehavior)).With(CommandBehavior.CloseConnection).Will(Return.Value(mockDbDataReader));
Expect.On(mockDbParameter0).One.GetProperty(x => x.Value).Will(Return.Value(1));
Expect.On(mockDbParameter1).One.GetProperty(x => x.Value).Will(Return.Value(null));
Expect.On(mockDbParameter1).One.SetProperty(x => x.Value).To(DBNull.Value);
Expect.On(mockDbParameterCollection).One.Method(x => x.Add(_unusedDbParameter)).With(mockDbParameter0).Will(Return.Value(0));
Expect.On(mockDbParameterCollection).One.Method(x => x.Add(_unusedDbParameter)).With(mockDbParameter1).Will(Return.Value(0));
Expect.On(mockDbDataReader).One.Method(x => x.Dispose());
adoNetYieldingFascade = new AdoNetYieldingFascade(mockReflectionFascade);
dbDataReader = adoNetYieldingFascade.ExecuteReader(mockDbConnection, null, CommandType.StoredProcedure, "blah blah blah", mockDbParameters, CommandBehavior.CloseConnection, null, false);
Assert.IsNotNull(dbDataReader);
dbDataReader.Dispose();
mockFactory.VerifyAllExpectationsHaveBeenMet();
}
示例7: EnsureThatEverythingIsTrackedCorrectly
public void EnsureThatEverythingIsTrackedCorrectly()
{
var mock = new MockFactory();
Mock<IGameOutputAdapter> outputAdapterMock = mock.CreateMock<IGameOutputAdapter>();
outputAdapterMock.Expects.AtLeastOne.MethodWith(x => x.NotifyReady());
outputAdapterMock.Expects.AtLeastOne.MethodWith(x => x.NotifyEndOfTurn());
var gameManager = new GameManager(outputAdapterMock.MockObject);
var inputInterpreter = new InputInterpreter(gameManager);
inputInterpreter.Interpret("turn 0");
inputInterpreter.Interpret("rows 10");
inputInterpreter.Interpret("cols 10");
inputInterpreter.Interpret("ready");
inputInterpreter.Interpret("turn 1");
inputInterpreter.Interpret("a 0 5 0");
inputInterpreter.Interpret("go");
Ant initAnt = (from row in Enumerable.Range(0, GameContext.Map.Rows)
from col in Enumerable.Range(0, GameContext.Map.Columns)
let tile = GameContext.Map.At(row, col)
where tile.CurrentAnt != null
select tile.CurrentAnt
).Single();
initAnt.MovementStrategy = new MoveDirection(initAnt, Direction.South);
for (int turn = 2; turn < 10; turn++)
{
var expectedRow = turn - 2;
var expectedColumn = initAnt.CurrentPosition.Column;
inputInterpreter.Interpret("turn " + turn);
inputInterpreter.Interpret(string.Format("a {0} {1} 0", expectedRow, expectedColumn));
outputAdapterMock.Expects.One
.MethodWith(adapter => adapter.MoveAnt(expectedRow, expectedColumn, Direction.South));
inputInterpreter.Interpret("go");
Assert.IsTrue(initAnt.MovementStrategy is MoveDirection);
}
mock.VerifyAllExpectationsHaveBeenMet();
}
示例8: EnsureMovesAreIssued
public void EnsureMovesAreIssued()
{
var mock = new MockFactory();
Mock<IGameOutputAdapter> outputAdapterMock = mock.CreateMock<IGameOutputAdapter>();
outputAdapterMock.Expects.One.MethodWith(x => x.NotifyReady());
outputAdapterMock.Expects.One.MethodWith(x => x.NotifyEndOfTurn());
var gameManager = new GameManager(outputAdapterMock.MockObject);
var turnResults = new TurnState();
turnResults.Ants.Add(new TurnState.Point(3, 3));
gameManager.RulesNotification(new GameRules {MapColumns = 10, MapRows = 10});
gameManager.DoMoves(turnResults);
mock.VerifyAllExpectationsHaveBeenMet();
}
示例9: ShouldCreateAndEvaluateTest
public void ShouldCreateAndEvaluateTest()
{
ContextWrapperDependencyResolution contextWrapperDependencyResolution;
IDependencyManager mockDependencyManager;
IDependencyResolution mockDependencyResolution;
IDependencyManager _unusedDependencyManager = null;
Type _unusedType = null;
string _unusedString = null;
object result;
const int EXPECTED = 11;
MockFactory mockFactory;
mockFactory = new MockFactory();
mockDependencyManager = mockFactory.CreateInstance<IDependencyManager>();
mockDependencyResolution = mockFactory.CreateInstance<IDependencyResolution>();
Expect.On(mockDependencyResolution).One.Method(m => m.Resolve(_unusedDependencyManager, _unusedType, _unusedString)).With(mockDependencyManager, typeof(object), string.Empty).WillReturn(EXPECTED);
Expect.On(mockDependencyResolution).One.Method(m => m.Dispose());
contextWrapperDependencyResolution = new ContextWrapperDependencyResolution(ContextScope.LocalThreadSafe, mockDependencyResolution);
Assert.AreEqual(DependencyLifetime.Singleton, contextWrapperDependencyResolution.DependencyLifetime);
// should be thawed at this point
result = contextWrapperDependencyResolution.Resolve(mockDependencyManager, typeof(object), string.Empty);
Assert.IsNotNull(result);
Assert.AreEqual(EXPECTED, result);
// should be frozen at this point
result = contextWrapperDependencyResolution.Resolve(mockDependencyManager, typeof(object), string.Empty);
Assert.IsNotNull(result);
Assert.AreEqual(EXPECTED, result);
contextWrapperDependencyResolution.Dispose();
mockFactory.VerifyAllExpectationsHaveBeenMet();
}
示例10: ShouldCreateTest
public void ShouldCreateTest()
{
Tokenizer tokenizer;
MockFactory mockFactory;
IDictionary<string, ITokenReplacementStrategy> mockTokenReplacementStrategies;
mockFactory = new MockFactory();
mockTokenReplacementStrategies = mockFactory.CreateInstance<IDictionary<string, ITokenReplacementStrategy>>();
tokenizer = new Tokenizer(true);
Assert.IsNotNull(tokenizer);
Assert.IsNotNull(tokenizer.TokenReplacementStrategies);
Assert.IsTrue(tokenizer.StrictMatching);
tokenizer = new Tokenizer(mockTokenReplacementStrategies, true);
Assert.IsNotNull(tokenizer);
Assert.IsNotNull(tokenizer.TokenReplacementStrategies);
Assert.IsTrue(tokenizer.StrictMatching);
mockFactory.VerifyAllExpectationsHaveBeenMet();
}
示例11: ShouldCreateAndEvaluateTest
public void ShouldCreateAndEvaluateTest()
{
TransientDefaultConstructorDependencyResolution<MockDependantObject> transientDefaultConstructorDependencyResolution;
IDependencyManager mockDependencyManager;
MockDependantObject result;
MockFactory mockFactory;
mockFactory = new MockFactory();
mockDependencyManager = mockFactory.CreateInstance<IDependencyManager>();
transientDefaultConstructorDependencyResolution = new TransientDefaultConstructorDependencyResolution<MockDependantObject>();
Assert.AreEqual(DependencyLifetime.Transient, transientDefaultConstructorDependencyResolution.DependencyLifetime);
result = transientDefaultConstructorDependencyResolution.Resolve(mockDependencyManager, string.Empty);
Assert.IsNotNull(result);
Assert.IsNull(result.Text);
transientDefaultConstructorDependencyResolution.Dispose();
mockFactory.VerifyAllExpectationsHaveBeenMet();
}
开发者ID:textmetal,项目名称:main,代码行数:23,代码来源:TransientDefaultConstructorDependencyResolutionArity1Tests.cs
示例12: ShouldCreateAndEvaluateTest
public void ShouldCreateAndEvaluateTest()
{
SingletonWrapperDependencyResolution<int> singletonWrapperDependencyResolution;
IDependencyManager mockDependencyManager;
IDependencyResolution<int> mockDependencyResolution;
IDependencyManager _unusedDependencyManager = null;
string _unusedString = null;
int result;
MockFactory mockFactory;
mockFactory = new MockFactory();
mockDependencyManager = mockFactory.CreateInstance<IDependencyManager>();
mockDependencyResolution = mockFactory.CreateInstance<IDependencyResolution<int>>();
Expect.On(mockDependencyResolution).One.Method(m => m.Resolve(_unusedDependencyManager, _unusedString)).With(mockDependencyManager, string.Empty).WillReturn(11);
Expect.On(mockDependencyResolution).One.Method(m => m.Dispose());
singletonWrapperDependencyResolution = new SingletonWrapperDependencyResolution<int>(mockDependencyResolution);
Assert.AreEqual(DependencyLifetime.Singleton, singletonWrapperDependencyResolution.DependencyLifetime);
// should be thawed at this point
result = singletonWrapperDependencyResolution.Resolve(mockDependencyManager, string.Empty);
Assert.IsNotNull(result);
Assert.AreEqual(11, result);
// should be frozen at this point
result = singletonWrapperDependencyResolution.Resolve(mockDependencyManager, string.Empty);
Assert.IsNotNull(result);
Assert.AreEqual(11, result);
singletonWrapperDependencyResolution.Dispose();
mockFactory.VerifyAllExpectationsHaveBeenMet();
}
示例13: ShouldNotFailOnDoubleDisposedAddResolution1Test
public void ShouldNotFailOnDoubleDisposedAddResolution1Test()
{
DependencyManager dependencyManager;
MockFactory mockFactory;
IDependencyResolution mockDependencyResolution;
mockFactory = new MockFactory();
mockDependencyResolution = mockFactory.CreateInstance<IDependencyResolution>();
dependencyManager = new DependencyManager();
Assert.IsFalse(dependencyManager.Disposed);
dependencyManager.Dispose();
Assert.IsTrue(dependencyManager.Disposed);
dependencyManager.Dispose();
Assert.IsTrue(dependencyManager.Disposed);
mockFactory.VerifyAllExpectationsHaveBeenMet();
}
示例14: ShouldExecuteReaderCloseConnectionTextNoParametersTest
public void ShouldExecuteReaderCloseConnectionTextNoParametersTest()
{
IAdoNetYieldingFascade adoNetYieldingFascade;
MockFactory mockFactory;
DbConnection mockDbConnection;
DbCommand mockDbCommand;
DbDataReader mockDbDataReader;
IReflectionFascade mockReflectionFascade;
DbDataReader dbDataReader;
CommandBehavior _unusedCommandBehavior = CommandBehavior.Default;
mockFactory = new MockFactory();
mockDbConnection = mockFactory.CreateInstance<DbConnection>();
mockDbCommand = mockFactory.CreateInstance<DbCommand>();
mockDbDataReader = mockFactory.CreateInstance<DbDataReader>();
mockReflectionFascade = mockFactory.CreateInstance<IReflectionFascade>();
Expect.On(mockDbConnection).One.Method(x => x.CreateCommand()).Will(Return.Value(mockDbCommand));
Expect.On(mockDbCommand).One.Method(x => x.Dispose());
Expect.On(mockDbCommand).One.SetProperty(x => x.CommandType).To(CommandType.Text);
Expect.On(mockDbCommand).One.SetProperty(x => x.CommandText).To("blah blah blah");
Expect.On(mockDbCommand).One.SetProperty(x => x.Transaction).To(null);
Expect.On(mockDbCommand).One.Method(x => x.ExecuteReader(_unusedCommandBehavior)).With(CommandBehavior.CloseConnection).Will(Return.Value(mockDbDataReader));
Expect.On(mockDbDataReader).One.Method(x => x.Dispose());
Expect.On(mockDbCommand).One.SetProperty(x => x.CommandTimeout).To(15);
Expect.On(mockDbCommand).One.Method(x => x.Prepare());
adoNetYieldingFascade = new AdoNetYieldingFascade(mockReflectionFascade);
dbDataReader = adoNetYieldingFascade.ExecuteReader(mockDbConnection, null, CommandType.Text, "blah blah blah", null, CommandBehavior.CloseConnection, 15, true);
Assert.IsNotNull(dbDataReader);
dbDataReader.Dispose();
mockFactory.VerifyAllExpectationsHaveBeenMet();
}
示例15: ShouldCheckIfHasResolution1Test
public void ShouldCheckIfHasResolution1Test()
{
DependencyManager dependencyManager;
MockFactory mockFactory;
IDependencyResolution<IDisposable> mockDependencyResolution;
string selectorKey;
bool includeAssignableTypes;
bool result;
mockFactory = new MockFactory();
mockDependencyResolution = mockFactory.CreateInstance<IDependencyResolution<IDisposable>>();
Expect.On(mockDependencyResolution).One.Method(m => m.Dispose());
dependencyManager = new DependencyManager();
selectorKey = null;
includeAssignableTypes = false;
result = dependencyManager.HasTypeResolution<IDisposable>(selectorKey, includeAssignableTypes);
Assert.IsFalse(result);
selectorKey = string.Empty;
includeAssignableTypes = false;
result = dependencyManager.HasTypeResolution<IDisposable>(selectorKey, includeAssignableTypes);
Assert.IsFalse(result);
selectorKey = COMMON_SELECTOR_KEY;
includeAssignableTypes = false;
result = dependencyManager.HasTypeResolution<IDisposable>(selectorKey, includeAssignableTypes);
Assert.IsFalse(result);
selectorKey = COMMON_SELECTOR_KEY;
includeAssignableTypes = false;
dependencyManager.AddResolution<IDisposable>(selectorKey, includeAssignableTypes, mockDependencyResolution);
selectorKey = null;
includeAssignableTypes = false;
result = dependencyManager.HasTypeResolution<IDisposable>(selectorKey, includeAssignableTypes);
Assert.IsTrue(result);
selectorKey = string.Empty;
includeAssignableTypes = false;
result = dependencyManager.HasTypeResolution<IDisposable>(selectorKey, includeAssignableTypes);
Assert.IsFalse(result);
selectorKey = COMMON_SELECTOR_KEY;
includeAssignableTypes = false;
result = dependencyManager.HasTypeResolution<IDisposable>(selectorKey, includeAssignableTypes);
Assert.IsTrue(result);
dependencyManager.ClearAllResolutions();
selectorKey = null;
includeAssignableTypes = false;
result = dependencyManager.HasTypeResolution<IDisposable>(selectorKey, includeAssignableTypes);
Assert.IsFalse(result);
selectorKey = string.Empty;
includeAssignableTypes = false;
result = dependencyManager.HasTypeResolution<IDisposable>(selectorKey, includeAssignableTypes);
Assert.IsFalse(result);
selectorKey = COMMON_SELECTOR_KEY;
includeAssignableTypes = false;
result = dependencyManager.HasTypeResolution<IDisposable>(selectorKey, includeAssignableTypes);
Assert.IsFalse(result);
selectorKey = string.Empty;
includeAssignableTypes = false;
dependencyManager.AddResolution<IDisposable>(selectorKey, includeAssignableTypes, mockDependencyResolution);
result = dependencyManager.HasTypeResolution<IDisposable>(selectorKey, includeAssignableTypes);
Assert.IsTrue(result);
selectorKey = string.Empty;
includeAssignableTypes = false;
result = dependencyManager.HasTypeResolution<IDisposable>(selectorKey, includeAssignableTypes);
Assert.IsTrue(result);
selectorKey = COMMON_SELECTOR_KEY;
includeAssignableTypes = false;
result = dependencyManager.HasTypeResolution<IDisposable>(selectorKey, includeAssignableTypes);
Assert.IsFalse(result);
mockFactory.VerifyAllExpectationsHaveBeenMet();
}