public ColourValidationTests()
 {
     _inputValidatorColor = new InputValidator(
         new List <IValidation>()
     {
         new ColourValidation(),
     });
 }
Example #2
0
 public RepositoryController(PortalCoreContext context, IConfiguration configuration, IHostingEnvironment hostingEnvironment)
 {
     _validateService    = new InputValidator();
     _configuration      = configuration;
     _hostingEnvironment = hostingEnvironment;
     _context            = context;
     _tokenValidator     = new TokenValidator(_context);
 }
Example #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Strike"/> class.
        /// </summary>
        /// <param name="style">The style.</param>
        /// <param name="strikePrice">The strike price.</param>
        public Strike(OptionType style, Double strikePrice)
        {
            InputValidator.EnumTypeNotSpecified("Option Type", style, true);
            InputValidator.NotZero("Strike Price", strikePrice, true);

            Style       = style;
            StrikePrice = strikePrice;
        }
        public void CheckMilkAndEggsValid()
        {
            var input           = new string[] { "Milk", "Eggs" };
            var validator       = new InputValidator(_products);
            var isValidProducts = validator.ValidateInput(input);

            Assert.IsTrue(isValidProducts);
        }
Example #5
0
        /// <summary>
        /// Adds a specific access key to the dynamo client's credentials
        /// </summary>
        /// <exception cref="ArgumentNullException"></exception>
        public DynamoContextOptionsBuilder UseAccessKeyId(string accessKey)
        {
            InputValidator.ThrowIfNullOrWhitespace(accessKey);

            this.options.AccessKeyId = accessKey;

            return(this);
        }
        public void GetItemsAfterFailedValidate()
        {
            var input     = new string[] { "Beans" };
            var validator = new InputValidator(_products);

            validator.ValidateInput(input);
            validator.GetValidatedProducts();
        }
Example #7
0
        public void TestValidateSeeGrid_NullInput()
        {
            string input = null;

            bool isValid = InputValidator.IsSeeGridValid(input);

            Assert.IsFalse(isValid);
        }
Example #8
0
        public void TestValidateSeeGrid_InvalidInput()
        {
            string input = "aaa";

            bool isValid = InputValidator.IsSeeGridValid(input);

            Assert.IsFalse(isValid);
        }
Example #9
0
        public void Given_WrongParameters_Then_ExceptionIsThrown(int count)
        {
            var parameters = TestDataSources.StringEmitter().Take(count).ToArray();

            var exception = Assert.Throws <ArgumentCountException>(() => InputValidator.ValidateArgs(parameters));

            Assert.AreEqual(TestUtils.GetWrongCountMessage(count), exception.Message);
        }
Example #10
0
        public void TestValidateSeeGrid_ValidNoInput()
        {
            string input = "N";

            bool isValid = InputValidator.IsSeeGridValid(input);

            Assert.IsTrue(isValid);
        }
Example #11
0
        public void CheckInputLength_MoreThan2Params_ThrowsException()
        {
            //given
            string[] args = { "01/01/01", "01/01/01", "01/01/01" };

            //when
            InputValidator.CheckInputLength(args);
        }
Example #12
0
        public void CheckInputLength_WithoutParams_ThrowsException()
        {
            //given
            string[] args = { };

            //when
            InputValidator.CheckInputLength(args);
        }
Example #13
0
        public void CheckInputLength_OnlyOneParam_ThrowsException()
        {
            //given
            string[] args = { "01/01/01" };

            //when
            InputValidator.CheckInputLength(args);
        }
 public LoginControl(Dashboard dashboard)
 {
     this.InitializeComponent();
     _dashboard = dashboard;
     ApplyBlurEffect(dashboard);
     Username.Text = GwupeClientAppContext.CurrentAppContext.LoginManager.LoginDetails.Username ?? "";
     _validator    = new InputValidator(null, null, Dispatcher);
 }
        public void CheckBeansNotValid()
        {
            var input           = new string[] { "Beans" };
            var validator       = new InputValidator(_products);
            var isValidProducts = validator.ValidateInput(input);

            Assert.IsFalse(isValidProducts);
        }
Example #16
0
        /// <summary>
        /// Adds a specific access secret to the dynamo client's credentials
        /// </summary>
        /// <exception cref="DynamoContextConfigurationException"></exception>
        public DynamoContextOptionsBuilder UseSecretAccessKey(string accessSecret)
        {
            InputValidator.ThrowIfNullOrWhitespace(accessSecret);

            this.options.SecretAccessKey = accessSecret;

            return(this);
        }
        public void CheckWrongCaseValid()
        {
            var input           = new string[] { "milk", "EGGS" };
            var validator       = new InputValidator(_products);
            var isValidProducts = validator.ValidateInput(input);

            Assert.IsTrue(isValidProducts);
        }
