コード例 #1
0
 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);
 }
コード例 #2
0
        public void CompareRangeToNull()
        {
            var range = new BibleReferenceRange {
                First = new BibleReference {
                    Book = BibleBook.Genesis
                }
            };

            Assert.AreEqual(1, range.CompareTo(null));
        }
コード例 #3
0
        public void EqualsRangeToNullIsFalse()
        {
            var rangeA = new BibleReferenceRange {
                First = new BibleReference {
                    Book = BibleBook.Genesis
                }
            };

            Assert.IsFalse(rangeA.Equals(null));
        }
コード例 #4
0
        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));
        }
コード例 #5
0
        public void ToFriendlyStringFirstBookChapterLastNull()
        {
            var range = new BibleReferenceRange
            {
                First = new BibleReference {
                    Book = BibleBook.Genesis, Chapter = 2
                },
                Last = null
            };

            Assert.AreEqual("Genesis 2", range.ToFriendlyString());
        }
コード例 #6
0
        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());
        }
コード例 #7
0
        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));
        }
コード例 #8
0
        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());
        }
コード例 #9
0
        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());
        }
コード例 #10
0
        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());
        }
コード例 #11
0
        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());
        }
コード例 #12
0
        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());
        }
コード例 #13
0
        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));
        }
コード例 #14
0
        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());
        }
コード例 #15
0
        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());
        }
コード例 #16
0
        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());
        }
コード例 #17
0
        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));
        }
コード例 #18
0
        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));
        }
コード例 #19
0
        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));
        }
コード例 #20
0
        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);
        }