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