private void ReturnResults([NotNull] IEnumerable <ITranslationItem> items, [NotNull] IEnumerable <GetTranslationsResponse> responses)
        {
            Contract.Requires(items != null);
            Contract.Requires(responses != null);

            foreach (var tuple in Enumerate.AsTuples(items, responses))
            {
                Contract.Assume(tuple != null);

                var response = tuple.Item2;
                Contract.Assume(response != null);

                var translationItem = tuple.Item1;
                Contract.Assume(translationItem != null);

                var translations = response.Translations;
                Contract.Assume(translations != null);

                foreach (var match in translations)
                {
                    Contract.Assume(match != null);
                    translationItem.Results.Add(new TranslationMatch(this, match.TranslatedText, match.Rating / 5.0));
                }
            }
        }
Exemple #2
0
        public static void AssertIlStrict(string decompiledSource, string decompiledTarget)
        {
            var expected = decompiledSource.Replace("\r\n", "\n").Split('\n').OrderBy(line => line).SkipWhile(string.IsNullOrWhiteSpace).Where(IsNotBinaryData);
            var target   = decompiledTarget.Replace("\r\n", "\n").Split('\n').OrderBy(line => line).SkipWhile(string.IsNullOrWhiteSpace).Where(IsNotBinaryData);

            var mismatches = Enumerate.AsTuples(expected, target)
                             .Select((tuple, index) => new { tuple.Item1, tuple.Item2, index })
                             .Where(tuple => tuple.Item1 != tuple.Item2)
                             .ToList();

            Assert.Empty(mismatches);
        }