예제 #1
0
        private void SaveOrUpdate()
        {
            try
            {
                if (Globals.CurrentlyOpenedFile != null)
                {
                    service.Update(new UpdateFileCommand
                    {
                        Id      = Globals.CurrentlyOpenedFile.Id,
                        Author  = Globals.CurrentlyOpenedFile.Author,
                        Content = fileContent.Text,
                        Name    = Globals.CurrentlyOpenedFile.Name
                    });
                    signalr.UnlockFile(JsonConvert.SerializeObject(Globals.CurrentlyOpenedFile));
                }
                else
                {
                    service.Add(new CreateFileCommand
                    {
                        Author  = Globals.Credentials.Email,
                        Content = fileContent.Text,
                        Name    = this.Title
                    });

                    var allNotes = service.Get();
                    Globals.CurrentlyOpenedFile = allNotes.Last();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #2
0
        public void should_update_note()
        {
            var allNotes = service.Get();
            var note = allNotes.First();

            var command = new UpdateFileCommand
            {
                Id = note.Id,
                Author = note.Author,
                Content = note.Content + Environment.NewLine + DateTime.Now.Ticks,
                Name = note.Name
            };

            service.Update(command);

            var updatedNote = service.Get(note.Id);

            Assert.AreEqual(command.Content, updatedNote.Content);
        }