本文整理汇总了C#中Services.SetValue方法的典型用法代码示例。如果您正苦于以下问题:C# Services.SetValue方法的具体用法?C# Services.SetValue怎么用?C# Services.SetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Services
的用法示例。
在下文中一共展示了Services.SetValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetValue_ShouldCallAddOrUpdate
public async Task SetValue_ShouldCallAddOrUpdate(
[Frozen]ThrowingTestScheduler scheduler,
[Frozen]Mock<IAsyncStorage> table,
Services.SettingsService sut,
string key,
object expected)
{
//arrange
var verifiable = table.Setup(t => t.AddOrUpdate(key, expected, It.IsAny<CancellationToken>())).ReturnsDefaultTaskVerifiable();
//act
await sut.SetValue(key, expected, CancellationToken.None);
//assert
verifiable.Verify();
}
示例2: ObserveValue_WhenCallSet_ShouldReturnValue
public async Task ObserveValue_WhenCallSet_ShouldReturnValue(
[Frozen]ThrowingTestScheduler scheduler,
[Frozen]Mock<IAsyncStorage> table,
Services.SettingsService sut,
string key,
object expected)
{
//arrange
table.Setup(t => t.Contains<string, object>(key, It.IsAny<CancellationToken>())).ReturnsTask(false);
table.Setup(t => t.AddOrUpdate(key, It.IsAny<object>(), It.IsAny<CancellationToken>())).ReturnsDefaultTask();
//act
var observer = scheduler.CreateObserver<object>();
sut.ObserveValue(key, () => default(object)).Skip(1).Subscribe(observer);
await sut.SetValue(key, expected, CancellationToken.None);
//assert
observer.Values().Last().Should().Be(expected);
}