public void ParseMetricEvents(string subscriptionId, string appName, string functionName, string eventName, long average, long minimum, long maximum, long count, string data, string runtimeSiteName, string slotName) { _generator.LogFunctionMetricEvent(subscriptionId, appName, functionName, eventName, average, minimum, maximum, count, DateTime.Now, data, runtimeSiteName, slotName); string evt = _events.Single(); string expectedRegex = $"(?<SubscriptionId>[^,]*),(?<AppName>[^,]*),(?<FunctionName>[^,]*),(?<EventName>[^,]*),(?<Average>\\d*),(?<Min>\\d*),(?<Max>\\d*),(?<Count>\\d*),(?<HostVersion>[^,]*),(?<EventTimestamp>[^,]+),\"(?<Data>.*)\",(?<RuntimeSiteName>[^,]*),(?<SlotName>[^,]*),(?<PodName>[^,]*)"; Regex regex = new Regex(expectedRegex); var match = regex.Match(evt); Assert.True(match.Success); Assert.Equal(15, match.Groups.Count); DateTime dt; var groupMatches = match.Groups.Cast <Group>().Select(p => p.Value).Skip(1).ToArray(); Assert.Collection(groupMatches, p => Assert.Equal(subscriptionId, p), p => Assert.Equal(appName, p), p => Assert.Equal(functionName, p), p => Assert.Equal(eventName, p), p => Assert.Equal(average, long.Parse(p)), p => Assert.Equal(minimum, long.Parse(p)), p => Assert.Equal(maximum, long.Parse(p)), p => Assert.Equal(count, long.Parse(p)), p => Assert.Equal(ScriptHost.Version, p), p => Assert.True(DateTime.TryParse(p, out dt)), p => Assert.Equal(data, UnNormalize(p)), p => Assert.Equal(runtimeSiteName, p), p => Assert.Equal(slotName, p), p => Assert.Equal(_podName, p)); }
public void ParseMetricEvents(string subscriptionId, string appName, string functionName, string eventName, long average, long minimum, long maximum, long count, string data, string runtimeSiteName, string slotName) { _generator.LogFunctionMetricEvent(subscriptionId, appName, functionName, eventName, average, minimum, maximum, count, DateTime.Now, data, runtimeSiteName, slotName); string evt = _events.Single(); var jObject = JObject.Parse(evt); Assert.Equal(14, jObject.Properties().Count()); DateTime dt; Assert.Collection(jObject.Properties(), p => Assert.Equal(ScriptConstants.LinuxLogEventStreamName, p.Value), p => Assert.Equal(subscriptionId, p.Value), p => Assert.Equal(appName, p.Value), p => Assert.Equal(functionName, p.Value), p => Assert.Equal(eventName, p.Value), p => Assert.Equal(average, long.Parse(p.Value.ToString())), p => Assert.Equal(minimum, long.Parse(p.Value.ToString())), p => Assert.Equal(maximum, long.Parse(p.Value.ToString())), p => Assert.Equal(count, long.Parse(p.Value.ToString())), p => Assert.Equal(ScriptHost.Version, p.Value), p => Assert.True(DateTime.TryParse(p.Value.ToString(), out dt)), p => Assert.Equal(LinuxEventGenerator.NormalizeString(data), p.Value), p => Assert.Equal(runtimeSiteName, p.Value), p => Assert.Equal(slotName, p.Value)); }