예제 #1
0
        public async void ShouldUpdateANoteSuccessfully()
        {
            // Arrange
            var controller = new HomeController(noteData, noteDataPreparation, fakeHttpContextAccessor);

            var note = new Note
            {
                Title       = "This is updatable",
                Description = "Make sure it is actually updateable. Otherwise this woulud be a pitty",
                DueDate     = DateTime.Parse("30.09.2017"),
                Priority    = 3,
                Finished    = false
            };

            // Add new note to database
            await noteData.AddNoteAsync(note);

            // Get Note from Database again and amend due date
            var dueDate = DateTime.Parse("31.10.2017");

            note = await noteData.GetNoteAsync(note.Id);

            note.DueDate = DateTime.Parse("31.10.2017");

            // Act
            // Update Database with amended Due Date
            await controller.UpdateNote(note);

            // Get Note with updated Due Date from Database;
            var result = await noteData.GetNoteAsync(note.Id);

            // Assert
            Assert.Equal(result, note);
        }