Beispiel #1
0
        public async Task can_add_signed_note_to_database()
        {
            var note = new Note()
            {
                Content     = "A positive note about sam",
                StudentId   = sam.StudentId,
                TeacherId   = jonathan.TeacherId,
                NoteType    = Note.NoteTypes.Positive,
                DateCreated = DateTime.Now
            };

            await studentRepository.AddSignedNoteAsync(sam, note, jonathan.TeacherId);

            var samWithNote = await studentRepository.GetStudentAsync(sam.StudentId);

            samWithNote.Notes.Where(n => n.NoteId == note.NoteId).Count()
            .Should().Be(1);
            samWithNote.Notes.Where(n => n.NoteId == note.NoteId).First()
            .Content.Should().Be(note.Content);
            samWithNote.Notes.Where(n => n.NoteId == note.NoteId).First()
            .StudentId.Should().Be(note.StudentId);
            samWithNote.Notes.Where(n => n.NoteId == note.NoteId).First()
            .TeacherId.Should().Be(note.TeacherId);
            samWithNote.Notes.Where(n => n.NoteId == note.NoteId).First()
            .NoteType.Should().Be(note.NoteType);
            var timedifference = samWithNote.Notes
                                 .Where(n => n.NoteId == note.NoteId)
                                 .First().DateCreated
                                 - note.DateCreated;

            timedifference.Should().BeLessThan(new TimeSpan(2 * TimeSpan.TicksPerSecond));
        }