Ejemplo n.º 1
0
        public void CanCreateNewNoteMessage()
        {
            // ARRANGE

            // ACT
            var subjectUnderTest = new NewNoteMessage();

            // ASSERT
            Assert.That(subjectUnderTest, Is.TypeOf(typeof(NewNoteMessage)));
        }
Ejemplo n.º 2
0
        //
        // Work with notes with regard for categories.
        // In esseence these notes will be stored in the context of default category.

        public NoteDto TakeNote(SecurityContext securityContext, NewNoteMessage newNoteMessage)
        {
            var category = GetDefaultCategory();

            var note = category.AddNote(newNoteMessage.Text);

            _categoryRepository.Save(category);

            return(_mapper.Map <NoteDto>(note));
        }
Ejemplo n.º 3
0
        public void CanSetText()
        {
            // ARRANGE
            var expectedText     = "Don't to forget to pick up bread from the grocery store.";
            var subjectUnderTest = new NewNoteMessage();

            // ACT
            subjectUnderTest.Text = expectedText;

            // ASSERT
            Assert.That(subjectUnderTest.Text, Is.EqualTo(expectedText));
        }
        public NoteDto TakeCategorizedNote(Guid categoryId, NewNoteMessage newNoteMessage)
        {
            if (newNoteMessage == null)
            {
                throw new ArgumentNullException(nameof(newNoteMessage));
            }

            var category = GetCategory(categoryId);

            var note = category.AddNote(newNoteMessage.Text);

            _categoryRepository.Save(category);

            return(_mapper.Map <NoteDto>(note));
        }
Ejemplo n.º 5
0
        public IActionResult CreateNoteInCategory(Guid id, [FromBody] NewNoteMessage newNoteMessage)
        {
            var noteDto = _noteTaker.TakeCategorizedNote(SecurityContext, id, newNoteMessage);

            return(CreatedAtRoute("ReadCategorizedNote", new { noteId = noteDto.Id }, noteDto));
        }
        public IActionResult Post([FromBody] NewNoteMessage newNoteMessage)
        {
            var noteDto = _noteTaker.TakeNote(SecurityContext, newNoteMessage);

            return(CreatedAtRoute("GetNote", new { id = noteDto.Id }, noteDto));
        }
Ejemplo n.º 7
0
 public void AddNote(NewNoteMessage message)
 {
     _notesService.AddNote(message.NewNote);
     RaisePropertyChanged(() => Notes);
 }