public void OrderByNumberThrowInvalidOperationExceptionWhenOrderNumberPatternIsIncorrect()
        {
            //Arrange

            string orderNumber = "222"; //THIS IS AN INVALID ORDER NUMBER

            //Act
            var spec = OrdersSpecifications.OrdersByNumber(orderNumber);
        }
Esempio n. 2
0
        public void OrderByNumberThrowInvalidOperationExceptionWhenOrderNumberPatternIsIncorrect()
        {
            //Arrange

            string orderNumber = "222"; //THIS IS AN INVALID ORDER NUMBER

            //Act
            Exception ex = Assert.Throws <InvalidOperationException>(() => OrdersSpecifications.OrdersByNumber(orderNumber));

            Assert.IsType(typeof(InvalidOperationException), ex);
        }
Esempio n. 3
0
        public void OrderByNumberReturnDirectSpecificationWhenPatternIsOk()
        {
            //Arrange

            string orderNumber = "2011/12-1212"; //THIS IS AN INVALID ORDER NUMBER

            //Act
            var spec = OrdersSpecifications.OrdersByNumber(orderNumber);

            //Assert
            Assert.IsType <DirectSpecification <Order> >(spec);
        }
        public void OrderByNumberReturnDirectSpecificationWhenPatternIsOk()
        {
            //Arrange

            var orderNumber = "2011/12-1212"; //THIS IS AN INVALID ORDER NUMBER

            //Act
            var spec = OrdersSpecifications.OrdersByNumber(orderNumber);

            //Assert
            Assert.IsInstanceOfType(spec, typeof(DirectSpecification <Order>));
        }
Esempio n. 5
0
        public void OrderFromDateRangeNullEndDateReturnDirectSpecification()
        {
            //Arrange
            DateTime?start = DateTime.Now;
            DateTime?end   = null;

            //Act
            var spec = OrdersSpecifications.OrderFromDateRange(start, end);

            //Assert
            Assert.NotNull(spec);
            Assert.IsType <AndSpecification <Order> >(spec);
        }
Esempio n. 6
0
        public void OrderFromDateRangeNullDatesReturnTrueSpecification()
        {
            //Arrange
            DateTime?start = null;
            DateTime?end   = null;

            //Act
            var spec = OrdersSpecifications.OrderFromDateRange(start, end);

            //Assert
            Assert.NotNull(spec);
            Assert.IsType <TrueSpecification <Order> >(spec);
        }
Esempio n. 7
0
        public void OrderRepositoryAllMatchingMethodReturnEntitiesWithSatisfiedCriteria()
        {
            //Arrange
            var orderRepository = new OrderRepository(fixture.unitOfWork, fixture.orderLogger);

            var spec = OrdersSpecifications.OrderFromDateRange(DateTime.Now.AddDays(-2), DateTime.Now.AddDays(-1));

            //Act
            var result = orderRepository.AllMatching(spec);

            //Assert
            Assert.NotNull(result.All(o => o.OrderDate > DateTime.Now.AddDays(-2) && o.OrderDate < DateTime.Now.AddDays(-1)));
        }
        public void OrderFromDateRangeNullStartDateReturnDirectSpecification()
        {
            //Arrange
            DateTime?start = null;
            DateTime?end   = DateTime.Now;

            //Act
            var spec = OrdersSpecifications.OrderFromDateRange(start, end);

            //Assert
            Assert.IsNotNull(spec);
            Assert.IsInstanceOfType(spec, typeof(AndSpecification <Order>));
        }
Esempio n. 9
0
        /// <summary>
        ///    <see cref="Microsoft.Samples.NLayerApp.Application.MainBoundedContext.ERPModule.Services.ISalesAppService" />
        /// </summary>
        /// <param name="dateFrom">
        ///    <see cref="Microsoft.Samples.NLayerApp.Application.MainBoundedContext.ERPModule.Services.ISalesAppService" />
        /// </param>
        /// <param name="dateTo">
        ///    <see cref="Microsoft.Samples.NLayerApp.Application.MainBoundedContext.ERPModule.Services.ISalesAppService" />
        /// </param>
        /// <returns>
        ///    <see cref="Microsoft.Samples.NLayerApp.Application.MainBoundedContext.ERPModule.Services.ISalesAppService" />
        /// </returns>
        public List <OrderListDto> FindOrders(DateTime?dateFrom, DateTime?dateTo)
        {
            //create the specification ( how to filter orders from dates..)
            var spec = OrdersSpecifications.OrderFromDateRange(dateFrom, dateTo);

            //recover orders
            var orders = _orderRepository.AllMatching(spec);

            if (orders != null && orders.Any())
            {
                return(orders.ProjectedAsCollection <OrderListDto>());
            }
            else //no data
            {
                return(null);
            }
        }