本文整理汇总了C#中Fixture.Do方法的典型用法代码示例。如果您正苦于以下问题:C# Fixture.Do方法的具体用法?C# Fixture.Do怎么用?C# Fixture.Do使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fixture
的用法示例。
在下文中一共展示了Fixture.Do方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoStuffWillInvokeAddInWithContextInstance
public void DoStuffWillInvokeAddInWithContextInstance()
{
// Fixture setup
var fixture = new Fixture();
var addInMock = new Mock<IAddIn>();
addInMock.Setup(ai => ai.DoStuff(It.IsAny<SomeValue>(), It.Is<ISomeContext>(ctx => ctx != null))).Returns(fixture.CreateAnonymous("Message")).Verifiable();
fixture.Register<IEnumerable<IAddIn>>(() => new[] { addInMock.Object });
var sut = fixture.CreateAnonymous<AddInClient>();
// Exercise system
fixture.Do((SomeValue sv) => sut.DoStuff(sv));
// Verify outcome
addInMock.Verify();
// Teardown
}
示例2: DoubleParameterDoWillInvokeMethodWithCorrectParameters
public void DoubleParameterDoWillInvokeMethodWithCorrectParameters(
int expectedNumber,
string expectedText)
{
// Fixture setup
var fixture = new Fixture();
fixture.Inject(expectedNumber);
fixture.Inject(expectedText);
var verified = false;
var mock = new CommandMock<int, string>();
mock.OnCommand = (x, y) => verified =
expectedNumber == x &&
expectedText == y;
// Exercise system
fixture.Do((int x, string y) => mock.Command(x, y));
// Verify outcome
Assert.True(verified, "Mock wasn't verified.");
// Teardown
}
示例3: DoOnCommandWithThreeParametersWillInvokeMethodWithCorrectSecondParameter
public void DoOnCommandWithThreeParametersWillInvokeMethodWithCorrectSecondParameter()
{
// Fixture setup
TimeSpan expectedTimeSpan = TimeSpan.FromHours(53);
var sut = new Fixture();
sut.Register<TimeSpan>(() => expectedTimeSpan);
var mock = new CommandMock<uint, TimeSpan, TimeSpan>();
mock.OnCommand = (x1, x2, x3) => Assert.Equal<TimeSpan>(expectedTimeSpan, x2);
// Exercise system
sut.Do((uint x1, TimeSpan x2, TimeSpan x3) => mock.Command(x1, x2, x3));
// Verify outcome (done by mock)
// Teardown
}
示例4: DoOnCommandWithThreeParametersWillInvokeMethodWithCorrectFirstParameter
public void DoOnCommandWithThreeParametersWillInvokeMethodWithCorrectFirstParameter()
{
// Fixture setup
DateTime expectedDateTime = new DateTime(1004328837);
var sut = new Fixture();
sut.Register<DateTime>(() => expectedDateTime);
var mock = new CommandMock<DateTime, long, short>();
mock.OnCommand = (x1, x2, x3) => Assert.Equal<DateTime>(expectedDateTime, x1);
// Exercise system
sut.Do((DateTime x1, long x2, short x3) => mock.Command(x1, x2, x3));
// Verify outcome (done by mock)
// Teardown
}
示例5: DoOnCommandWithThreeParametersWillInvokeMethod
public void DoOnCommandWithThreeParametersWillInvokeMethod()
{
// Fixture setup
bool methodInvoked = false;
var sut = new Fixture();
var mock = new CommandMock<object, object, object>();
mock.OnCommand = (x1, x2, x3) => methodInvoked = true;
// Exercise system
sut.Do((object x1, object x2, object x3) => mock.Command(x1, x2, x3));
// Verify outcome
Assert.True(methodInvoked, "Command method invoked");
// Teardown
}
示例6: DoOnCommandWithSingleParameterWillInvokeMethodWithCorrectParameter
public void DoOnCommandWithSingleParameterWillInvokeMethodWithCorrectParameter()
{
// Fixture setup
int expectedNumber = 94;
var sut = new Fixture();
sut.Register<int>(() => expectedNumber);
var mock = new CommandMock<int>();
mock.OnCommand = x => Assert.Equal<int>(expectedNumber, x);
// Exercise system
sut.Do((int i) => mock.Command(i));
// Verify outcome (done by mock)
// Teardown
}
示例7: DoOnCommandWithNullTwoParameterActionThrows
public void DoOnCommandWithNullTwoParameterActionThrows()
{
// Fixture setup
var sut = new Fixture();
// Exercise system and verify outcome
Assert.Throws<ArgumentNullException>(() =>
sut.Do<object, object>(null));
// Teardown
}
示例8: QuadrupleParameterDoWillInvokeMethodWithCorrectParameters
public void QuadrupleParameterDoWillInvokeMethodWithCorrectParameters(
int expectedNumber,
string expectedText,
Type expectedType,
bool expectedBool)
{
// Fixture setup
var fixture = new Fixture();
fixture.Inject(expectedNumber);
fixture.Inject(expectedText);
fixture.Inject(expectedType);
fixture.Inject(expectedBool);
var verified = false;
var mock = new CommandMock<int, string, Type, bool>();
mock.OnCommand = (x, y, z, æ) => verified =
expectedNumber == x &&
expectedText == y &&
expectedType == z &&
expectedBool == æ;
// Exercise system
fixture.Do(
(int x, string y, Type z, bool æ) => mock.Command(x, y, z, æ));
// Verify outcome
Assert.True(verified, "Mock wasn't verified.");
// Teardown
}
示例9: DoOnCommandWithTwoParametersWillInvokeMethodWithCorrectFirstParameter
public void DoOnCommandWithTwoParametersWillInvokeMethodWithCorrectFirstParameter()
{
// Fixture setup
double expectedNumber = 25364.37;
var sut = new Fixture();
sut.Register<double>(() => expectedNumber);
var mock = new CommandMock<double, object>();
mock.OnCommand = (x1, x2) => Assert.Equal<double>(expectedNumber, x1);
// Exercise system
sut.Do((double x1, object x2) => mock.Command(x1, x2));
// Verify outcome (done by mock)
// Teardown
}
示例10: DoOnCommandWithFourParametersWillInvokeMethodWithCorrectFourthParameter
public void DoOnCommandWithFourParametersWillInvokeMethodWithCorrectFourthParameter()
{
// Fixture setup
var expectedOS = new OperatingSystem(PlatformID.Win32NT, new Version(5, 0));
var sut = new Fixture();
sut.Register<OperatingSystem>(() => expectedOS);
var mock = new CommandMock<int?, DateTime, TimeSpan, OperatingSystem>();
mock.OnCommand = (x1, x2, x3, x4) => Assert.Equal<OperatingSystem>(expectedOS, x4);
// Exercise system
sut.Do((int? x1, DateTime x2, TimeSpan x3, OperatingSystem x4) => mock.Command(x1, x2, x3, x4));
// Verify outcome (done by mock)
// Teardown
}
示例11: DoOnCommandWithFourParametersWillInvokeMethodWithCorrectFirstParameter
public void DoOnCommandWithFourParametersWillInvokeMethodWithCorrectFirstParameter()
{
// Fixture setup
uint expectedNumber = 294;
var sut = new Fixture();
sut.Register<uint>(() => expectedNumber);
var mock = new CommandMock<uint, bool, string, Guid>();
mock.OnCommand = (x1, x2, x3, x4) => Assert.Equal<uint>(expectedNumber, x1);
// Exercise system
sut.Do((uint x1, bool x2, string x3, Guid x4) => mock.Command(x1, x2, x3, x4));
// Verify outcome (done by mock)
// Teardown
}
示例12: DoOnCommandWithFourParametersWillInvokeMethod
public void DoOnCommandWithFourParametersWillInvokeMethod()
{
// Fixture setup
bool methodInvoked = false;
var sut = new Fixture();
var mock = new CommandMock<uint, ushort, int, bool>();
mock.OnCommand = (x1, x2, x3, x4) => methodInvoked = true;
// Exercise system
sut.Do((uint x1, ushort x2, int x3, bool x4) => mock.Command(x1, x2, x3, x4));
// Verify outcome
Assert.True(methodInvoked, "Command method invoked");
// Teardown
}
示例13: UpdateCurrencyCodeWhenProfileIsNotUserProfileWillThrow
public void UpdateCurrencyCodeWhenProfileIsNotUserProfileWillThrow()
{
// Fixture setup
var fixture = new Fixture();
var profile = new Mock<ProfileBase>().Object;
var httpContextStub = new Mock<HttpContextBase>();
httpContextStub.SetupGet(ctx => ctx.Profile).Returns(profile);
var sut = new DefaultCurrencyProfileService(httpContextStub.Object);
// Exercise system and verify outcome
Assert.Throws<InvalidOperationException>(() =>
fixture.Do((string currencyCode) =>
sut.UpdateCurrencyCode(currencyCode)));
// Teardown
}
示例14: DoOnCommandWithThreeParametersWillInvokeMethodWithCorrectThirdParameter
public void DoOnCommandWithThreeParametersWillInvokeMethodWithCorrectThirdParameter()
{
// Fixture setup
var expectedText = "Anonymous text";
var sut = new Fixture();
sut.Register<string>(() => expectedText);
var mock = new CommandMock<double, uint, string>();
mock.OnCommand = (x1, x2, x3) => Assert.Equal<string>(expectedText, x3);
// Exercise system
sut.Do((double x1, uint x2, string x3) => mock.Command(x1, x2, x3));
// Verify outcome (done by mock)
// Teardown
}
示例15: DoOnCommandWithFourParametersWillInvokeMethodWithCorrectSecondParameter
public void DoOnCommandWithFourParametersWillInvokeMethodWithCorrectSecondParameter()
{
// Fixture setup
decimal expectedNumber = 92183.28m;
var sut = new Fixture();
sut.Register<decimal>(() => expectedNumber);
var mock = new CommandMock<ushort, decimal, Guid, bool>();
mock.OnCommand = (x1, x2, x3, x4) => Assert.Equal<decimal>(expectedNumber, x2);
// Exercise system
sut.Do((ushort x1, decimal x2, Guid x3, bool x4) => mock.Command(x1, x2, x3, x4));
// Verify outcome (done by mock)
// Teardown
}