Exemple #1
0
        public void SellerUseCaseEqualTest()
        {
            User user = new User {
                Id = 2
            };
            GetSellerRequest getSellerRequest = new GetSellerRequest(user);

            IRepositoryFactory repositoryFactory = new RepositoryFactory(new DBContext());
            IActivityFactory   activityFactory   = new ActivityFactory(repositoryFactory, new ValidationRuleFactory());
            IUseCaseFactory    useCaseFactory    = new UseCaseFactory(activityFactory);
            GetSellerResponse  getSellerResponse = useCaseFactory.Create <IUseCase <GetSellerRequest, GetSellerResponse> >().Execute(getSellerRequest);

            Assert.AreEqual(getSellerResponse.Seller.Surname, "Wolf");
        }
        public async Task <OperationStatusInfo> FindSeller(User user)
        {
            return(await Task.Run(() =>
            {
                OperationStatusInfo operationStatusInfo = new OperationStatusInfo(operationStatus: OperationStatus.Done);
                GetSellerRequest getSellerRequest = new GetSellerRequest(user);

                try
                {
                    GetSellerResponse getSellerResponse = hubEnvironment.UseCaseFactory.Create <IUseCase <GetSellerRequest, GetSellerResponse> >().Execute(getSellerRequest);
                    operationStatusInfo.AttachedObject = getSellerResponse.Seller;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    operationStatusInfo.OperationStatus = OperationStatus.Cancelled;
                    operationStatusInfo.AttachedInfo = ex.Message;
                }

                return operationStatusInfo;
            }));
        }