public void Collect_BothProjectIdAndCompanyIdHasValue_ThrowsException()
        {
            // Arrange
            var sut = new ForecastMonthSearchCriteriaCollector();

            // Act
            var exception = Assert.Throws <Exception>(() => sut.Collect(new ForecastSearchByRegistrationRequest {
                CompanyId = 1, ProjectId = 2
            }));

            // Assert
            Assert.That(exception.Message, Is.EqualTo("CompanyId and ProjectId search combination does not make sence"));
        }
        public void Collect_ForecastIdHasValue_ResultContainsForcastTypeQueryCriteria()
        {
            // Arrange
            var sut = new ForecastMonthSearchCriteriaCollector();

            // Act
            var result = sut.Collect(new ForecastSearchByRegistrationRequest {
                ForecastTypeId = 1
            });

            // Assert
            Assert.That(result.Single(), Is.InstanceOf <ForcastTypeQueryCriteria>());
        }
        private List <ForecastMonthDto> GetForecastMonths(ForecastSearchByRegistrationRequest request)
        {
            var criterias = _criteriaCollector.Collect(request).ToList();

            // If criterias is empty. Return empty list. We dont want to return the whole table
            if (!criterias.Any())
            {
                return(new List <ForecastMonthDto>());
            }

            var result = _forecastMonthRepository.GetBySearchCriterias(criterias, request.ForecastMonth, request.ForecastYear);

            return(new List <ForecastMonthDto>(result.Select(ForecastMonthToDto)));
        }