private void AssertConvertToItems(List <SourceWithTranslation> sourcesWithTranslation, List <List <Tuple <int, int> > > ranges) { List <GapsTrainerItem> items = _helper.ConvertToItems(sourcesWithTranslation); Assert.That(items.Count, Is.EqualTo(sourcesWithTranslation.Count)); for (int i = 0; i < sourcesWithTranslation.Count; i++) { GapsTrainerItem item = items[i]; SourceWithTranslation sourceWithTranslation = sourcesWithTranslation[i]; Assert.That(item, Is.Not.Null); Assert.That(item.Id, Is.EqualTo(sourceWithTranslation.Id)); Assert.That(item.Original, Is.EqualTo(sourceWithTranslation.Source)); Assert.That(item.Translation, Is.EqualTo(sourceWithTranslation.Translation)); string textWithGaps = item.TextForUser; Assert.That(textWithGaps, Is.Not.Null); string sourceText = string.Join(" ", sourceWithTranslation.Source.Text.Split(new[] { ' ' }, StringSplitOptions. RemoveEmptyEntries)); Assert.That(textWithGaps.Length, Is.EqualTo(sourceText.Length)); string[] words = textWithGaps.Split(' '); List <Tuple <int, int> > wordRanges = ranges[i]; for (int wordIndex = 0; wordIndex < words.Length; wordIndex++) { string word = words[wordIndex]; Tuple <int, int> range = wordRanges[wordIndex]; AssertWord(word, range.Item1, range.Item2); } } }
private GapsTrainerItem ConvertToGapsItem(ISourceWithTranslation sourceWithTranslation) { var item = new GapsTrainerItem { Id = sourceWithTranslation.Id, TextForUser = GetTextWithGaps(sourceWithTranslation.Source.Text), Original = sourceWithTranslation.Source, Translation = sourceWithTranslation.Translation }; return(item); }