예제 #1
0
        public void Validate_Throws_When_CountryCode_Is_Empty(string countryCode)
        {
            // Arrange

            // Act
            var ex = Assert.Throws <InvalidCountryCodeException>(() => _countryCodeValidator.Validate(countryCode));

            // Assert
            Assert.IsNotNull(ex);
        }
예제 #2
0
        public void CodeIsNull()
        {
            // Arrange
            var validator = new CountryCodeValidator(null, codeService, "Country");

            //Act
            validator.Validate(controller.ModelState);

            // Assert
            controller.ModelState.IsValid.Should().BeTrue();
        }
예제 #3
0
        public void CodeNotExistsCodeServiceReturnsEmpty()
        {
            // Arrange
            codeServiceMockSetup.Setup(c => c.GetCountryByCode(It.IsAny <string>())).Returns("");
            var validator = new CountryCodeValidator("code", codeServiceMockSetup.Object, "Country");

            //Act
            validator.Validate(controller.ModelState);

            // Assert
            controller.ModelState.IsValid.Should().BeFalse();
        }
예제 #4
0
        private ServiceResult ValidatePosition(PositionDto positionDto)
        {
            ServiceResult result = new ServiceResult(Common.Enums.ServiceResultType.Success);

            if (string.IsNullOrEmpty(positionDto.ISIN))
            {
                result.ResultType = Common.Enums.ServiceResultType.Error;
                result.Message    = $"ISIN code of portfolios position is empty";
                return(result);
            }

            if (!IsinValidator.Validate(positionDto.ISIN))
            {
                result.ResultType = Common.Enums.ServiceResultType.Error;
                result.Message    = $"ISIN code ('{positionDto.ISIN}') of portfolios position is not valid";
                return(result);
            }

            if (string.IsNullOrEmpty(positionDto.Currency))
            {
                result.ResultType = Common.Enums.ServiceResultType.Error;
                result.Message    = $"Currency code of portfolios position is empty";
                return(result);
            }

            if (!CurrencyCodeValidator.Validate(positionDto.Currency))
            {
                result.ResultType = Common.Enums.ServiceResultType.Error;
                result.Message    = $"Currency code ('{positionDto.Currency}') of portfolios position is not valid";
                return(result);
            }

            if (string.IsNullOrEmpty(positionDto.Country))
            {
                result.ResultType = Common.Enums.ServiceResultType.Error;
                result.Message    = $"Country code of portfolios position is empty";
                return(result);
            }

            if (!CountryCodeValidator.Validate(positionDto.Country))
            {
                result.ResultType = Common.Enums.ServiceResultType.Error;
                result.Message    = $"Country code ('{positionDto.Country}') of portfolios position is not valid";
                return(result);
            }

            return(result);
        }