本文整理汇总了C#中IUserService.GetByIdAsync方法的典型用法代码示例。如果您正苦于以下问题:C# IUserService.GetByIdAsync方法的具体用法?C# IUserService.GetByIdAsync怎么用?C# IUserService.GetByIdAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IUserService
的用法示例。
在下文中一共展示了IUserService.GetByIdAsync方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetUp
private AutoResetEvent SetUp(string method, IUserService svc = null)
{
#if DEBUG
if (Debugger.IsAttached)
{
_waitTime = int.MaxValue;
}
#endif
Global.Init();
if (svc == null)
{
svc = Substitute.For<IUserService>();
if (method == nameof(IUserService.GetById))
{
svc.GetById(Arg.Any<Guid>()).Returns(cx => cx.Arg<Guid>());
}
if (method == nameof(IUserService.GetByIdAsync))
{
svc.GetByIdAsync(Arg.Any<Guid>()).Returns(cx => Task.FromResult((object)cx.Arg<Guid>()));
}
}
var builder = new ContainerBuilder();
builder.RegisterModule(new FlatwhiteCoreModule());
builder
.RegisterInstance(svc)
.As<IUserService>()
.EnableInterceptors();
var container = builder.Build();
var proxy = container.Resolve<IUserService>();
_invocation = Substitute.For<_IInvocation>();
_invocation.Arguments.Returns(new object[] { _id });
_invocation.Method.Returns(typeof(IUserService).GetMethod(method, BindingFlags.Instance | BindingFlags.Public));
_invocation.Proxy.Returns(proxy);
var cacheStore = Substitute.For<IAsyncCacheStore>();
var autoResetEvent = new AutoResetEvent(false);
cacheStore.When(x => x.SetAsync(CacheInfo.Key, Arg.Is<object>(obj => _id.Equals(((CacheItem)obj).Data)), Arg.Any<DateTimeOffset>()))
.Do(c => autoResetEvent.Set());
cacheStore.When(x => x.RemoveAsync(CacheInfo.Key))
.Do(c => autoResetEvent.Set());
cacheStore.StoreId.Returns(StoreId);
Global.CacheStoreProvider.RegisterAsyncStore(cacheStore);
return autoResetEvent;
}