public async void Get_ShouldReturnNullBecauseRecordNotFound()
        {
            var mock = new ServiceMockFacade <ICustomerCommunicationService, ICustomerCommunicationRepository>();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <CustomerCommunication>(null));
            var service = new CustomerCommunicationService(mock.LoggerMock.Object,
                                                           mock.MediatorMock.Object,
                                                           mock.RepositoryMock.Object,
                                                           mock.ModelValidatorMockFactory.CustomerCommunicationModelValidatorMock.Object,
                                                           mock.DALMapperMockFactory.DALCustomerCommunicationMapperMock);

            ApiCustomerCommunicationServerResponseModel response = await service.Get(default(int));

            response.Should().BeNull();
            mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>()));
        }
        public async void ByEmployeeId_Not_Exists()
        {
            var mock = new ServiceMockFacade <ICustomerCommunicationService, ICustomerCommunicationRepository>();

            mock.RepositoryMock.Setup(x => x.ByEmployeeId(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>())).Returns(Task.FromResult <List <CustomerCommunication> >(new List <CustomerCommunication>()));
            var service = new CustomerCommunicationService(mock.LoggerMock.Object,
                                                           mock.MediatorMock.Object,
                                                           mock.RepositoryMock.Object,
                                                           mock.ModelValidatorMockFactory.CustomerCommunicationModelValidatorMock.Object,
                                                           mock.DALMapperMockFactory.DALCustomerCommunicationMapperMock);

            List <ApiCustomerCommunicationServerResponseModel> response = await service.ByEmployeeId(default(int));

            response.Should().BeEmpty();
            mock.RepositoryMock.Verify(x => x.ByEmployeeId(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>()));
        }
        public async void All_ShouldReturnRecords()
        {
            var mock    = new ServiceMockFacade <ICustomerCommunicationService, ICustomerCommunicationRepository>();
            var records = new List <CustomerCommunication>();

            records.Add(new CustomerCommunication());
            mock.RepositoryMock.Setup(x => x.All(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <string>())).Returns(Task.FromResult(records));
            var service = new CustomerCommunicationService(mock.LoggerMock.Object,
                                                           mock.MediatorMock.Object,
                                                           mock.RepositoryMock.Object,
                                                           mock.ModelValidatorMockFactory.CustomerCommunicationModelValidatorMock.Object,
                                                           mock.DALMapperMockFactory.DALCustomerCommunicationMapperMock);

            List <ApiCustomerCommunicationServerResponseModel> response = await service.All();

            response.Should().HaveCount(1);
            mock.RepositoryMock.Verify(x => x.All(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <string>()));
        }
        public async void Delete_NoErrorsOccurred_ShouldReturnResponse()
        {
            var mock  = new ServiceMockFacade <ICustomerCommunicationService, ICustomerCommunicationRepository>();
            var model = new ApiCustomerCommunicationServerRequestModel();

            mock.RepositoryMock.Setup(x => x.Delete(It.IsAny <int>())).Returns(Task.CompletedTask);
            var service = new CustomerCommunicationService(mock.LoggerMock.Object,
                                                           mock.MediatorMock.Object,
                                                           mock.RepositoryMock.Object,
                                                           mock.ModelValidatorMockFactory.CustomerCommunicationModelValidatorMock.Object,
                                                           mock.DALMapperMockFactory.DALCustomerCommunicationMapperMock);

            ActionResponse response = await service.Delete(default(int));

            response.Should().NotBeNull();
            response.Success.Should().BeTrue();
            mock.RepositoryMock.Verify(x => x.Delete(It.IsAny <int>()));
            mock.ModelValidatorMockFactory.CustomerCommunicationModelValidatorMock.Verify(x => x.ValidateDeleteAsync(It.IsAny <int>()));
            mock.MediatorMock.Verify(x => x.Publish(It.IsAny <CustomerCommunicationDeletedNotification>(), It.IsAny <CancellationToken>()));
        }
        public async void Delete_ErrorsOccurred_ShouldReturnErrorResponse()
        {
            var mock          = new ServiceMockFacade <ICustomerCommunicationService, ICustomerCommunicationRepository>();
            var model         = new ApiCustomerCommunicationServerRequestModel();
            var validatorMock = new Mock <IApiCustomerCommunicationServerRequestModelValidator>();

            validatorMock.Setup(x => x.ValidateDeleteAsync(It.IsAny <int>())).Returns(Task.FromResult(new FluentValidation.Results.ValidationResult(new List <ValidationFailure>()
            {
                new ValidationFailure("text", "test")
            })));
            var service = new CustomerCommunicationService(mock.LoggerMock.Object,
                                                           mock.MediatorMock.Object,
                                                           mock.RepositoryMock.Object,
                                                           validatorMock.Object,
                                                           mock.DALMapperMockFactory.DALCustomerCommunicationMapperMock);

            ActionResponse response = await service.Delete(default(int));

            response.Should().NotBeNull();
            response.Success.Should().BeFalse();
            validatorMock.Verify(x => x.ValidateDeleteAsync(It.IsAny <int>()));
            mock.MediatorMock.Verify(x => x.Publish(It.IsAny <CustomerCommunicationDeletedNotification>(), It.IsAny <CancellationToken>()), Times.Never());
        }