当前位置: 首页>>代码示例>>C#>>正文


C# Services.ObserveValue方法代码示例

本文整理汇总了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();
		}
开发者ID:Galad,项目名称:Hanno,代码行数:16,代码来源:SettingsServiceTests.cs

示例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);
		}
开发者ID:Galad,项目名称:Hanno,代码行数:16,代码来源:SettingsServiceTests.cs

示例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);
		}
开发者ID:Galad,项目名称:Hanno,代码行数:17,代码来源:SettingsServiceTests.cs

示例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);
		}
开发者ID:Galad,项目名称:Hanno,代码行数:19,代码来源:SettingsServiceTests.cs


注:本文中的Services.ObserveValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。