本文整理汇总了C#中Moq.MockRepository.OneOf方法的典型用法代码示例。如果您正苦于以下问题:C# MockRepository.OneOf方法的具体用法?C# MockRepository.OneOf怎么用?C# MockRepository.OneOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Moq.MockRepository
的用法示例。
在下文中一共展示了MockRepository.OneOf方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LocalBallancerConstructorTestNull1
public void LocalBallancerConstructorTestNull1()
{
var moq = new MockRepository(MockBehavior.Default);
var ballancer = new LocalBallancer<int>(null, moq.OneOf<IPerformanceManager>(),
moq.OneOf<IRemoteMachinesManager>(), 1);
Assert.IsNotNull(ballancer);
}
示例2: LocalBallancerConstructorTestNull3
public void LocalBallancerConstructorTestNull3()
{
var moq = new MockRepository(MockBehavior.Default);
var ballancer = new LocalBallancer<int>(moq.OneOf<IBallancerTask<int>>(), moq.OneOf<IPerformanceManager>(),
null, 1);
Assert.IsNotNull(ballancer);
}
示例3: StrartLoadBallancerTestNoConf
public void StrartLoadBallancerTestNoConf()
{
var moq = new MockRepository(MockBehavior.Default);
var config = new SimpleConfig(@"nonfile.xml");
config.StrartLoadBallancer(moq.OneOf<IBallancerTask<int>>());
}
示例4: Test_Initialize_Multiple_Stubs_Using_Repository_OneOf_Method
public void Test_Initialize_Multiple_Stubs_Using_Repository_OneOf_Method()
{
// MockRepository supports two ways for building subs.
// Instead of calling "Of" method we can call OneOf and
// use the same syntax as for creating stubs via Mock.Of
// Arrange
var repository = new MockRepository(MockBehavior.Default);
ILoggerDependency logger =
repository.OneOf<ILoggerDependency>(ld => ld.DefaultLogger == "DefaultLogger"
&& ld.GetCurrentDirectory() == "D:\\Temp"
&& ld.GetDirectoryByLoggerName(It.IsAny<string>()) == "C:\\Temp");
// Assert
Assert.That(logger.GetCurrentDirectory(), Is.EqualTo("D:\\Temp"));
Assert.That(logger.DefaultLogger, Is.EqualTo("DefaultLogger"));
Assert.That(logger.GetDirectoryByLoggerName("CustomLogger"), Is.EqualTo("C:\\Temp"));
}
示例5: LocalBallancerStartTest
public void LocalBallancerStartTest()
{
var machineMgrMoq = new Mock<IRemoteMachinesManager>();
var moq = new MockRepository(MockBehavior.Default);
const int machCount = 7;
machineMgrMoq.Setup(manager => manager.UnaviableHosts()).Returns(new[] { 2,5,6 });
machineMgrMoq.Setup(m => m.Count).Returns(machCount);
int ijk = 0;
var recived = new List<int>();
int tmp = 0;
var ballancerTask = new BallancerDelagateTask<int?>(i =>
{
if (ijk != 100) return new int?[] {ijk++};
return Enumerable.Empty<int?>();
}, i =>
{
if (i != null) recived.Add(i.Value);
else
{
tmp++;
if (tmp > ijk)
lock (this)
{
Monitor.PulseAll(this);
return true;
}
}
return true;
}, 1);
var ballancer = new LocalBallancer<int?>(ballancerTask,
moq.OneOf<IPerformanceManager>(),
machineMgrMoq.Object, 1);
var task = ballancer.StartAsync();
lock (this)
{
Monitor.Wait(this);
Assert.IsTrue(recived.Count > ijk / machCount, "{0}", recived.Count);
}
Assert.IsNotNull(ballancer);
Assert.IsFalse(task.IsCanceled);
Assert.IsFalse(task.IsFaulted);
Assert.IsFalse(task.IsCanceled);
}