Exemplo n.º 1
0
        public void GetAllEmails_Action_Fails()
        {
            // Arrange
            GenericServiceResponse <IEnumerable <EmailDto> > fakeResponse = null;

            mockClientServicesProvider.Setup(x => x.Logger).Returns(mockLogger.Object).Verifiable();
            mockClientServicesProvider.Setup(x => x.EmailService.GetAllEmails()).Returns(fakeResponse).Verifiable();

            var viewModel = new GenericListViewModel <EmailDto>();

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

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

            // Assert
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(GenericListViewModel <EmailDto>));
            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 <EmailDto>));
            Assert.IsTrue(result.Items.ToList().Count() == 0);
        }
Exemplo n.º 2
0
 public object Get(GetAllEmails request)
 {
     return(WithDb(db => Logic.GetAll()));
 }
Exemplo n.º 3
0
 public async Task <List <EmailModel> > Handle(GetAllEmails request, CancellationToken cancellationToken)
 {
     return(await emailsRepository.GetEmails(cancellationToken));
 }