public void NoteAutoMap_ViewModelToEntity_SuccessfulMapping()
        {
            NoteViewModel viewModel = NoteMockData.GetNoteViewModel();
            Note          note      = Mapper.Map <NoteViewModel, Note>(viewModel);

            Assert.AreEqual(note.Id, viewModel.NoteId);
            Assert.AreEqual(note.Details, viewModel.NoteDetails);
            Assert.AreEqual(note.Contacts.Count, viewModel.Contacts.Count());
        }
        public void UpdateNote_ValidNote_Succeed()
        {
            NoteViewModel noteViewModel = NoteMockData.GetNoteViewModel();

            mockNoteRepository.Setup(a => a.Update(new Note()));
            UpdateNoteResponse response = noteService.UpdateNote(new UpdateNoteRequest()
            {
                NoteViewModel = noteViewModel
            });

            mockRepository.VerifyAll();
        }
        public void UpdateNote_InValidNote_Failed()
        {
            NoteViewModel noteViewModel = NoteMockData.GetNoteViewModel();

            mockNoteRepository.Setup(a => a.Update(new Note())).Throws(new NullReferenceException());
            UpdateNoteResponse response = noteService.UpdateNote(new UpdateNoteRequest()
            {
                NoteViewModel = noteViewModel
            });

            mockRepository.VerifyAll();
            Assert.AreEqual(typeof(NullReferenceException), response.Exception.GetType());
            Assert.AreNotEqual(null, response.Exception);
        }
        public void InsertNote_RunTimeException_ExceptionDetails()
        {
            NoteViewModel noteViewModel = NoteMockData.GetNoteViewModel();

            mockNoteRepository.Setup(c => c.Insert(new Note())).Throws(new NullReferenceException());
            SaveNoteResponse response = noteService.InsertNote(new SaveNoteRequest()
            {
                NoteViewModel = noteViewModel
            });

            mockNoteRepository.VerifyAll();
            Assert.AreEqual(typeof(NullReferenceException), response.Exception.GetType());
            Assert.AreNotEqual(null, response.Exception);
        }
        public void InsertNote_ValidNote_Succeed()
        {
            NoteViewModel viewModel = NoteMockData.GetNoteViewModel();

            //var mockNote = NoteMockData.CreateMockNote(mockRepository, 0);
            mockNoteRepository.Setup(mnt => mnt.Insert(It.IsAny <Note>())).Verifiable("Error ocuured calling repository method");

            SaveNoteResponse response = noteService.InsertNote(new SaveNoteRequest()
            {
                NoteViewModel = viewModel
            });

            mockRepository.VerifyAll();
        }
Exemple #6
0
        public void GetNote_ValidNote_Successful()
        {
            var mockNotes = NoteMockData.CreateMockNote(mockRepository, 5);

            mockNoteRepository.Setup(c => c.FindBy(It.IsAny <int>(), It.IsAny <int>())).Returns(mockNotes.Object);

            GetNoteResponse response = noteService.GetNote(new GetNoteRequest()
            {
                ContactId = 4, NoteId = 5
            });

            mockRepository.VerifyAll();
            Assert.AreEqual(mockNotes.Object.Id, response.NoteViewModel.NoteId);
        }
        public void InsertNote_InValidNote_Exception()
        {
            NoteViewModel noteViewModel = NoteMockData.GetNoteViewModel();

            //noteViewModel.Contacts = null;
            mockNoteRepository.Setup(a => a.Insert(new Note())).Throws(new ArgumentNullException());
            SaveNoteResponse response = noteService.InsertNote(new SaveNoteRequest()
            {
                NoteViewModel = noteViewModel
            });

            mockRepository.Verify();
            Assert.AreEqual(typeof(ArgumentNullException), response.Exception.GetType());
            Assert.AreNotEqual(null, response.Exception);
        }
        public void GetNote_ValidNote_Successful()
        {
            var mockNotes = NoteMockData.GetMockNotes(mockRepository, 5).ToList();

            mockNoteRepository.Setup(c => c.FindBy(It.IsAny <int>(), It.IsAny <int>(), Account_ID)).Returns(mockNotes[0]);

            GetNoteResponse response = noteService.GetNote(new GetNoteRequest()
            {
                ContactId = CONTACT_ID, NoteId = NOTE_ID, AccountId = Account_ID
            });
            NoteViewModel note = response.NoteViewModel;

            mockRepository.VerifyAll();
            Assert.AreEqual(0, note.NoteId);
            Assert.AreEqual(null, response.Exception);
        }
        public void GetNotesContacts_GetNotes_Succeed()
        {
            var mockNotes = NoteMockData.GetMockNotes(mockRepository, 10).ToList();

            mockNoteRepository.Setup(c => c.FindByContact(It.IsAny <int>(), Account_ID)).Returns(mockNotes);

            GetNotesListResponse response = noteService.GetNotesContacts(new GetNotesListRequest()
            {
                Id = NOTE_ID, AccountId = Account_ID
            });
            IEnumerable <NoteViewModel> notes = response.NotesListViewModel;

            mockRepository.VerifyAll();
            Assert.AreEqual(mockNotes.Count(), notes.Count());
            Assert.AreEqual(null, response.Exception);
        }