예제 #1
0
        public void GetAllCustomers_Action_Fails()
        {
            // Arrange
            GenericServiceResponse <IEnumerable <CustomerDto> > fakeResponse = null;

            mockClientServicesProvider.Setup(x => x.Logger).Returns(mockLogger.Object).Verifiable();
            mockClientServicesProvider.Setup(x => x.CustomerService.GetAllCustomers()).Returns(fakeResponse).Verifiable();

            var viewModel = new GenericListViewModel <CustomerDto>();

            var action = new GetAllCustomers <GenericListViewModel <CustomerDto> >(mockClientServicesProvider.Object)
            {
                OnComplete = model => viewModel = model
            };

            // Act
            var result = action.Invoke();

            // Assert
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(GenericListViewModel <CustomerDto>));
            Assert.IsNotNull(result.Notifications);
            Assert.IsInstanceOfType(result.Notifications, typeof(NotificationCollection));
            Assert.IsTrue(result.Notifications.Count() == 1);
            Assert.IsTrue(result.HasErrors);
            Assert.IsNotNull(result.Items);
            Assert.IsTrue(result.Items.Count() == 0);
            Assert.IsInstanceOfType(result.Items, typeof(IEnumerable <CustomerDto>));
            Assert.IsTrue(result.Items.ToList().Count() == 0);
        }
예제 #2
0
        protected virtual void OnGetAllCustomers(GetAllCustomersEventArgs args)
        {
            EventHandler <GetAllCustomersEventArgs> temp = GetAllCustomers;

            if (temp != null)
            {
                GetAllCustomers?.Invoke(this, args);
            }
        }