private static bool ReferenceCompare(BibleReferenceRange x, BibleReferenceRange y) { return (x.StartBook == y.StartBook && x.StartChapter == y.StartChapter && x.StartVerse == y.StartVerse && x.EndBook == y.EndBook && x.EndChapter == y.EndChapter && x.EndVerse == y.EndVerse); }
public void CompareRangeToNull() { var range = new BibleReferenceRange { First = new BibleReference { Book = BibleBook.Genesis } }; Assert.AreEqual(1, range.CompareTo(null)); }
public void EqualsRangeToNullIsFalse() { var rangeA = new BibleReferenceRange { First = new BibleReference { Book = BibleBook.Genesis } }; Assert.IsFalse(rangeA.Equals(null)); }
public void IsValidBibleReferenceRangeInvalidReferenceWithNoEndReference() { var refA = new BibleReference { Book = BibleBook.Exodus, Chapter = 40, Verse = 0 }; var range = new BibleReferenceRange { First = refA }; Assert.IsFalse(BibleDetails.IsValidBibleReferenceRange(range)); }
public void ToFriendlyStringFirstBookChapterLastNull() { var range = new BibleReferenceRange { First = new BibleReference { Book = BibleBook.Genesis, Chapter = 2 }, Last = null }; Assert.AreEqual("Genesis 2", range.ToFriendlyString()); }
public void ToFriendlyStringPartialBookAtStartChapterVerse() { var range = new BibleReferenceRange { First = new BibleReference { Book = BibleBook.Genesis, Chapter = 1, Verse = 1 }, Last = new BibleReference { Book = BibleBook.Genesis, Chapter = 40, Verse = 3 } }; Assert.AreEqual("Genesis 1-40:3", range.ToFriendlyString()); }
public void IsValidBibleReferenceRangeValidReferenceToInvalidReference() { var refA = new BibleReference { Book = BibleBook.Exodus, Chapter = 40, Verse = 1 }; var refB = new BibleReference { Book = BibleBook.Exodus, Chapter = 40, Verse = 39 }; var range = new BibleReferenceRange { First = refA, Last = refB }; Assert.IsFalse(BibleDetails.IsValidBibleReferenceRange(range)); }
public void ToFriendlyStringBookChapterVerseToBookChapterVerse() { var range = new BibleReferenceRange { First = new BibleReference { Book = BibleBook.Genesis, Chapter = 4, Verse = 5 }, Last = new BibleReference { Book = BibleBook.Exodus, Chapter = 2, Verse = 3 } }; Assert.AreEqual("Genesis 4:5-Exodus 2:3", range.ToFriendlyString()); }
public void ToFriendlyStringBookChapterToBookChapter() { var range = new BibleReferenceRange { First = new BibleReference { Book = BibleBook.Genesis, Chapter = 4 }, Last = new BibleReference { Book = BibleBook.Exodus, Chapter = 2 } }; Assert.AreEqual("Genesis 4-Exodus 2", range.ToFriendlyString()); }
public void ToFriendlyStringBookToBook() { var range = new BibleReferenceRange { First = new BibleReference { Book = BibleBook.Genesis }, Last = new BibleReference { Book = BibleBook.Exodus } }; Assert.AreEqual("Genesis-Exodus", range.ToFriendlyString()); }
public void ToFriendlyStringFullBookChapterVerse() { var range = new BibleReferenceRange { First = new BibleReference { Book = BibleBook.Genesis, Chapter = 1, Verse = 1 }, Last = new BibleReference { Book = BibleBook.Genesis, Chapter = 50, Verse = 26 } }; Assert.AreEqual("Genesis", range.ToFriendlyString()); }
public void ToFriendlyStringPartialBookAtEndChapterVerse() { var range = new BibleReferenceRange { First = new BibleReference { Book = BibleBook.Genesis, Chapter = 40, Verse = 2 }, Last = new BibleReference { Book = BibleBook.Genesis, Chapter = 50, Verse = 26 } }; Assert.AreEqual("Genesis 40:2-50:26", range.ToFriendlyString()); }
public void IsValidBibleReferenceRangeValidReferenceToEarlierValidReference() { var refA = new BibleReference { Book = BibleBook.Deuteronomy }; var refB = new BibleReference { Book = BibleBook.Genesis }; var range = new BibleReferenceRange { First = refA, Last = refB }; Assert.IsFalse(BibleDetails.IsValidBibleReferenceRange(range)); }
public void ToFriendlyStringChapterToFullChapter() { var range = new BibleReferenceRange { First = new BibleReference { Book = BibleBook.Genesis, Chapter = 1 }, Last = new BibleReference { Book = BibleBook.Genesis, Chapter = 3, Verse = 24 } }; Assert.AreEqual("Genesis 1-3", range.ToFriendlyString()); }
public void ToFriendlyStringPartialChapterAtEnd() { var range = new BibleReferenceRange { First = new BibleReference { Book = BibleBook.Genesis, Chapter = 1, Verse = 26 }, Last = new BibleReference { Book = BibleBook.Genesis, Chapter = 1, Verse = 31 } }; Assert.AreEqual("Genesis 1:26-31", range.ToFriendlyString()); }
public void ToFriendlyStringPartialChapterAtStart() { var range = new BibleReferenceRange { First = new BibleReference { Book = BibleBook.Genesis, Chapter = 1, Verse = 1 }, Last = new BibleReference { Book = BibleBook.Genesis, Chapter = 1, Verse = 5 } }; Assert.AreEqual("Genesis 1:1-5", range.ToFriendlyString()); }
public void EqualsRangeToRangeIsTrue() { var rangeA = new BibleReferenceRange { First = new BibleReference { Book = BibleBook.Genesis } }; var rangeB = new BibleReferenceRange { First = new BibleReference { Book = BibleBook.Genesis } }; Assert.IsTrue(rangeA.Equals(rangeB)); }
public void CompareEqualRangeToRange() { var rangeA = new BibleReferenceRange { First = new BibleReference { Book = BibleBook.Genesis } }; var rangeB = new BibleReferenceRange { First = new BibleReference { Book = BibleBook.Genesis } }; Assert.AreEqual(0, rangeA.CompareTo(rangeB)); }
public void CompareGreaterRangeToRange() { var rangeA = new BibleReferenceRange { First = new BibleReference { Book = BibleBook.Revelation } }; var rangeB = new BibleReferenceRange { First = new BibleReference { Book = BibleBook.Genesis } }; Assert.AreEqual(1, rangeA.CompareTo(rangeB)); }
IQueryable <Message> FindByBibleReference(string searchString) { var validationResult = BibleReferenceValidation.Validate(searchString); var messages = GetNoMessages(); if (validationResult != ValidationResult.Success) { ViewData["SearchErrorMessage"] = validationResult.ErrorMessage; return(messages); } var bibleReferences = Parser.TryParse(searchString); if (bibleReferences != null && bibleReferences.Count == 1) { // x1 <= y2 && y1 <= x2 var x = BibleReferenceRange.From(bibleReferences[0].GetExplicitRange()); var matchingReferences = from y in _context.BibleReferences where ( (x.StartBook < y.EndBook) || (x.StartBook == y.EndBook && x.StartChapter < y.EndChapter) || (x.StartBook == y.EndBook && x.StartChapter == y.EndChapter && x.StartVerse <= y.EndVerse) ) && ( (y.StartBook < x.EndBook) || (y.StartBook == x.EndBook && y.StartChapter < x.EndChapter) || (y.StartBook == x.EndBook && y.StartChapter == x.EndChapter && y.StartVerse <= x.EndVerse) ) select y; messages = GetAllMessages() .Join(matchingReferences, m => m.Id, r => r.MessageId, (m, r) => m); foreach (var reference in matchingReferences) { MatchingBibleReferences.Add(reference.ToFriendlyString()); } } return(messages); }