Example #18
0
        private void SetInputValidator()
        {
            IValidator <PrimesBigInteger>     validateto      = new BigIntegerMinValueMaxValueValidator(null, PrimesBigInteger.ValueOf((int)m_ButtonScale + 1), MAX);
            InputValidator <PrimesBigInteger> inputvalidateto = new InputValidator <PrimesBigInteger>();

            inputvalidateto.DefaultValue = ((int)m_ButtonScale + 1).ToString();
            inputvalidateto.Validator    = validateto;
            iscTo.AddInputValidator(InputSingleControl.Free, inputvalidateto);
        }
Example #19
0
        /// <summary>
        /// Attaches the specified transactions (trytes) to the Tangle by doing Proof of Work.
        /// You need to supply branchTransaction as well as trunkTransaction
        /// (basically the tips which you're going to validate and reference with this transaction)
        ///  - both of which you'll get through the getTransactionsToApprove API call.
        /// </summary>
        /// <param name="trunkTransaction">Trunk transaction to approve.</param>
        /// <param name="branchTransaction">Branch transaction to approve.</param>
        /// <param name="trytes">List of trytes (raw transaction data) to attach to the tangle.</param>
        /// <param name="minWeightMagnitude">Proof of Work intensity. Minimum value is 18</param>
        /// <returns>The returned value contains a different set of tryte values which you can input into broadcastTransactions and storeTransactions.
        /// The returned tryte value, the last 243 trytes basically consist of the: trunkTransaction + branchTransaction + nonce.
        /// These are valid trytes which are then accepted by the network.</returns>
        public AttachToTangleResponse AttachToTangle(string trunkTransaction, string branchTransaction,
                                                     string[] trytes, int minWeightMagnitude = 18)
        {
            if (!InputValidator.IsHash(trunkTransaction))
            {
                throw new ArgumentException("Invalid hashes provided.");
            }

            if (!InputValidator.IsHash(branchTransaction))
            {
                throw new ArgumentException("Invalid hashes provided.");
            }

            if (!InputValidator.IsArrayOfTrytes(trytes, 2673))
            {
                throw new ArgumentException("Invalid trytes provided.");
            }

            if (LocalPow != null)
            {
                var response = new AttachToTangleResponse
                {
                    Trytes = new List <string>()
                };

                string previousTransaction = null;
                foreach (var t in trytes)
                {
                    var txn = new Transaction(t)
                    {
                        TrunkTransaction  = previousTransaction ?? trunkTransaction,
                        BranchTransaction = previousTransaction == null ? branchTransaction : trunkTransaction
                    };

                    if (string.IsNullOrEmpty(txn.Tag) || txn.Tag.Matches("9*"))
                    {
                        txn.Tag = txn.ObsoleteTag;
                    }
                    txn.AttachmentTimestamp           = IotaApiUtils.CreateTimeStampNow();
                    txn.AttachmentTimestampLowerBound = 0;
                    txn.AttachmentTimestampUpperBound = 3_812_798_742_493L;

                    var resultTrytes = LocalPow.PerformPoW(txn.ToTransactionTrytes(), minWeightMagnitude);

                    previousTransaction = new Transaction(resultTrytes).Hash;

                    response.Trytes.Add(resultTrytes);
                }

                return(response);
            }

            AttachToTangleRequest attachToTangleRequest = new AttachToTangleRequest(trunkTransaction, branchTransaction,
                                                                                    trytes, minWeightMagnitude);

            return(_genericIotaCoreApi.Request <AttachToTangleRequest, AttachToTangleResponse>(attachToTangleRequest));
        }
Example #20
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TryteString"/> class.
        /// </summary>
        /// <param name="trytes">
        /// The trytes.
        /// </param>
        /// <exception cref="ArgumentException">
        /// Thrown if on or more characters of the given string are no trytes
        /// </exception>
        public TryteString(string trytes)
        {
            if (!InputValidator.IsTrytes(trytes))
            {
                throw new ArgumentException("Given string does contain invalid characters. Use 'From string' if you meant to convert a string to tryteString");
            }

            this.Value = trytes;
        }
        protected override bool Validate(string text)
        {
            if (!string.IsNullOrEmpty(text) && InputValidator.IsTrytes(text) && text.Length == 81)
            {
                return(true);
            }

            return(false);
        }
Example #22
0
        public Tuple <int[, ], char, bool, int[, ]> InputCommand(string input, IPosition mapBoundary, IList <IPosition> obstacles)
        {
            if (!InputValidator.IsValidInput(input))
            {
                return(null);
            }

            return(Move(input.ToCharArray(), mapBoundary, obstacles));
        }
