示例#1
0
        public bool ValidatePassword(ValidationMessages messages)
        {
            if (string.IsNullOrEmpty(client_id))
            {
                messages.Add("ClientId missing. Use the client_id property to set the ClientId.");
                return(false);
            }

            if (string.IsNullOrEmpty(client_secret))
            {
                messages.Add("ClientSecret missing. Use the client_secret property to set the ClientSecret.");
                return(false);
            }

            if (string.IsNullOrEmpty(username))
            {
                messages.Add("Username missing. Use the username property to set the Username.");
                return(false);
            }

            if (string.IsNullOrEmpty(password))
            {
                messages.Add("Password missing. Use the password property to set the Password.");
                return(false);
            }

            return(true);
        }
示例#2
0
        public void ValidatePassword()
        {
            var messages = new ValidationMessages();

            if (string.IsNullOrEmpty(ClientId))
            {
                messages.Add("ClientId missing. Use the client_id property to set the ClientId.");
            }

            if (string.IsNullOrEmpty(ClientSecret))
            {
                messages.Add("ClientSecret missing. Use the client_secret property to set the ClientSecret.");
            }

            if (string.IsNullOrEmpty(Username))
            {
                messages.Add("Username missing. Use the username property to set the Username.");
            }

            if (string.IsNullOrEmpty(Password))
            {
                messages.Add("Password missing. Use the password property to set the Password.");
            }

            if (messages.HasErrors)
            {
                throw new SoundCloudValidationException(messages);
            }
        }
示例#3
0
        private void CheckForMixedAcTypes(TrsProgramBlock programBlockIn)
        {
            foreach (var typeDef in programBlockIn.Statements.
                     Where(stm => stm is TrsTypeDefinition).Cast <TrsTypeDefinition>())
            {
                foreach (var validationInput in typeDef.AcceptedTerms)
                {
                    var term   = validationInput as TrsTypeDefinitionTerm;
                    var acTerm = validationInput as TrsTypeDefinitionAcTerm;

                    if (term != null || acTerm != null)
                    {
                        string strComp = term != null ? term.TermName : acTerm.TermName;
                        var    isAc    = acTerm != null;
                        if (!isAcTerm.ContainsKey(strComp))
                        {
                            isAcTerm.Add(strComp, isAc);
                        }
                        if (isAc != isAcTerm[strComp])
                        {
                            ValidationMessages.Add(new InterpreterResultMessage
                            {
                                Message     = string.Format("The '{0}' term may not be an AC and non-AC term at the same time.", strComp),
                                InputEntity = validationInput,
                                MessageType = InterpreterMessageType.Error
                            });
                        }
                    }
                }
            }
        }
        public void CheckJobStatus()
        {
            var client = BrightstarService.GetClient(Store.Source.ConnectionString);

            _transactionJob = client.GetJobInfo(Store.Location, _transactionJob.JobId);
            if (_transactionJob.JobCompletedOk)
            {
                ValidationMessages.Clear();
                ValidationMessages.Add(Strings.TransactionSuccess);
            }
            else if (_transactionJob.JobCompletedWithErrors)
            {
                ValidationMessages.Clear();
                ValidationMessages.Add(Strings.TransactionFailed);
                ValidationMessages.Add(_transactionJob.ExtractJobErrorMessage(true));
                Messenger.Default.Send(
                    new ShowDialogMessage("Transaction failed",
                                          "Transaction failed with status: " + _transactionJob.StatusMessage,
                                          MessageBoxImage.Error, MessageBoxButton.OK), "MainWindow");
            }
            else
            {
                _dispatcher.BeginInvoke(DispatcherPriority.SystemIdle, new JobMonitorDelegate(this.CheckJobStatus));
            }
        }
示例#5
0
        internal bool ValidatePost(ValidationMessages messages)
        {
            if (track_id < 1)
            {
                messages.Add("TrackId missing. Use the track_id property to set the TrackId of this comment.");
                return(false);
            }

            if (string.IsNullOrEmpty(body))
            {
                messages.Add("Message missing. Use the body property to set your message.");
                return(false);
            }

            return(true);
        }
示例#6
0
        public bool ValidatePost(ValidationMessages messages)
        {
            if (string.IsNullOrEmpty(title))
            {
                messages.Add("Title missing. Use the title property to set your track title.");
                return(false);
            }

            if (playlist_type == PlaylistType.Other)
            {
                messages.Add("Playlist type must not be 'other'.");
                return(false);
            }

            return(true);
        }
