Esempio n. 1
0
        public async Task <ClassResponse> ReadOnlyGetClassAsync(GetClassRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException($"Request is null");
            }

            var result = await _classRepository.ReadOnlyGetByIdAsync(request.Id);

            return(_classMapper.Map(result));
        }
Esempio n. 2
0
        public void ClassUseCaseEqualTest()
        {
            GetClassRequest getClassRequest = new GetClassRequest();

            IRepositoryFactory repositoryFactory = new RepositoryFactory(new DBContext());
            IActivityFactory   activityFactory   = new ActivityFactory(repositoryFactory, new ValidationRuleFactory());
            IUseCaseFactory    useCaseFactory    = new UseCaseFactory(activityFactory);
            GetClassResponse   getClassResponse  = useCaseFactory.Create <IUseCase <GetClassRequest, GetClassResponse> >().Execute(getClassRequest);

            Assert.IsTrue(getClassResponse.Classes.Count > 0);
        }
Esempio n. 3
0
        public async Task getClass_should_get_data(int id)
        {
            var classRequest = new GetClassRequest {
                Id = id
            };

            var result =
                await _sut.ReadOnlyGetClassAsync(classRequest);

            result.ShouldNotBeNull();
            result.Id.ShouldBe(id);
            result.Name.ShouldBe("C1");
            //result.TaughtBy.Id.ShouldBe(1);
        }
Esempio n. 4
0
        public async Task <OperationStatusInfo> ShowClass()
        {
            return(await Task.Run(() =>
            {
                OperationStatusInfo operationStatusInfo = new OperationStatusInfo(operationStatus: OperationStatus.Done);
                GetClassRequest getClassRequest = new GetClassRequest();

                try
                {
                    GetClassResponse getClassResponse = hubEnvironment.UseCaseFactory.Create <IUseCase <GetClassRequest, GetClassResponse> >().Execute(getClassRequest);
                    operationStatusInfo.AttachedObject = getClassResponse.Classes;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    operationStatusInfo.OperationStatus = OperationStatus.Cancelled;
                    operationStatusInfo.AttachedInfo = ex.Message;
                }

                return operationStatusInfo;
            }));
        }