本文整理汇总了C#中System.Proxy.Save方法的典型用法代码示例。如果您正苦于以下问题:C# Proxy.Save方法的具体用法?C# Proxy.Save怎么用?C# Proxy.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Proxy
的用法示例。
在下文中一共展示了Proxy.Save方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Should_Throw_If_Advices_Are_Not_Specified
public void Should_Throw_If_Advices_Are_Not_Specified()
{
var foo = new Foo();
var proxy = new Proxy<IFoo>()
.Target(foo)
.Intercept(f => f.Go());
//.OnBefore(() => Assert.False(foo.WasExecuted))
Assert.Throws<ProxyInitializationException>(() => proxy.Save());
}
示例2: Shuold_Throw_If_Target_Does_Not_Exist
public void Shuold_Throw_If_Target_Does_Not_Exist()
{
var foo = new Foo();
var proxy = new Proxy<IFoo>()
//.Target(foo)
//.Intercept(f => f.Go())
.OnBefore(() => Assert.False(foo.WasExecuted))
.OnInvoke(mi => foo.Go());
Assert.Throws<ProxyInitializationException>(() => proxy.Save());
}
示例3: Can_Intercept_Multiple_Members_Using_Many_Fluent_Instructions
public void Can_Intercept_Multiple_Members_Using_Many_Fluent_Instructions()
{
var ack = 0;
var target = new Foo();
var proxy = new Proxy<IFoo>();
proxy.Target(target)
.InterceptMethod(f => f.Go())
.OnBefore(() => Assert.Equal(0, ack))
.OnAfter(() => ack++);
proxy
.InterceptGetter(f => f.Name)
.OnBefore(() => Assert.Equal(1, ack))
.OnAfter(() => ack++);
proxy
.InterceptSetter(f => f.Description)
.OnBefore(() => Assert.Equal(2, ack))
.OnAfter(() => ack++);
var foo = proxy.Save();
// intercepted
foo.Go();
var name = foo.Name;
foo.Description = string.Empty;
// not intercepted
foo.Return();
foo.Name = string.Empty;
var desc = foo.Description;
Assert.Equal(3, ack);
}