本文整理汇总了C#中IFoo类的典型用法代码示例。如果您正苦于以下问题:C# IFoo类的具体用法?C# IFoo怎么用?C# IFoo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IFoo类属于命名空间,在下文中一共展示了IFoo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BarWithMultipleParameters
public BarWithMultipleParameters(IFoo parameter1, string parameter2, string parameter3, int parameter4)
{
Parameter1 = parameter1;
Parameter2 = parameter2;
Parameter3 = parameter3;
Parameter4 = parameter4;
}
示例2: MultipleCallbacks
public static void MultipleCallbacks(
IFoo fake,
bool firstWasCalled,
bool secondWasCalled,
int returnValue)
{
"establish"
.x(() => fake = A.Fake<IFoo>());
"when configuring multiple callback"
.x(() =>
{
A.CallTo(() => fake.Baz())
.Invokes(x => firstWasCalled = true)
.Invokes(x => secondWasCalled = true)
.Returns(10);
returnValue = fake.Baz();
});
"it should call the first callback"
.x(() => firstWasCalled.Should().BeTrue());
"it should call the second callback"
.x(() => secondWasCalled.Should().BeTrue());
"it should return the configured value"
.x(() => returnValue.Should().Be(10));
}
示例3: RaiseTests
public RaiseTests()
{
this.foo = A.Fake<IFoo>();
this.foo.SomethingHappened += this.Foo_SomethingHappened;
this.sender = null;
this.eventArguments = null;
}
示例4: MatchingCallsWithMatches
public static void MatchingCallsWithMatches(
IFoo fake,
IEnumerable<ICompletedFakeObjectCall> completedCalls,
IEnumerable<ICompletedFakeObjectCall> matchedCalls)
{
"Given a Fake"
.x(() => fake = A.Fake<IFoo>());
"And I make several calls to the Fake"
.x(() =>
{
fake.AMethod();
fake.AnotherMethod();
fake.AnotherMethod("houseboat");
});
"And I use the static Fake class to get the calls made on the Fake"
.x(() => completedCalls = Fake.GetCalls(fake));
"When I use Matching to find calls to a method with a match"
.x(() => matchedCalls = completedCalls.Matching<IFoo>(c => c.AnotherMethod("houseboat")));
"Then it finds the matching call"
.x(() => matchedCalls.Select(c => c.Method.Name).Should().Equal("AnotherMethod"));
}
示例5: FakeWrapperConfiguratorTests
public FakeWrapperConfiguratorTests()
{
this.faked = A.Fake<IFoo>();
IFoo wrapped = A.Fake<IFoo>();
this.wrapperConfigurator = new FakeWrapperConfigurator<IFoo>(A.Fake<IFakeOptions<IFoo>>(), wrapped);
}
示例6: Serialize
public static void Serialize(IFoo h)
{
Point point1 = new Point (0, 1);
Point? point2 = new Point (1, 2);
h.Foo (ref point1);
h.Foo (ref point2);
}
示例7: MultipleCallbacks
public static void MultipleCallbacks(
IFoo fake,
bool firstWasCalled,
bool secondWasCalled,
int returnValue)
{
"Given a fake"
.x(() => fake = A.Fake<IFoo>());
"And I configure a method to invoke two actions and return a value"
.x(() =>
A.CallTo(() => fake.Baz())
.Invokes(x => firstWasCalled = true)
.Invokes(x => secondWasCalled = true)
.Returns(10));
"When I call the method"
.x(() => returnValue = fake.Baz());
"Then it calls the first callback"
.x(() => firstWasCalled.Should().BeTrue());
"And it calls the first callback"
.x(() => secondWasCalled.Should().BeTrue());
"And it returns the configured value"
.x(() => returnValue.Should().Be(10));
}
示例8: SetUp
public void SetUp()
{
this.foo = A.Fake<IFoo>();
this.foo.SomethingHappened += new EventHandler(this.Foo_SomethingHappened);
this.sender = null;
this.eventArguments = null;
}
示例9: MultistepOrderedAssertionsInOrder
public static void MultistepOrderedAssertionsInOrder(
IFoo fake,
Exception exception,
IOrderableCallAssertion lastAssertion)
{
"Given a Fake"
.x(() => fake = A.Fake<IFoo>());
"And a call on the Fake, passing argument 1"
.x(() => fake.Bar(1));
"And a call on the Fake, passing argument 2"
.x(() => fake.Bar(2));
"And a call on the Fake, passing argument 2"
.x(() => fake.Bar(2));
"And a call on the Fake, passing argument 3"
.x(() => fake.Bar(3));
"When I assert that a call with argument 1 was made exactly once"
.x(() => lastAssertion = A.CallTo(() => fake.Bar(1)).MustHaveHappened(Repeated.Exactly.Once));
"And then a call with argument 2"
.x(() => lastAssertion = lastAssertion.Then(A.CallTo(() => fake.Bar(2)).MustHaveHappened()));
"And then a call with argument 3 exactly once"
.x(() => exception = Record.Exception(() => lastAssertion.Then(A.CallTo(() => fake.Bar(3)).MustHaveHappened(Repeated.Exactly.Once))));
"Then the assertions should pass"
.x(() => exception.Should().BeNull());
}
示例10: Run
private double Run(IFoo foo)
{
double sum = 0;
for (int i = 0; i < 1001; i++)
sum += foo.Inc(0);
return sum;
}
示例11: Setup
public void Setup()
{
this.faked = A.Fake<IFoo>();
IFoo wrapped = A.Fake<IFoo>();
this.wrapperConfigurator = new FakeWrapperConfigurator(wrapped);
}
示例12: Setup
public void Setup()
{
this.faked = A.Fake<IFoo>();
IFoo wrapped = A.Fake<IFoo>();
this.wrapperConfigurator = new FakeWrapperConfigurator<IFoo>(A.Fake<IFakeOptionsBuilder<IFoo>>(), wrapped);
}
示例13: Setup
public void Setup()
{
this.foo = A.Fake<IFoo>();
this.foo.SomethingHappened += this.Foo_SomethingHappened;
this.sender = null;
this.eventArguments = null;
}
示例14: VoidMethodWithThrows
public void VoidMethodWithThrows(
IFoo foo,
Action action,
Exception exception)
{
"Given a fake"
.x(() => foo = A.Fake<IFoo>());
"And an action"
.x(() => action = A.Fake<Action>());
"When a void method is configured to invoke a delegate twice then throw an exception"
.x(() =>
A.CallTo(() => foo.Bar()).Invokes(action).DoesNothing().Twice()
.Then.Throws<InvalidOperationException>());
"And the method is called 3 times"
.x(() =>
{
foo.Bar();
foo.Bar();
exception = Record.Exception(() => foo.Bar());
});
"Then the delegate is invoked twice"
.x(() => A.CallTo(() => action()).MustHaveHappened(Repeated.Exactly.Twice));
"And the third call throws an exception"
.x(() => exception.Should().BeAnExceptionOfType<InvalidOperationException>());
}
示例15: VoidMethodWithInvokes
public void VoidMethodWithInvokes(
IFoo foo,
Action action1,
Action action2)
{
"Given a fake"
.x(() => foo = A.Fake<IFoo>());
"And two delegates"
.x(() =>
{
action1 = A.Fake<Action>();
action2 = A.Fake<Action>();
});
"When a void method is configured to invoke a delegate once then invoke another delegate"
.x(() =>
A.CallTo(() => foo.Bar()).Invokes(action1).DoesNothing().Once()
.Then.Invokes(action2));
"And the method is called 3 times"
.x(() =>
{
foo.Bar();
foo.Bar();
foo.Bar();
});
"Then the first delegate is invoked once, and the second delegate is invoked twice"
.x(() => A.CallTo(() => action1()).MustHaveHappened(Repeated.Exactly.Once)
.Then(A.CallTo(() => action2()).MustHaveHappened(Repeated.Exactly.Twice)));
}