示例#7
0
        public bool ValidatePost(ValidationMessages messages)
        {
            if (string.IsNullOrEmpty(title))
            {
                messages.Add("WebProfile title missing. Use the title property to set the title of this WebProfile.");
                return(false);
            }

            if (string.IsNullOrEmpty(url))
            {
                messages.Add("WebProfile url missing. Use the url property to set the url of this WebProfile.");
                return(false);
            }

            return(true);
        }
示例#8
0
        public bool ValidateUpdate(ValidationMessages messages)
        {
            if (id < 1)
            {
                messages.Add("PlaylistId missing. Use the id property to set the id of this playlist.");
                return(false);
            }

            if (string.IsNullOrEmpty(title))
            {
                messages.Add("Title missing. Use the title property to set your track title.");
                return(false);
            }

            return(true);
        }
示例#9
0
        public bool ValidateUpdate(ValidationMessages messages)
        {
            if (id < 1)
            {
                messages.Add("GroupId missing. Use the id property to set the id of this group.");
                return(false);
            }

            if (string.IsNullOrEmpty(name))
            {
                messages.Add("Name missing. Use the name property to set your group name.");
                return(false);
            }

            return(true);
        }
示例#10
0
        protected void LogInvalidRecord(string record, Exception ex = null)
        {
            if (ex != null)
            {
                var message = string.Empty;

                if (ex.InnerException != null)
                {
                    message = ex.InnerException.Message;
                }
                else
                {
                    message = ex.Message;
                }

                ValidationMessages.Add($"Error: {message}. Raw record: {record}");
            }
            else
            {
                ValidationMessages.Add($"Invalid record: {record}");
            }

            IsParseSuccess = false;
            // todo: perform log
        }
示例#11
0
        public bool ValidateClientCredentials(ValidationMessages messages)
        {
            if (string.IsNullOrEmpty(client_id))
            {
                messages.Add("ClientId missing. Use the client_id property to set the ClientId.");
                return(false);
            }

            if (string.IsNullOrEmpty(client_secret))
            {
                messages.Add("ClientSecret missing. Use the client_secret property to set the ClientSecret.");
                return(false);
            }

            return(true);
        }
示例#12
0
        public virtual bool CanBuySnack(int position)
        {
            ValidationMessages.Clear();

            var snackPile = GetSnackPile(position);

            if (snackPile.Quantity == 0)
            {
                ValidationMessages.Add(Constants.NoSnackAvailableToBuy);
                return(false);
            }

            if (snackPile.Price > MoneyInTransaction)
            {
                ValidationMessages.Add(Constants.NotEnoughMoneyInserted);
                return(false);
            }

            if (!MoneyInside.CanAllocate(snackPile.Price))
            {
                ValidationMessages.Add(Constants.NotEnoughChange);
                return(false);
            }

            return(true);
        }
示例#13
0
        public override void Validate(TrsProgramBlock programBlockIn)
        {
            // Check for empty
            if (programBlockIn.Statements == null || programBlockIn.Statements.Count == 0)
            {
                ValidationMessages.Add(new InterpreterResultMessage
                {
                    Message     = "Empty program block.",
                    MessageType = InterpreterMessageType.Warning,
                    InputEntity = programBlockIn
                });
            }

            // Check types for cyclical definitions
            ValidateTypeDefinitions(programBlockIn);

            // Check limit statements
            ValidateLimitStatements(programBlockIn);

            // Check statements with sub-validators
            ValidateSubValidators(programBlockIn);

            // Check type definitions for mixed AC/non-ac terms with the same name
            CheckForMixedAcTypes(programBlockIn);
        }
        public void Test_HasErrors()
        {
            var errors = new ValidationMessages();

            errors.Add("error!");

            Assert.That(errors.HasErrors, Is.True);
        }
示例#15
0
        public void Test_Add_String()
        {
            var errors = new ValidationMessages();

            errors.Add("error!");

            Assert.Equal("error!", errors.ToString());
        }
        public void Test_Add_StringBuilder()
        {
            var errors = new ValidationMessages();

            errors.Add(new StringBuilder("error!"));

            Assert.That(errors.ToString(), Is.EqualTo("error!"));
        }
            public void OutputsCorrectly()
            {
                var          messages      = new ValidationMessages();
                const string expectedError = "Error";

                messages.Add(XmlSeverityType.Error, expectedError);

                Assert.Same(expectedError, messages.ToString());
            }
