Ejemplo n.º 1
0
        private static bool ContainsSearchValue(DreamEntry entry, string searchFor)
        {
            var literalWords = GetQuotedExpressionsForLiteralSearch(searchFor);
            var searchForWithoutQuotedExpressions = RemoveQuotedExpressions(searchFor, literalWords);
            var unquotedWords = GetUnquotedWords(searchForWithoutQuotedExpressions);

            return(literalWords.Any(entry.DreamTextContains) || unquotedWords.Any(entry.DreamTextContains));
        }
Ejemplo n.º 2
0
        public void FromExistingEntry_copies_text_date_tags()
        {
            var entry           = new DreamEntry(new DateTime(2019, 2, 20), "Beach", "Hello");
            var entityUnderTest = DreamEntryViewModel.FromExistingEntry(entry);

            entityUnderTest.DreamText.Should().Be("Hello");
            entityUnderTest.Tags.Should().Be("Beach");
            entityUnderTest.DreamDate.Should().Be(new DateTime(2019, 2, 20));
        }
Ejemplo n.º 3
0
 private EntryViewerModel([NotNull] DreamEntry entry, int entryNumber, [NotNull] IDreamDiaryBus bus)
 {
     _entry         = entry ?? throw new ArgumentNullException(nameof(entry));
     _entryNumber   = entryNumber;
     _dreamDiaryBus = bus ?? throw new ArgumentNullException(nameof(bus));
     DreamDate      = entry.Date.ToShortDateString();
     DreamText      = entry.Text;
     DreamTags      = entry.GetTagString();
 }
Ejemplo n.º 4
0
 public FrmDreamEntry(DreamEntry editEntry, IList <TagStatistic> tagStatistics)
 {
     InitializeComponent();
     SetUpForm();
     _tagStatistics           = tagStatistics;
     _viewModel               = DreamEntryViewModel.FromExistingEntry(editEntry);
     BindingSource.DataSource = _viewModel;
     CmdSave.Click           -= AddEntryButton_Click;
     CmdSave.Click           += SaveEdit;
     _editEntry               = editEntry;
     LoadEditEntry();
 }
Ejemplo n.º 5
0
        public void Count_when_two_entries_given_is_2()
        {
            var dreamEntryA = new DreamEntry(DateTime.Now, "", "A");
            var dreamEntryB = new DreamEntry(DateTime.Now, "", "B");

            var entityUnderTest = new DreamDayEntry(DateTime.Now, new List <DreamEntry>
            {
                dreamEntryA, dreamEntryB
            });

            entityUnderTest.Count.Should().Be(2);
        }
Ejemplo n.º 6
0
 // Why make this a static method? Because I'm initializing EntryViewerModel from another entity (i.e. DreamEntry)
 // even if the constructor, for convenience, is going to take the same parameters, I prefer to hide this fact from callers.
 // The method makes it clear we're doing some work behind the scenes to set the properties of EntityViewerModel
 // from another object. This would not be clear from the constructor
 // If at some point I have the need to provide the properties myself, then I will make a public constructor for that
 public static EntryViewerModel FromEntry([NotNull] DreamEntry entry, int entryNumber,
                                          [NotNull] IDreamDiaryBus dreamDiaryBus)
 {
     if (entry == null)
     {
         throw new ArgumentNullException(nameof(entry));
     }
     if (dreamDiaryBus == null)
     {
         throw new ArgumentNullException(nameof(dreamDiaryBus));
     }
     return(new EntryViewerModel(entry, entryNumber, dreamDiaryBus));
 }
Ejemplo n.º 7
0
        public void Count_when_entry_marked_for_deletion_is_decreased()
        {
            var dreamEntryA = new DreamEntry(DateTime.Now, "", "A");
            var dreamEntryB = new DreamEntry(DateTime.Now, "", "B");

            var entityUnderTest = new DreamDayEntry(DateTime.Now, new List <DreamEntry>
            {
                dreamEntryA, dreamEntryB
            });

            entityUnderTest.Count.Should().Be(2);
            dreamEntryB.ToDelete = true;
            entityUnderTest.Count.Should().Be(1);
        }
Ejemplo n.º 8
0
        public void Constructor_strips_time_from_DreamDate()
        {
            var entityUnderTest = new DreamEntry(new DateTime(2019, 2, 16, 12, 56, 23), "hello", "");

            entityUnderTest.Date.Should().Be(new DateTime(2019, 2, 16));
        }
Ejemplo n.º 9
0
        public bool ContainsTagOrChildTag_cases(string tags, string searchedForTag)
        {
            var entityUnderTest = new DreamEntry(new DateTime(2019, 3, 10), tags, "h");

            return(entityUnderTest.ContainsTagOrChildTag(searchedForTag));
        }
Ejemplo n.º 10
0
 private static bool DreamContainsAnyTag(DreamEntry entry, IEnumerable <string> tags)
 {
     return(tags.Any(tag => entry.ContainsTagOrChildTag(tag.Trim())));
 }