예제 #1
0
        private HashSet <byte[]> InitHashSet()
        {
            var    res   = new HashSet <byte[]>(ByteArrayComparer.Instance);
            string query = $"SELECT [Hash] FROM [{_tableName}]";

            foreach (BaseHashStorage item in _dataProvider.Enumerate <BaseHashStorage>(query))
            {
                res.Add(item.Hash);
            }
            return(res);
        }
예제 #2
0
        public void ReadDeadlocksEvents(ISimpleDataProvider dataProvider, ILogger <ExtendedEventParser> logger)
        {
            dataProvider.Enumerate <XmlRow>(Arg.Any <string>(), Arg.Any <object>()).Returns(ReadXmlLines("deadlockData.json"));
            var p      = new ExtendedEventParser(dataProvider, logger);
            var events = p.ReadDeadLockEvents("someFile");
            var result = events.ToList();

            result.Should().NotBeEmpty();
            result.Any(r => string.IsNullOrWhiteSpace(r.QueryA)).Should().BeFalse();
            result.Any(r => string.IsNullOrWhiteSpace(r.QueryB)).Should().BeFalse();
            result.Any(r => r.TimeStamp == DateTime.MinValue).Should().BeFalse();
            result.Any(r => !string.IsNullOrWhiteSpace(r.ObjectAName) && !string.IsNullOrWhiteSpace(r.ObjectBName)).Should().BeTrue();
        }
예제 #3
0
        public void ReadLongLockEvents(ISimpleDataProvider dataProvider, ILogger <ExtendedEventParser> logger)
        {
            dataProvider.Enumerate <XmlRow>(Arg.Any <string>(), Arg.Any <object>()).Returns(ReadXmlLines("data.json"));
            var p      = new ExtendedEventParser(dataProvider, logger);
            var events = p.ReadLongLockEvents("someFile");
            var result = events.ToList();

            result.Should().NotBeEmpty();
            result.Any(r => string.IsNullOrWhiteSpace(r.Blocker.Text)).Should().BeFalse();
            result.Any(r => string.IsNullOrWhiteSpace(r.Blocked.Text)).Should().BeFalse();
            result.Any(r => r.Duration == 0).Should().BeFalse();
            result.Any(r => !string.IsNullOrWhiteSpace(r.DatabaseName)).Should().BeTrue();
        }
예제 #4
0
        private IEnumerable <XmlRow> ReadEventData(string file)
        {
            var query = @"SELECT CAST(event_data AS XML) XML FROM sys.fn_xe_file_target_read_file(@fileName, NULL, NULL, NULL)";

            return(_simpleDataProvider.Enumerate <XmlRow>(query, new { fileName = file }));
        }