예제 #1
0
        public async Task CreateAsync_NoteReminder()
        {
            var update = new NoteReminderUpdateModel();

            update.Name = "test";

            var identity = new NoteReminderIdentityModel(0);

            var expected = new NoteReminder();

            expected.Name = "test";

            //mock
            var noteDataAccess = new Mock <IDataAccessor <NoteReminder, INoteReminderIdentity, NoteReminderUpdateModel> >();

            noteDataAccess.Setup(x => x.InsertAsync(update)).ReturnsAsync(expected);

            //setup
            var noteServices = new NoteReminderServices(noteDataAccess.Object);
            //action
            var result = await noteServices.CreateAsync(update);

            //result
            result.Should().Be(expected);
        }
예제 #2
0
        public async Task UpdateAsync_NoteReminder()
        {
            var initial = new NoteReminder();

            initial.Name = "test";
            initial.Date = DateTime.Now;
            initial.Text = "initial";

            var update = new NoteReminderUpdateModel();

            update.Name = "test2";
            update.Date = DateTime.Today;
            update.Text = "update";

            var identity = new NoteReminderIdentityModel(0);

            var expected = new NoteReminder();

            expected.Name = "test2";
            expected.Date = DateTime.Today;
            expected.Text = "update";
            //mock
            var noteDataAccess = new Mock <IDataAccessor <NoteReminder, INoteReminderIdentity, NoteReminderUpdateModel> >();

            noteDataAccess.Setup(x => x.InsertAsync(update)).ReturnsAsync(initial);
            noteDataAccess.Setup(x => x.UpdateAsync(identity, update)).ReturnsAsync(expected);
            //setup
            var noteServices = new NoteReminderServices(noteDataAccess.Object);
            //action
            await noteServices.CreateAsync(update);

            var result = await noteServices.UpdateAsync(identity, update);

            //result
            result.Should().Be(expected);
        }