Beispiel #1
0
        internal static void ExpectMembersInReport(ListReport messagesReport, string path, IReadOnlyCollection <string> expectedMembers)
        {
            Assert.NotNull(messagesReport);

            var pathParts = path == string.Empty ? Enumerable.Empty <string>() : path.Split('.');

            var reportLines = messagesReport.Where(item => (path == string.Empty) || (item.StartsWith(path) && item.Contains(':'))).ToArray();

            reportLines = reportLines
                          .Where(item => item.Contains(':'))
                          .Select(item => item.Substring(0, item.IndexOf(':')))
                          .ToArray();

            var groups = reportLines.Select(item => item.Split('.')).ToArray();

            groups = groups.Where(g => g.Count() >= (pathParts.Count() + 1)).ToArray();

            var members = groups.Select(g => g.ElementAt(pathParts.Count())).Distinct().ToArray();

            Assert.Equal(expectedMembers.Count(), members.Length);

            for (var i = 0; i < expectedMembers.Count(); ++i)
            {
                Assert.Equal(expectedMembers.ElementAt(i), members.ElementAt(i));
            }
        }
Beispiel #2
0
        internal static void ExpectMessagesInReport(ListReport messagesReport, string path, IReadOnlyCollection <string> expectedMessages)
        {
            Assert.NotNull(messagesReport);

            var messages = string.IsNullOrEmpty(path)
                ? messagesReport
                           .Where(item => !item.Contains(':'))
                           .ToArray()
                : messagesReport
                           .Where(item => item.StartsWith($"{path}:"))
                           .Select(item => item.Split(": ", StringSplitOptions.RemoveEmptyEntries).ElementAtOrDefault(1))
                           .ToArray();

            Assert.Equal(expectedMessages.Count(), messages.Count());

            for (var i = 0; i < expectedMessages.Count(); ++i)
            {
                Assert.Equal(expectedMessages.ElementAt(i), messages.ElementAt(i));
            }
        }