Exemple #1
0
        private async void CheckSubjectAction_ExecuteAsync(Object sender, SimpleActionExecuteEventArgs e)
        {
            var selectedSpecificationEnum = selectCheckSpecificationActionController.SelectedSpecification;
            var selectedSpecificationName = selectedSpecificationEnum.ToString().RemoveUnderline();

            CheckSubject currentObject = ((DetailView)View).CurrentObject as CheckSubject;

            if (currentObject.Date == new DateTime())
            {
                currentObject.Date = DateTime.Now;
            }

            var selectedSpecificationData = currentObject.GetType().GetProperty($"{selectedSpecificationName}").GetValue(currentObject) as IList;

            if (!DataIsValid(currentObject, selectedSpecificationData))
            {
                return;
            }

            subjectService = new SubjectService();

            var selectedSpecificationObject = new CheckSpecificationData
            {
                SelectedSpecification = ((BaseSpecification)selectedSpecificationData[0]).Number,
                BankAccount           = currentObject.BankAccount[0].Number
            };

            var response = await subjectService.CheckSubject(selectedSpecificationObject, selectedSpecificationEnum, currentObject.Date);

            ShowNewDetailView(response);
        }
        public void ShouldGetUrlToCheckByRegon()
        {
            //Assert
            var selectedSpecificationData = new CheckSpecificationData {
                BankAccount = "10521327305908100261101820", SelectedSpecification = "79156739856513"
            };

            //Act
            var actionUrl = checkApiUrlAssigner.GetActionUrl(selectedSpecificationData, (int)CheckBySpecification.Regon);

            //Assert
            actionUrl.Should().NotBeNullOrEmpty();
            actionUrl.Should().Contain("79156739856513");
            actionUrl.Should().Contain("10521327305908100261101820");
            actionUrl.Should().Contain("regon");
        }
        public void ShouldGetUrlToCheckByNip()
        {
            //Assert
            var selectedSpecificationData = new CheckSpecificationData {
                BankAccount = "10521327305908100261101820", SelectedSpecification = "3245174504"
            };

            //Act
            var actionUrl = checkApiUrlAssigner.GetActionUrl(selectedSpecificationData, (int)CheckBySpecification.Nip);

            //Assert
            actionUrl.Should().NotBeNullOrEmpty();
            actionUrl.Should().Contain("3245174504");
            actionUrl.Should().Contain("10521327305908100261101820");
            actionUrl.Should().Contain("nip");
        }
        public async Task ShouldReturnEntityCheckResponse()
        {
            //Assert
            var response = "{ 'result': { 'requestId': '123' } }";
            var selectedSpecificationObject = new CheckSpecificationData
            {
                SelectedSpecification = "3245174504",
                BankAccount           = "49635393242218223941769740"
            };

            customHttpClient.Setup(x => x.GetStringAsync(It.IsAny <string>(), It.IsAny <Dictionary <string, string> >())).Returns(Task.FromResult(response));

            //Act
            var action = await subjectService.CheckSubject(selectedSpecificationObject, CheckBySpecification.Nip, DateTime.Today);

            //Assert
            action.Should().BeOfType(typeof(EntityCheckResponse));
        }