Example #23
0
        public void ValidateInput(IResponseCreator responseCreator, string prefix = null)
        {
            var iv = new InputValidator <Level1DTO>(this, responseCreator);

            iv.ForString(x => x.NameTest)
            .MinLength(1, NastedDTOValidationTests.TooShortValidationResult);

            this.Level2.ValidateInput(responseCreator, nameof(Level2));
        }
 public async Task <MessageList> ListTopDeviceMessagesAsync(
     int limit,
     string deviceId)
 {
     InputValidator.Validate(deviceId);
     return(this.timeSeriesEnabled ?
            await this.GetListFromTimeSeriesAsync(limit, deviceId) :
            await this.GetListFromCosmosDbAsync(limit, deviceId));
 }
Example #25
0
        public static ICircle GetCircleProperties()
        {
            ICircle circle = Factory.GetInstanceICircle();
            Point   center = new Point();

            /* get input from user start point */
            Console.Write("Enter center coordinate x1,y1: ");
            string coOrdinate = Console.ReadLine();

            string[] coOrdinateValues = coOrdinate.Split(',');
            if (coOrdinateValues.Count() == 0)
            {
                circle = null;
                return(circle);
            }
            else if (coOrdinateValues.Count() == 2)
            {
                /* parsing check and setting null if parsing fails */
                int parseStorageX = 0, parseStorageY = 0;

                if (InputValidator.IsInt(coOrdinateValues[0], ref parseStorageX) & InputValidator.IsInt(coOrdinateValues[1], ref parseStorageY))
                {
                    center.X      = parseStorageX;
                    center.Y      = parseStorageY;
                    circle.center = center;
                }
                else
                {
                    circle = null;
                    return(circle);
                }

                /* get input from user radius */
                Console.Write("Enter radius: ");
                coOrdinate = Console.ReadLine();


                /* parsing check and setting null if parsing fails */
                int parseStorage = 0;

                if (InputValidator.IsInt(coOrdinate, ref parseStorage))
                {
                    circle.radius = parseStorage;
                }
                else
                {
                    circle = null;
                    return(circle);
                }
                return(circle);
            }//else if
            else
            {
                circle = null;
                return(circle);
            }
        }//GetCircleProperties
Example #26
0
        private bool CheckValidEmail()
        {
            ErrorMsgLabel.Text = AppLogic.GetString("signin.aspx.21", SkinID, ThisCustomer.LocaleSetting, true);
            ErrorPanel.Visible = true;

            _EmailValidator = new RegularExpressionInputValidator(EMail, DomainConstants.EmailRegExValidator, ErrorMsgLabel.Text.ToString());
            _EmailValidator.Validate();
            return(_EmailValidator.IsValid);
        }
Example #27
0
 public NoticeView(ILogger <IView> logger, IController <Notice> noticeController, InputValidator validator, IStore <Person> memberStore, IStore <Group> groupStore)
 {
     _logger           = logger;
     _noticeController = noticeController;
     _validator        = validator;
     _groupStore       = groupStore;
     _memberStore      = memberStore;
     GenerateOptions();
 }
Example #28
0
        public void CheckRoverCoordsAndDirection_MissingInputWithoutSpace()
        {
            bool result = InputValidator.CheckRoverCoordsAndDirection("45F", out int x, out int y, out Direction direction);

            Assert.AreEqual(false, result);
            Assert.AreEqual(0, x);
            Assert.AreEqual(0, y);
            Assert.AreEqual(Direction.N, direction);
        }
Example #29
0
        public void CheckRoverCoordsAndDirection_X_Y_AndWrongDirectionInputWithSpace()
        {
            bool result = InputValidator.CheckRoverCoordsAndDirection("4 5 F", out int x, out int y, out Direction direction);

            Assert.AreEqual(false, result);
            Assert.AreEqual(4, x);
            Assert.AreEqual(5, y);
            Assert.AreEqual(Direction.N, direction);
        }
Example #30
0
        public void CheckRoverCoordsAndDirection_Negative_X_Y_AndCorrectDirectionInputWithSpace()
        {
            bool result = InputValidator.CheckRoverCoordsAndDirection("-4 -5 S", out int x, out int y, out Direction direction);

            Assert.AreEqual(false, result);
            Assert.AreEqual(0, x);
            Assert.AreEqual(0, y);
            Assert.AreEqual(Direction.N, direction);
        }
Example #31
0
    //initialize battleship parameteres
    public void Init_Ship(int s_size)
    {
        Debug.Log("ship class init start");

        ship_conf = new Cords[s_size];
        ship_size = s_size;
        cur_loc = 0;
        ship_status = true;//alive
        structure_complete = false; //no ship yet

        input_validator = new InputValidator();
        input_validator.InitValidator();

        Debug.Log("ship class init done");
    }
