예제 #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());
        }
예제 #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();
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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());
        }
예제 #8
0
        public void GetContactActions_ValidRequest_Succeed()
        {
            var mockActions = ActionMockData.GetMockActions(mockRepository, 10).ToList();

            mockActionRepository.Setup(cr => cr.FindByContact(It.IsAny <int>())).Returns(mockActions);

            GetActionListResponse response = actionService.GetContactActions(new GetActionListRequest()
            {
                Id = ACTION_ID
            });
            IEnumerable <ActionViewModel> actions = response.ActionListViewModel;

            mockRepository.VerifyAll();
            Assert.AreEqual(mockActions.Count(), actions.Count());
            Assert.AreEqual(null, response.Exception);
        }      //Problem with automapper if we use strict mock
예제 #9
0
        public void GetAction_ValidRequest_Succeed()
        {
            var mockActions = ActionMockData.GetMockActions(mockRepository, 10).ToList();

            mockActionRepository.Setup(cr => cr.FindBy(It.IsAny <int>(), It.IsAny <int>())).Returns(mockActions[0]);

            GetActionResponse response = actionService.GetAction(new GetActionRequest()
            {
                Id = ACTION_ID, ContactId = CONTACT_ID
            });
            ActionViewModel action = response.ActionViewModel;

            mockRepository.VerifyAll();
            Assert.AreEqual(0, action.ActionId);
            Assert.AreEqual(null, response.Exception);
        }         //Problem with automapper if we use strict mock
예제 #10
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);
        }