示例#18
0
        public void ValidateClientCredentials()
        {
            var messages = new ValidationMessages();

            if (string.IsNullOrEmpty(ClientId))
            {
                messages.Add("ClientId missing. Use the client_id property to set the ClientId.");
            }

            if (string.IsNullOrEmpty(ClientSecret))
            {
                messages.Add("ClientSecret missing. Use the client_secret property to set the ClientSecret.");
            }

            if (messages.HasErrors)
            {
                throw new SoundCloudValidationException(messages);
            }
        }
        public void Test_With_ErrorMessages()
        {
            var messages = new ValidationMessages();

            messages.Add("MyMessage");

            var ex = new SoundCloudValidationException(messages);

            Assert.That(ex.Message, Is.EqualTo("MyMessage"));
        }
示例#20
0
        public bool ValidatePost(ValidationMessages messages)
        {
            if (string.IsNullOrEmpty(name))
            {
                messages.Add("Name missing. Use the name property to set your group name.");
                return(false);
            }

            return(true);
        }
示例#21
0
        public bool ValidateUploadArtwork(ValidationMessages messages)
        {
            if (id < 1)
            {
                messages.Add("PlaylistId missing. Use the id property to set the id of this playlist.");
                return(false);
            }

            return(true);
        }
示例#22
0
        public bool ValidateDelete(ValidationMessages messages)
        {
            if (id < 1)
            {
                messages.Add("WebProfile id missing. Use the id property to set the id of this WebProfile.");
                return(false);
            }

            return(true);
        }
示例#23
0
        public bool ValidateLikeUnlike(ValidationMessages messages)
        {
            if (id < 1)
            {
                messages.Add("TrackId missing. Use the id property to set the id of this track.");
                return(false);
            }

            return(true);
        }
示例#24
0
        public bool ValidateGet(ValidationMessages messages)
        {
            if (id < 1)
            {
                messages.Add("UserId missing. Use the id property to set the id of this user.");
                return(false);
            }

            return(true);
        }
示例#25
0
        public bool ValidateDelete(ValidationMessages messages)
        {
            if (track_id < 1)
            {
                messages.Add("TrackId missing. Use the track_id property to set the TrackId of this comment.");
                return(false);
            }

            return(true);
        }
示例#26
0
        public void ValidatePost()
        {
            var messages = new ValidationMessages();

            if (string.IsNullOrEmpty(Title))
            {
                messages.Add("Title missing. Use the title property to set your track title.");
            }

            if (PlaylistType == PlaylistType.Other)
            {
                messages.Add("Playlist type must not be 'other'.");
            }

            if (messages.HasErrors)
            {
                throw new SoundCloudValidationException(messages);
            }
        }
示例#27
0
        public void ValidateUpdate()
        {
            var messages = new ValidationMessages();

            if (Id < 1)
            {
                messages.Add("PlaylistId missing. Use the id property to set the id of this playlist.");
            }

            if (string.IsNullOrEmpty(Title))
            {
                messages.Add("Title missing. Use the title property to set your track title.");
            }

            if (messages.HasErrors)
            {
                throw new SoundCloudValidationException(messages);
            }
        }
示例#28
0
        internal void ValidatePost()
        {
            var messages = new ValidationMessages();

            if (TrackId < 1)
            {
                messages.Add("TrackId missing. Use the track_id property to set the TrackId of this comment.");
            }

            if (string.IsNullOrEmpty(Body))
            {
                messages.Add("Message missing. Use the body property to set your message.");
            }

            if (messages.HasErrors)
            {
                throw new SoundCloudValidationException(messages);
            }
        }
示例#29
0
        public void ValidatePassword()
        {
            var messages = new ValidationMessages();

            if (string.IsNullOrEmpty(UserName))
            {
                messages.Add("UserName не указан. Используй username свойство для установки UserName.");
            }

            if (string.IsNullOrEmpty(Password))
            {
                messages.Add("Password не указан. Используй password свойство для установки Password.");
            }

            if (messages.HasErrors)
            {
                throw new EasyMSValidationException(messages);
            }
        }
示例#30
0
        /// <summary>
        /// Validates the specified model is not null
        /// </summary>
        /// <param name="modelProperties">The model properties.</param>
        /// <param name="model">The model.</param>
        /// <param name="validationMessages">The validation messages.</param>
        /// <returns></returns>
        public bool Validate(IModelProperties <TModel> modelProperties, TModel model, ValidationMessages validationMessages)
        {
            bool isValid = !Equals(model, null);

            if (!isValid)
            {
                string message = string.Format("Null model specified. Type='{0}'", typeof(TModel));
                validationMessages.Add(message);
            }
            return(isValid);
        }