Example #32
0
        public static string Show(IWin32Window parent, string title, string message, string defaultValue, InputValidator validator)
        {
            PromptWindow window = new PromptWindow();
            window.Text = title;
            window.Message = message;
            window.textInput.Text = defaultValue;
            if (validator != null)
            {
                window.Validator = validator;
            }

            DialogResult result = window.ShowDialog(parent);
            if (result == DialogResult.OK)
            {
                return window.textInput.Text;
            }
            else
            {
                return null;
            }
        }
Example #33
0
        static void Main(string[] args)
        {

            KeyBundle keyBundle = null; // The key specification and attributes
            Secret secret = null;
            string keyName = string.Empty;
            string secretName = string.Empty;

            inputValidator = new InputValidator(args);

            TracingAdapter.AddTracingInterceptor(new ConsoleTracingInterceptor());
            TracingAdapter.IsEnabled = inputValidator.GetTracingEnabled();

            var clientId = ConfigurationManager.AppSettings["AuthClientId"];

            var cerificateThumbprint = ConfigurationManager.AppSettings["AuthCertThumbprint"];

            var certificate = FindCertificateByThumbprint(cerificateThumbprint);
            var assertionCert = new ClientAssertionCertificate(clientId, certificate);

            keyVaultClient = new KeyVaultClient(new KeyVaultClient.AuthenticationCallback( 
                   (authority, resource, scope) => GetAccessToken(authority, resource, scope, assertionCert)), 
                   GetHttpClient());

            // SECURITY: DO NOT USE IN PRODUCTION CODE; FOR TEST PURPOSES ONLY
            //ServicePointManager.ServerCertificateValidationCallback += ( sender, cert, chain, sslPolicyErrors ) => true;

            List<KeyOperationType> successfulOperations = new List<KeyOperationType>();
            List<KeyOperationType> failedOperations = new List<KeyOperationType>();

            foreach (var operation in inputValidator.GetKeyOperations())
            {
                try
                {
                    Console.Out.WriteLine(string.Format("\n\n {0} is in process ...", operation.ToString()));
                    switch (operation)
                    {
                        case KeyOperationType.CREATE_KEY:
                            keyBundle = CreateKey(keyBundle, out keyName);
                            break;

                        case KeyOperationType.IMPORT_KEY:
                            keyBundle = ImportKey(out keyName);
                            break;

                        case KeyOperationType.GET_KEY:
                            keyBundle = GetKey(keyBundle);
                            break;

                        case KeyOperationType.LIST_KEYVERSIONS:
                            ListKeyVersions(keyName);
                            break;

                        case KeyOperationType.UPDATE_KEY:
                            keyBundle = UpdateKey(keyName);
                            break;

                        case KeyOperationType.DELETE_KEY:
                            DeleteKey(keyName);
                            break;

                        case KeyOperationType.BACKUP_RESTORE:
                            keyBundle = BackupRestoreKey(keyName);
                            break;

                        case KeyOperationType.SIGN_VERIFY:
                            SignVerify(keyBundle);
                            break;

                        case KeyOperationType.ENCRYPT_DECRYPT:
                            EncryptDecrypt(keyBundle);
                            break;

                        case KeyOperationType.ENCRYPT:
                            Encrypt(keyBundle);
                            break;

                        case KeyOperationType.DECRYPT:
                            Decrypt(keyBundle);
                            break;

                        case KeyOperationType.WRAP_UNWRAP:
                            WrapUnwrap(keyBundle);
                            break;

                        case KeyOperationType.CREATE_SECRET:
                            secret = CreateSecret(out secretName);
                            break;

                        case KeyOperationType.GET_SECRET:
                            secret = GetSecret(secret.Id);
                            break;

                        case KeyOperationType.LIST_SECRETS:
                            ListSecrets();
                            break;

                        case KeyOperationType.DELETE_SECRET:
                            secret = DeleteSecret(secretName);
                            break;
                    }
                    successfulOperations.Add(operation);
                }
                catch (KeyVaultClientException exception)
                {
                    // The Key Vault exceptions are logged but not thrown to avoid blocking execution for other commands running in batch
                    Console.Out.WriteLine("Operation failed: {0}", exception.Message);
                    failedOperations.Add(operation);
                }

            }

            Console.Out.WriteLine("\n\n---------------Successful Key Vault operations:---------------");
            foreach (KeyOperationType type in successfulOperations)
                Console.Out.WriteLine("\t{0}", type);

            if (failedOperations.Count > 0)
            {
                Console.Out.WriteLine("\n\n---------------Failed Key Vault operations:---------------");
                foreach (KeyOperationType type in failedOperations)
                    Console.Out.WriteLine("\t{0}", type);
            }

            Console.Out.WriteLine();
            Console.Out.Write("Press enter to continue . . .");
            Console.In.Read();
        }
Example #34
0
 public PromptWindow()
 {
     InitializeComponent();
     validator = NumericInputValidator;
 }