public void GetSaleByClassUseCaseEqualTest() { GetSaleByClassRequest getSaleByClassRequest = new GetSaleByClassRequest(class_, sinceDate, toDate); IRepositoryFactory repositoryFactory = new RepositoryFactory(new DBContext()); IActivityFactory activityFactory = new ActivityFactory(repositoryFactory, new ValidationRuleFactory()); IUseCaseFactory useCaseFactory = new UseCaseFactory(activityFactory); GetSaleByClassResponse getSaleByClassResponse = useCaseFactory.Create <IUseCase <GetSaleByClassRequest, GetSaleByClassResponse> >().Execute(getSaleByClassRequest); Assert.IsTrue(getSaleByClassResponse.Sales.Count > 0); }
public void GetSaleByClassUseCaseNotEqualTest() { Exception exception = null; try { IRepositoryFactory repositoryFactory = new RepositoryFactory(new DBContext()); IActivityFactory activityFactory = new ActivityFactory(repositoryFactory, new ValidationRuleFactory()); IUseCaseFactory useCaseFactory = new UseCaseFactory(activityFactory); GetSaleByClassRequest getSaleByClassRequest = new GetSaleByClassRequest(class_, "", "asd"); GetSaleByClassResponse getSaleByClassResponse = useCaseFactory.Create <IUseCase <GetSaleByClassRequest, GetSaleByClassResponse> >().Execute(getSaleByClassRequest); } catch (Exception ex) { exception = ex; } Assert.AreEqual(exception.Message, "Date must be defined"); }
public async Task <OperationStatusInfo> ShowSalesByClass(Class class_, DateTime sinceDate, DateTime toDate) { return(await Task.Run(() => { OperationStatusInfo operationStatusInfo = new OperationStatusInfo(operationStatus: OperationStatus.Done); GetSaleByClassRequest getSaleByClassRequest = new GetSaleByClassRequest(class_, sinceDate.ToString(), toDate.ToString()); try { GetSaleByClassResponse getSaleByClassResponse = hubEnvironment.UseCaseFactory .Create <IUseCase <GetSaleByClassRequest, GetSaleByClassResponse> >() .Execute(getSaleByClassRequest); operationStatusInfo.AttachedObject = getSaleByClassResponse.Sales; } catch (Exception ex) { Console.WriteLine(ex.Message); operationStatusInfo.OperationStatus = OperationStatus.Cancelled; operationStatusInfo.AttachedInfo = ex.Message; } return operationStatusInfo; })); }