public void OrderByNumberThrowInvalidOperationExceptionWhenOrderNumberPatternIsIncorrect() { //Arrange string orderNumber = "222"; //THIS IS AN INVALID ORDER NUMBER //Act var spec = OrdersSpecifications.OrdersByNumber(orderNumber); }
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); }
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>)); }
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); }
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); }
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>)); }
/// <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); } }