public async Task <UsageStatistics> GetFeatureUsageStatisticsAsync(Guid profileId, string scope) { var knownStats = await GetUserAdditionalDataAsync(profileId, UserDataKeysKnown.KEY_FEATURE_USAGE_STATS); if (!knownStats.Success) { return(null); } return(UsageStatisticsList.Deserialize(knownStats.Result) .FirstOrDefault(s => s.Scope == scope)? .LimitEntries(UsageStatistics.MAX_RETURNED_ENTRIES)); }
public void TestFeatureUsageDeSerialize() { for (var i = 0; i < 100; i++) { var usageStatistics = new UsageStatisticsList(); usageStatistics.SetUsed("onlinevideos", "unit test"); var serialized = UsageStatisticsList.Serialize(usageStatistics); Assert.NotNull(serialized); var deserialized = UsageStatisticsList.Deserialize(serialized); Assert.NotNull(deserialized); Assert.NotNull(deserialized[0].Scope); Assert.AreEqual(1, deserialized[0].TopUsed.Count); Assert.AreEqual(1, deserialized[0].LastUsed.Count); } }