예제 #1
0
        public async Task WhenSaving_ThenStoreDraftAndContent()
        {
            const string body = "this is the content of the draft";

            var draft = new Draft
            {
                Uri        = new Uri("http://some.website.com/entry.html"),
                Title      = "The title",
                Paragraphs = new [] { "paragraph1", "paragraph2" },
                Picture    = new Uri("http://some.website.com/img1.png"),
                Tags       = new [] { "tag1", "tag2" },
                User       = new User
                {
                    Id       = Guid.NewGuid(),
                    Username = "******"
                }
            };

            _draftRepositoryMock.Setup(m => m.Save(draft)).Returns(Task.CompletedTask);
            _contentRepositoryMock.Setup(m => m.Save(It.IsAny <Content>()))
            .Callback((Content c) =>
            {
                c.Id.Should().Be(draft.Id);
                c.Body.Should().Be(body);
            })
            .Returns(Task.CompletedTask);

            await _draftService.Save(draft, body);

            _draftRepositoryMock.Verify(m => m.Save(draft), Times.Once);
            _contentRepositoryMock.Verify(m => m.Save(It.IsAny <Content>()), Times.Once);
        }
예제 #2
0
 private void FormMain_FormClosed(object sender, FormClosedEventArgs e)
 {
     KeyLogger.Stop();
     if (StaticAssets.StopDateTime <= DateTime.MinValue)
     {
         StaticAssets.StopDateTime = DateTime.Now;
     }
     DraftService.Save(new DraftModel
     {
         StartDateTime = StaticAssets.StartDateTime,
         StopDateTime  = StaticAssets.StopDateTime,
         Duration      = StaticAssets.Duration
     });
 }
예제 #3
0
 private void TimerBackup_Tick(object sender, EventArgs e)
 {
     _backupTimeSpan = _backupTimeSpan.Add(new TimeSpan(0, 0, 0, 1));
     if (!(_backupTimeSpan.TotalMinutes > 10))
     {
         return;
     }
     DraftService.Save(new DraftModel
     {
         StartDateTime = StaticAssets.StartDateTime,
         Duration      = StaticAssets.Duration
     });
     _backupTimeSpan = new TimeSpan(0, 0, 0, 0);
 }
예제 #4
0
 private void ButtonStop_Click(object sender, EventArgs e)
 {
     DisableDeactivateOperation = true;
     if (MessageBox.Show(this, @"Are you sure to stop timer?", @"Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.Yes)
     {
         return;
     }
     StopTimers();
     DraftService.Save(new DraftModel
     {
         StartDateTime = StaticAssets.StartDateTime,
         StopDateTime  = StaticAssets.StopDateTime,
         Duration      = StaticAssets.Duration
     });
 }