Exemple #1
0
        public void NonAggregatableActionsReturnFalse()
        {
            var action1 = new ActionPropertyBag(_errorStore);
            var action2 = new ActionPropertyBag(_errorStore);

            Assert.IsFalse(ActionComparer.IsEquivalentClass(action1, action2));
        }
Exemple #2
0
        public void DifferentPropertiesReturnFalse()
        {
            var action1 = new ActionPropertyBag(_errorStore);
            var action2 = new ActionPropertyBag(_errorStore);

            action1.IsAggregable = true;
            action2.IsAggregable = true;
            action1.Add(ActionPropertyNames.TenantIdConstStrKey, "TenantId");

            Assert.IsFalse(ActionComparer.IsEquivalentClass(action1, action2));
        }
Exemple #3
0
        public void SamePropertiesAndValuesReturnEquivalent()
        {
            var action1 = new ActionPropertyBag(_errorStore);
            var action2 = new ActionPropertyBag(_errorStore);

            action1.IsAggregable = true;
            action2.IsAggregable = true;
            action1.Add(ActionPropertyNames.TenantIdConstStrKey, "TenantId1");
            action2.Add(ActionPropertyNames.TenantIdConstStrKey, "TenantId1");

            Assert.IsTrue(ActionComparer.IsEquivalentClass(action1, action2));
        }
        public void ExpectedPropertiesAggregateCorrectly()
        {
            var target = new ActionPropertyBag(_errorStore);
            var child  = new ActionPropertyBag(_errorStore);

            // duration properties and names
            string durationMaxPropertyName = ActionPropertyNames.DurationConstStrKey + ActionPropertyNames.MaxConstStrSuffix;
            string durationMinPropertyName = ActionPropertyNames.DurationConstStrKey + ActionPropertyNames.MinConstStrSuffix;
            string durationSumPropertyName = ActionPropertyNames.DurationConstStrKey + ActionPropertyNames.SumConstStrSuffix;
            long   targetDuration          = 100;
            long   childDuration           = 200;

            // cache event count properties and names
            string cacheEventCountMaxPropertyName = MsalTelemetryBlobEventNames.CacheEventCountConstStrKey + ActionPropertyNames.MaxConstStrSuffix;
            string cacheEventCountMinPropertyName = MsalTelemetryBlobEventNames.CacheEventCountConstStrKey + ActionPropertyNames.MinConstStrSuffix;
            string cacheEventCountSumPropertyName = MsalTelemetryBlobEventNames.CacheEventCountConstStrKey + ActionPropertyNames.SumConstStrSuffix;
            int    targetCacheEventCount          = 100;
            int    childCacheEventCount           = 200;

            int expectedCount = 2;
            int startingCount = 1;

            // Add int64 duration properties and starting counts
            target.Add(durationMaxPropertyName, targetDuration);
            child.Add(durationMaxPropertyName, childDuration);
            target.Add(durationMinPropertyName, targetDuration);
            child.Add(durationMinPropertyName, childDuration);
            target.Add(durationSumPropertyName, targetDuration);
            child.Add(durationSumPropertyName, childDuration);
            target.Add(ActionPropertyNames.CountConstStrKey, startingCount);
            child.Add(ActionPropertyNames.CountConstStrKey, startingCount);

            // Add int32 cache event count properties
            target.Add(cacheEventCountMaxPropertyName, targetCacheEventCount);
            child.Add(cacheEventCountMaxPropertyName, childCacheEventCount);
            target.Add(cacheEventCountMinPropertyName, targetCacheEventCount);
            child.Add(cacheEventCountMinPropertyName, childCacheEventCount);
            target.Add(cacheEventCountSumPropertyName, targetCacheEventCount);
            child.Add(cacheEventCountSumPropertyName, childCacheEventCount);

            ActionAggregator.AggregateActions(target, child);
            var targetContents = target.GetContents();

            Assert.AreEqual(targetContents.Int64Properties[durationMaxPropertyName], childDuration);
            Assert.AreEqual(targetContents.Int64Properties[durationMinPropertyName], targetDuration);
            Assert.AreEqual(targetContents.Int64Properties[durationSumPropertyName], childDuration + targetDuration);
            Assert.AreEqual(targetContents.IntProperties[cacheEventCountMaxPropertyName], childCacheEventCount);
            Assert.AreEqual(targetContents.IntProperties[cacheEventCountMinPropertyName], targetCacheEventCount);
            Assert.AreEqual(targetContents.IntProperties[cacheEventCountSumPropertyName], childCacheEventCount + targetCacheEventCount);
            Assert.AreEqual(targetContents.IntProperties[ActionPropertyNames.CountConstStrKey], expectedCount);
        }
        public void MissingPropertiesDoNotAggregate()
        {
            var    target              = new ActionPropertyBag(_errorStore);
            var    child               = new ActionPropertyBag(_errorStore);
            string basePropertyName    = ActionPropertyNames.DurationConstStrKey;
            string averagePropertyName = ActionPropertyNames.DurationConstStrKey + ActionPropertyNames.AverageConstStrSuffix;
            string maxPropertyName     = ActionPropertyNames.DurationConstStrKey + ActionPropertyNames.MaxConstStrSuffix;
            string minPropertyName     = ActionPropertyNames.DurationConstStrKey + ActionPropertyNames.MinConstStrSuffix;
            string sumPropertyName     = ActionPropertyNames.DurationConstStrKey + ActionPropertyNames.SumConstStrSuffix;

            target.Add(basePropertyName, 100);
            child.Add(basePropertyName, 100);

            ActionAggregator.AggregateActions(target, child);
            var targetContents = target.GetContents();

            Assert.IsFalse(targetContents.IntProperties.ContainsKey(averagePropertyName));
            Assert.IsFalse(targetContents.IntProperties.ContainsKey(maxPropertyName));
            Assert.IsFalse(targetContents.IntProperties.ContainsKey(minPropertyName));
            Assert.IsFalse(targetContents.IntProperties.ContainsKey(sumPropertyName));
        }
 public ActionArtifacts(MatsAction action, ActionPropertyBag propertyBag)
 {
     Action      = action;
     PropertyBag = propertyBag;
 }