public void DeleteEntity_delegates_persisting_to_bus() { var bus = GetBus(); var entityUnderTest = EntryViewerModel.FromEntry(InitializeTestEntry(), 100, bus); entityUnderTest.DeleteEntry(); bus.Received(1).PersistDiary(); }
public void FromEntry_sets_tags() { var entityUnderTest = EntryViewerModel.FromEntry(InitializeTestEntry(), 100, GetBus()); // Notice the principle of least surprise: this is a side effect of another class (the tag parser) so we need to explain why we get // Tag1 instead of tag1. NSubstitute allows us to use the 'because' argument entityUnderTest.DreamTags.Should() .Be("Tag1, Tag2 (Tag2a)", "The tag parser automatically capitalizes the tags"); }
public void DeleteEntity_marks_entry_for_deletion() { var entry = InitializeTestEntry(); var entityUnderTest = EntryViewerModel.FromEntry(entry, 100, GetBus()); entry.ToDelete.Should().BeFalse(); entityUnderTest.DeleteEntry(); entry.ToDelete.Should().BeTrue(); }
private void LoadDayEntries(DreamDayEntry day) { TableLayoutPanel.Controls.Clear(); var entries = day.DreamEntries; if (!entries.Any()) { return; } TableLayoutPanel.Visible = false; var entryCount = 1; foreach (var entry in entries) { if (entry.ToDelete) { continue; } var newEntry = new CtrEntryViewer(); newEntry.SetViewModel(EntryViewerModel.FromEntry(entry, entryCount++, _dreamDiaryBus)); TableLayoutPanel.Controls.Add(newEntry); } for (var i = 0; i < TableLayoutPanel.RowStyles.Count; i++) { TableLayoutPanel.RowStyles[i].SizeType = SizeType.AutoSize; } try { for (var i = 0; i < TableLayoutPanel.Controls.Count; i++) { for (var j = 0; j < TableLayoutPanel.Controls[i].Controls.Count; j++) { TableLayoutPanel.Controls[i].Controls[j].MouseClick += FocusEntryPanel; for (var k = 0; k < TableLayoutPanel.Controls[i].Controls[j].Controls.Count; k++) { TableLayoutPanel.Controls[i].Controls[j].Controls[k].MouseClick += FocusEntryPanel; for (var l = 0; l < TableLayoutPanel.Controls[i].Controls[j].Controls[k].Controls.Count; l++) { TableLayoutPanel.Controls[i].Controls[j].Controls[k].Controls[l].MouseClick += FocusEntryPanel; //This is the panel where we click on the most } } } } } catch { // ignored } finally { TableLayoutPanel.Visible = true; } }
public void FromEntry_sets_text() { var entityUnderTest = EntryViewerModel.FromEntry(InitializeTestEntry(), 100, GetBus()); entityUnderTest.DreamText.Should().Be("my dream text"); }
public void FromEntry_sets_entry_number() { var entityUnderTest = EntryViewerModel.FromEntry(InitializeTestEntry(), 100, GetBus()); entityUnderTest.EntryNumber.Should().Be("Entry #100"); }
public void FromEntry_sets_date() { var entityUnderTest = EntryViewerModel.FromEntry(InitializeTestEntry(), 100, GetBus()); entityUnderTest.DreamDate.Should().Be("23/02/2018"); }