public async Task AddShortNamesAsyncTest() { var names = fixture.CreateMany <string>(); _nameCacheRepositoryMock.Setup(x => x.AddNamesAsync( It.IsAny <NameCacheEntityType>(), It.IsAny <IEnumerable <string> >())) .Returns(Task.FromResult(0)); await _nameCacheLogic.AddShortNamesAsync(NameCacheEntityType.Tag, names); _nameCacheRepositoryMock.Verify(x => x.AddNamesAsync( NameCacheEntityType.Tag, It.Is <IEnumerable <string> >(args => args.SequenceEqual(names.Select(s => $"{_nameCacheLogic.PREFIX_TAGS}{s}"))))); await _nameCacheLogic.AddShortNamesAsync(NameCacheEntityType.DesiredProperty, names); _nameCacheRepositoryMock.Verify(x => x.AddNamesAsync( NameCacheEntityType.DesiredProperty, It.Is <IEnumerable <string> >(args => args.SequenceEqual(names.Select(s => $"{_nameCacheLogic.PREFIX_DESIRED}{s}"))))); await _nameCacheLogic.AddShortNamesAsync(NameCacheEntityType.ReportedProperty, names); _nameCacheRepositoryMock.Verify(x => x.AddNamesAsync( NameCacheEntityType.ReportedProperty, It.Is <IEnumerable <string> >(args => args.SequenceEqual(names.Select(s => $"{_nameCacheLogic.PREFIX_REPORTED}{s}"))))); }
private void UpdateNameCache(IEnumerable <Shared.Twin> twins) { // Reminder: None of the tasks updating the namecache need to be waited for completed var tags = twins.GetNameList(twin => twin.Tags); var tagTask = _nameCacheLogic.AddShortNamesAsync(NameCacheEntityType.Tag, tags); var desiredProperties = twins.GetNameList(twin => twin.Properties.Desired); var desiredPropertyTask = _nameCacheLogic.AddShortNamesAsync(NameCacheEntityType.DesiredProperty, desiredProperties); var reportedProperties = twins.GetNameList(twin => twin.Properties.Reported) .Where(name => !SupportedMethodsHelper.IsSupportedMethodProperty(name)); var reportedPropertyTask = _nameCacheLogic.AddShortNamesAsync(NameCacheEntityType.ReportedProperty, reportedProperties); // No need to update Method here, since it will not change during device running }