Ejemplo n.º 1
0
        public void ActionAutoMap_ViewModelToEntity_SuccessfulMap()
        {
            ActionViewModel viewModel = ActionMockData.GetActionViewModel();

            DA.Action action = Mapper.Map <ActionViewModel, DA.Action>(viewModel);

            Assert.AreEqual(action.Id, viewModel.ActionId);
            Assert.AreEqual(action.Details, viewModel.ActionMessage);
            Assert.AreEqual(action.Contacts.Count, viewModel.Contacts.Count());
        }
Ejemplo n.º 2
0
        public void UpdateAction_ValidAction_Succeed()
        {
            ActionViewModel actionViewModel = ActionMockData.GetActionViewModel();

            mockActionRepository.Setup(a => a.Update(new DA.Action())).Verifiable("Unable to delete Action");
            UpdateActionResponse response = actionService.UpdateAction(new UpdateActionRequest()
            {
                ActionViewModel = actionViewModel
            });

            mockRepository.VerifyAll();
        }
Ejemplo n.º 3
0
        public void ActionStatus_Completed_Succeed()
        {
            ActionViewModel actionViewModel = ActionMockData.GetActionViewModel();

            mockActionRepository.Setup(a => a.ActionCompleted(It.IsAny <int>(), It.IsAny <bool>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <bool>(), It.IsAny <int>(), It.IsAny <DateTime>(), It.IsAny <bool>(), It.IsAny <int>())).Verifiable("Unable to call Actioncompleted method");
            CompletedActionResponse response = actionService.ActionStatus(new CompletedActionRequest()
            {
                actionId = ACTION_ID, contactId = CONTACT_ID, isCompleted = true
            });

            mockRepository.VerifyAll();
            Assert.AreEqual(null, response.Exception);
        }
Ejemplo n.º 4
0
        public void ActionContactsCount_WithContacts_Succeed()
        {
            ActionViewModel actionViewModel = ActionMockData.GetActionViewModel();

            mockActionRepository.Setup(a => a.ContactsCount(It.IsAny <int>())).Returns(It.IsAny <int>());
            GetContactsCountResponse response = actionService.ActionContactsCount(new GetContactsCountRequest()
            {
                Id = ACTION_ID
            });

            mockRepository.VerifyAll();
            Assert.AreEqual(It.IsAny <int>(), response.Count);
            Assert.AreEqual(null, response.Exception);
        }
Ejemplo n.º 5
0
        public void UpdateAction_InValidAction_BrokenRules()
        {
            ActionViewModel actionViewModel = ActionMockData.GetActionViewModel();

            mockActionRepository.Setup(a => a.Update(new DA.Action())).Throws(new NullReferenceException());
            UpdateActionResponse response = actionService.UpdateAction(new UpdateActionRequest()
            {
                ActionViewModel = actionViewModel
            });

            mockRepository.VerifyAll();
            Assert.AreEqual(typeof(NullReferenceException), response.Exception.GetType());
            Assert.AreNotEqual(null, response.Exception);
        }
Ejemplo n.º 6
0
        public void InsertAction_RunTimeException_ExceptionDetails()
        {
            ActionViewModel actionViewModel = ActionMockData.GetActionViewModel();

            mockActionRepository.Setup(a => a.Insert(new DA.Action())).Throws(new NullReferenceException());
            InsertActionResponse response = actionService.InsertAction(new InsertActionRequest()
            {
                ActionViewModel = actionViewModel
            });

            mockRepository.VerifyAll();
            Assert.AreEqual(typeof(NullReferenceException), response.Exception.GetType());
            Assert.AreNotEqual(null, response.Exception);
        }
Ejemplo n.º 7
0
        public void InsertAction_InValidAction_Exception()
        {
            ActionViewModel actionViewModel = ActionMockData.GetActionViewModel();

            mockActionRepository.Setup(a => a.Insert(new DA.Action())).Throws(new ArgumentNullException());
            InsertActionResponse response = actionService.InsertAction(new InsertActionRequest()
            {
                ActionViewModel = actionViewModel
            });

            //response.ActionViewModel.Contacts = null;
            mockRepository.Verify();
            Assert.AreNotEqual(null, response.Exception);
            Assert.AreEqual(typeof(ArgumentNullException), response.Exception.GetType());
        }
Ejemplo n.º 8
0
        public void InsertAction_ValidAction_Succeed()
        {
            ActionViewModel actionViewModel = ActionMockData.GetActionViewModel();

            mockActionRepository.Setup(a => a.Insert(new DA.Action())).Verifiable("Unable to insert Action");
            mockUnitOfWork.Setup(a => a.Commit()).Returns(new DA.Action()
            {
                Id = NEW_ACTION_ID
            });
            InsertActionResponse response = actionService.InsertAction(new InsertActionRequest()
            {
                ActionViewModel = actionViewModel
            });

            mockRepository.VerifyAll();
            Assert.AreEqual(null, response.Exception);
            Assert.AreNotEqual(typeof(ArgumentNullException), response.Exception);
        }