public void WhenQuestionIsNew_ThenItIsNotComplete() { var question = new NumericQuestion { }; Assert.IsFalse(question.IsComplete); }
public void WhenQuestionIsCreated_ThenTemplateValuesAreCopied() { var question = new NumericQuestion { MaxValue = 35 }; Assert.AreEqual(35, question.MaxValue); }
public void WhenQuestionHasValidValue_ThenItIsComplete() { var question = new NumericQuestion { }; question.Response = 10; Assert.IsTrue(question.IsComplete); }
public void WhenResponseIsNegative_ThenIndicatesErrorOnResponse() { var question = new NumericQuestion { }; var notifyErrorInfo = (INotifyDataErrorInfo)question; question.Response = -15; Assert.IsTrue(notifyErrorInfo.GetErrors("Response").Cast <string>().Any()); }
public void WhenQuestionHasNullValue_ThenItIsNotComplete() { var question = new NumericQuestion { }; question.Response = 10; question.Response = null; Assert.IsFalse(question.IsComplete); }
public void WhenQuestionHasNegativeValue_ThenItIsNotComplete() { var question = new NumericQuestion { MaxValue = 15 }; question.Response = -1; Assert.IsFalse(question.IsComplete); }
public void WhenResponseIsPositiveWithNoMaximum_ThenIndicatesNoErrorOnResponse() { var question = new NumericQuestion { }; var notifyErrorInfo = (INotifyDataErrorInfo)question; question.Response = 15; Assert.IsFalse(notifyErrorInfo.GetErrors("Response").Cast <string>().Any()); }
public void WhenResponseIsPositiveOverMaximum_ThenIndicatesErrorOnResponse() { var question = new NumericQuestion { MaxValue = 10 }; var notifyErrorInfo = (INotifyDataErrorInfo)question; question.Response = 15; Assert.IsTrue(notifyErrorInfo.GetErrors("Response").Cast <string>().Any()); }
public Answer GetAnswer(Question question) { return(question switch { NumericQuestion _ => new NumericAnswer(), RatingQuestion _ => new NumericAnswer(), MultipleChoiceQuestion _ => new MultipleChoiceAnswer(), StringQuestion _ => new StringAnswer(), DrawQuestion _ => new FileAnswer(), UploadPictureQuestion _ => new FileAnswer(), _ => throw new Exception() });
public void WhenSettingResponseToNull_ThenIndicatesErrorOnResponse() { var question = new NumericQuestion { }; var notifyErrorInfo = (INotifyDataErrorInfo)question; question.Response = 10; Assert.IsFalse(notifyErrorInfo.GetErrors("Response").Cast <string>().Any()); question.Response = null; Assert.IsTrue(notifyErrorInfo.GetErrors("Response").Cast <string>().Any()); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { return(value switch { DrawQuestion _ => "Teken vraag", RatingQuestion _ => "Beoordelings vraag", StringQuestion _ => "Open vraag", MultipleChoiceQuestion _ => "Meerkeuze vraag", UploadPictureQuestion _ => "Foto vraag", NumericQuestion _ => "Numerieke vraag", ReferenceQuestion _ => "Referentie vraag", _ => "vraag" });
public void WhenViewModelHasErrorIsSet_ThenDoesNotHaveCompletedResponse() { var question = new NumericQuestion { MaxValue = 100 }; var viewModel = new NumericQuestionViewModel(question); question.Response = 15; viewModel.HasBindingError = true; // Assertions Assert.IsFalse(viewModel.ResponseComplete); }
protected void Submit_Click(object sender, EventArgs e) { int paperID = Convert.ToInt32(Request[RequestMSG.PaperID]); string[] OptionalQuestionsAnswer = hfOptions.Value.Split(','); string[] temp; for (int i = 0; i < evaluation.Count; i++) { if (evaluation[i] is WrittenQuestions) { WrittenQuestions written = (WrittenQuestions)evaluation[i]; written.Answertext = Request.Form["writtenAnswer" + i]; } else if (evaluation[i] is NumericQuestion) { NumericQuestion numeric = (NumericQuestion)evaluation[i]; numeric.Score = Convert.ToInt32(Request.Form["numericAnswer" + i]); } else if (evaluation[i] is Multiple_ChoiceQuestions) { Multiple_ChoiceQuestions optional = (Multiple_ChoiceQuestions)evaluation[i]; bool ExistOption = false; for (int j = 0; j < OptionalQuestionsAnswer.Length; j++) { temp = OptionalQuestionsAnswer[j].Split('_'); if (temp[0] == i.ToString()) { ExistOption = optional.SelectAnswerItem(Convert.ToInt32(temp[1])); if (!ExistOption) { throw new MyException(QuestionEvaluation_Message.SuchAnOptionIsNotAvailable, 101, ""); } ExistOption = false; } } } } PaperInfoMan_Business paperInfoMan = new PaperInfoMan_Business(); List <string> files = new List <string>(); DBmessage dbm = paperInfoMan.SetPointToPaperByReferee(paperID, files, evaluation); if (dbm.Type == DBMessageType.Sucsess) { Response.Redirect(ServerDirectory.Paper + "/PaperInformation.aspx?" + RequestMSG.ID + "=" + paperID); } else { ShowNotify(dbm); } }
public void WhenCreatingANewViewModel_ThenHasChangesIsFalse() { var question = new NumericQuestion { MaxValue = 100 }; var viewModel = new NumericQuestionViewModel(question); bool hasChanges = false; viewModel.ResponseChanged += (o, e) => { hasChanges = true; }; // Assertions Assert.IsFalse(hasChanges); }
public void WhenResponseChangesOnTheModel_ThenResponseValueChangeIsFired() { var question = new NumericQuestion { MaxValue = 100 }; var viewModel = new NumericQuestionViewModel(question); bool responseChangeFired = false; viewModel.ResponseChanged += (s, e) => { responseChangeFired = true; }; question.Response = 15; // Assertions Assert.IsTrue(responseChangeFired); }
public void WhenHasErrorIsChangedToFalseOnTheViewModel_ThenResponseValueChangeIsFired() { var question = new NumericQuestion { MaxValue = 100 }; var viewModel = new NumericQuestionViewModel(question); viewModel.HasBindingError = true; bool responseChangeFired = false; viewModel.ResponseChanged += (s, e) => { responseChangeFired = true; }; viewModel.HasBindingError = false; // Assertions Assert.IsTrue(responseChangeFired); }
public void WhenResponseIsSetOnTheModel_ThenHasChangesIsTrue() { var question = new NumericQuestion { MaxValue = 100 }; var viewModel = new NumericQuestionViewModel(question); bool hasChanges = false; viewModel.ResponseChanged += (o, e) => { hasChanges = true; }; question.Response = 15; // Assertions Assert.IsTrue(hasChanges); }
public void WhenResponseIsSetOnTheModel_ThenTheHasErrorPropertyInTheViewModelIsCleared() { var question = new NumericQuestion { MaxValue = 100 }; var viewModel = new NumericQuestionViewModel(question); viewModel.HasBindingError = true; int responseChanges = 0; viewModel.ResponseChanged += (s, e) => { responseChanges++; }; question.Response = 15; // Assertions Assert.IsFalse(viewModel.HasBindingError); Assert.AreEqual(1, responseChanges); }
protected override void Seed(FestispecContext context) { // This method will be called after migrating to the latest version. // You can use the DbSet<T>.AddOrUpdate() helper extension method // to avoid creating duplicate seed data. // context.SaveChanges(); try { var address = new Address { Id = 1, StreetName = "Isolatorweg", HouseNumber = 36, ZipCode = "1014AS", City = "Amsterdam", Country = "Nederland", Latitude = 52.39399f, Longitude = 4.8507514f }; var address2 = new Address { Id = 2, Country = "Duitsland", StreetName = "Flughafen-Ring", HouseNumber = 16, City = "Weeze", ZipCode = "NW47652", Latitude = 51.5924149f, Longitude = 6.1545434f }; var address3 = new Address { Id = 3, City = "Utrecht", Country = "Nederland", HouseNumber = 59, StreetName = "Chopinstraat", ZipCode = "3533EL", Latitude = 52.0857048f, Longitude = 5.08541441f }; var address4 = new Address { City = "Amsterdam", Country = "Nederland", HouseNumber = 14, StreetName = "Lutmastraat", ZipCode = "1072JL", Latitude = 52.350400f, Longitude = 4.892710f }; context.Addresses.AddOrUpdate(address, address2, address3, address4); Employee employee = CreateEmployee(context, address3); var customer = new Customer { Id = 1, CustomerName = "Q-DANCE", KvkNr = 34212891, Address = address, ContactDetails = new ContactDetails { EmailAddress = "*****@*****.**", PhoneNumber = "+31204877300" } }; context.Customers.AddOrUpdate(customer); var now = DateTime.Now; var festival = new Festival { Id = 1, FestivalName = "Q-BASE", Customer = customer, Description = "Nachtfestival over de grens", Address = address2, OpeningHours = new OpeningHours { StartTime = new TimeSpan(now.Hour, now.Minute, now.Second), EndTime = new TimeSpan(8, 0, 0), StartDate = new DateTime(2020, 1, 1), EndDate = new DateTime(2020, 9, 6) } }; context.Festivals.AddOrUpdate(festival); customer.Festivals = new List <Festival> { festival }; context.Customers.AddOrUpdate(customer); var questionnaire = new Questionnaire { Id = 1, Name = "Tester", Festival = festival }; context.Questionnaires.AddOrUpdate(questionnaire); var employeeInspector = new Employee { Id = 2, Iban = "NL01RABO12789410", Name = new FullName { First = "Jan", Last = "Dirksen" }, Account = new Account { Id = 1, // Voorletter + Achternaam + geboortejaar Username = "******", Password = BCrypt.Net.BCrypt.HashPassword("TestWachtwoord"), Role = Role.Inspector }, Address = address4, ContactDetails = new ContactDetails { EmailAddress = "*****@*****.**", PhoneNumber = "+31987654321" }, Certificates = new List <Certificate> { new Certificate { Id = 2, CertificateTitle = "Inspection Certificate", CertificationDate = new DateTime(2019, 3, 4, 00, 00, 00), ExpirationDate = new DateTime(2021, 3, 4, 00, 00, 00) } } }; var plannedInspection = new PlannedInspection { Id = 1, Employee = employeeInspector, Festival = festival, EventTitle = "Inspection " + festival.FestivalName, StartTime = DateTime.Now.Date.Add(new TimeSpan(0, 10, 0, 0)), EndTime = DateTime.Now.Date.Add(new TimeSpan(0, 20, 0, 0)), Questionnaire = questionnaire, }; context.PlannedInspections.AddOrUpdate(plannedInspection); #region DrawQuestion var drawQuestion = new DrawQuestion { Id = 1, PicturePath = "/Uploads/grasso.png", Questionnaire = questionnaire, Contents = "Wat is de kortste looproute van de mainstage naar de nooduitgang?" }; var drawQuestionAnswer = new FileAnswer { Id = 1, Question = drawQuestion, UploadedFilePath = "/Uploads/inspection_adsfadfs.png", PlannedInspection = plannedInspection }; context.Answers.AddOrUpdate(drawQuestionAnswer); context.Questions.AddOrUpdate(drawQuestion); #endregion #region MultipleChoiceQuestion var multipleChoiceQuestion = new MultipleChoiceQuestion { Id = 2, Contents = "Zijn er evacuatieplannen zichtbaar opgesteld?", Options = "Ja~Nee", OptionCollection = new ObservableCollection <StringObject> { new StringObject("Option1") }, Questionnaire = questionnaire }; var multipleChoiceQuestionAnswer = new MultipleChoiceAnswer { Id = 2, MultipleChoiceAnswerKey = 0, PlannedInspection = plannedInspection, Question = multipleChoiceQuestion }; context.Answers.AddOrUpdate(multipleChoiceQuestionAnswer); context.Questions.AddOrUpdate(multipleChoiceQuestion); #endregion #region NumericQuestion var numericQuestion = new NumericQuestion { Id = 3, Contents = "Hoeveel EHBO-posten zijn er aanwezig?", Minimum = 0, Maximum = 99, Questionnaire = questionnaire }; var numericQuestionAnswer = new NumericAnswer { Id = 3, Question = numericQuestion, IntAnswer = 3, PlannedInspection = plannedInspection }; context.Answers.AddOrUpdate(numericQuestionAnswer); context.Questions.AddOrUpdate(numericQuestion); #endregion #region RatingQuestion var ratingQuestion = new RatingQuestion { Id = 4, Contents = "Op een schaal van 1 tot 5, is de beveiliging voldoende aanwezig op het terrein?", HighRatingDescription = "Er is veel beveiliging", LowRatingDescription = "Er is amper beveiliging", Questionnaire = questionnaire }; var ratingQuestionAnswer = new NumericAnswer { Id = 3, Question = numericQuestion, IntAnswer = 4, PlannedInspection = plannedInspection }; context.Answers.AddOrUpdate(ratingQuestionAnswer); context.Questions.AddOrUpdate(ratingQuestion); #endregion #region StringQuestion var stringQuestion = new StringQuestion { Id = 5, Contents = "Geef een korte samenvatting van het vluchtplan.", IsMultiline = true, Questionnaire = questionnaire }; var stringQuestionAnswer = new StringAnswer { Id = 5, Question = stringQuestion, AnswerContents = "In geval van een calamiteit is voor de bezoekers duidelijk te zien dat er vanaf de mainstage al vier vluchtroutes bestaan.", PlannedInspection = plannedInspection }; context.Answers.AddOrUpdate(stringQuestionAnswer); context.Questions.AddOrUpdate(stringQuestion); #endregion #region PictureQuestion var pictureQuestion = new UploadPictureQuestion { Id = 6, Contents = "Plaats een foto van de vluchtroutes op het calamiteitenplan.", Questionnaire = questionnaire }; var pictureQuestionAnswer = new FileAnswer { Id = 6, Question = pictureQuestion, UploadedFilePath = "/uploads/inspection_adsfadfs.png", PlannedInspection = plannedInspection }; context.Answers.AddOrUpdate(pictureQuestionAnswer); context.Questions.AddOrUpdate(pictureQuestion); #endregion #region ReferenceQuestion var referenceQuestion = new ReferenceQuestion { Id = 7, Question = pictureQuestion, Contents = pictureQuestion.Contents, Questionnaire = questionnaire }; var referenceQuestionAnswer = new FileAnswer { Id = 7, Question = referenceQuestion, UploadedFilePath = "/uploads/inspection_eruwioeiruwoio.png", PlannedInspection = plannedInspection }; context.Answers.AddOrUpdate(referenceQuestionAnswer); context.Questions.AddOrUpdate(referenceQuestion); #endregion context.Employees.AddOrUpdate(employeeInspector); context.SaveChanges(); } catch (DbEntityValidationException e) { foreach (DbEntityValidationResult eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (DbValidationError ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } throw; } }
protected void btnFinish_Click(object sender, EventArgs e) { string txtbDescriptiveQuestionTitle = ""; string txtbAnswerTitle = ""; string txtbNumQuestionTitle = ""; string txtbMin = ""; string txtbMax = ""; string txtbOptionalQuestionTitle = ""; string txtbOptions = ""; string[] Options; // Multiple_ChoiceQuestions multiChoice = null; NumericQuestion numeric = null; WrittenQuestions written = null; QuestionInfoMan_Business business = new QuestionInfoMan_Business(); EvaluationForm evaluationForm = new EvaluationForm(); evaluationForm.Title = txtbEvaTitle.Text; // for (int i = 0; i < 100; i++) { txtbDescriptiveQuestionTitle = Request.Form["txtbDescriptiveQuestionTitle" + (i + 1)]; txtbAnswerTitle = Request.Form["txtbAnswerTitle" + (i + 1)]; txtbNumQuestionTitle = Request.Form["txtbNumQuestionTitle" + (i + 1)]; txtbMin = Request.Form["txtbMinScore" + (i + 1)]; txtbMax = Request.Form["txtbmaxScore" + (i + 1)]; txtbOptionalQuestionTitle = Request.Form["txtbOptionalQuestionTitle" + (i + 1)]; txtbOptions = Request.Form["txtbOptions" + (i + 1)]; // if (txtbDescriptiveQuestionTitle != null && txtbAnswerTitle != null && txtbDescriptiveQuestionTitle != string.Empty && txtbAnswerTitle != string.Empty) { written = new WrittenQuestions(); written.Title = txtbDescriptiveQuestionTitle; written.AnswerTilte = txtbAnswerTitle; evaluationForm.Add(written); } else if (txtbNumQuestionTitle != null && txtbMin != null && txtbMax != null && txtbNumQuestionTitle != string.Empty && txtbMin != string.Empty && txtbMax != string.Empty) { numeric = new NumericQuestion(); numeric.Title = txtbNumQuestionTitle; numeric.Min = float.Parse(txtbMin); numeric.Max = float.Parse(txtbMax); evaluationForm.Add(numeric); } else if (txtbOptionalQuestionTitle != null && txtbOptions != null && txtbOptionalQuestionTitle != string.Empty && txtbOptions != string.Empty) { multiChoice = new Multiple_ChoiceQuestions(); multiChoice.Title = txtbOptionalQuestionTitle; Options = txtbOptions.Split(';'); for (int j = 0; j < Options.Length; j++) { multiChoice.Add(new AnswerOption() { Title = Options[j] }); } evaluationForm.Add(multiChoice); } else { break; } } DBmessage dbm = business.RegisterEvaluationForm(txtbEvaTitle.Text, evaluationForm); ShowNotify(dbm); }
private void UserControl_Loaded(object sender, RoutedEventArgs e) { _question = (NumericQuestion)QuestionData.DataContext; _question.AssignValidationRule(); }
public override Question CreateNewQuestion() { var question = new NumericQuestion(this); return(question); }
public override Question CreateNewQuestion() { var question = new NumericQuestion(this); return question; }
protected void btnFinish_Click(object sender, EventArgs e) { string txtbDescriptiveQuestionTitle = ""; string txtbAnswerTitle = ""; string txtbNumQuestionTitle = ""; string txtbMin = ""; string txtbMax = ""; string txtbOptionalQuestionTitle = ""; string txtbOptions = ""; string[] Options; // Multiple_ChoiceQuestions multiChoice = null; NumericQuestion numeric = null; WrittenQuestions written = null; QuestionInfoMan_Business business = new QuestionInfoMan_Business(); EvaluationForm evaluationForm = new EvaluationForm(); evaluationForm.Title = txtbEvaTitle.Text; // for (int i = 0; i < 100; i++) { txtbDescriptiveQuestionTitle = Request.Form["txtbDescriptiveQuestionTitle" + (i + 1)]; txtbAnswerTitle = Request.Form["txtbAnswerTitle" + (i + 1)]; txtbNumQuestionTitle = Request.Form["txtbNumQuestionTitle" + (i + 1)]; txtbMin = Request.Form["txtbMinScore" + (i + 1)]; txtbMax = Request.Form["txtbmaxScore" + (i + 1)]; txtbOptionalQuestionTitle = Request.Form["txtbOptionalQuestionTitle" + (i + 1)]; txtbOptions = Request.Form["txtbOptions" + (i + 1)]; // if (txtbDescriptiveQuestionTitle != null && txtbAnswerTitle != null && txtbDescriptiveQuestionTitle != string.Empty && txtbAnswerTitle != string.Empty) { written = new WrittenQuestions(); written.Title = txtbDescriptiveQuestionTitle; written.AnswerTilte = txtbAnswerTitle; evaluationForm.Add(written); } else if (txtbNumQuestionTitle != null && txtbMin != null && txtbMax != null && txtbNumQuestionTitle != string.Empty && txtbMin != string.Empty && txtbMax != string.Empty) { numeric = new NumericQuestion(); numeric.Title = txtbNumQuestionTitle; numeric.Min = float.Parse(txtbMin); numeric.Max = float.Parse(txtbMax); evaluationForm.Add(numeric); } else if (txtbOptionalQuestionTitle != null && txtbOptions != null && txtbOptionalQuestionTitle != string.Empty && txtbOptions != string.Empty) { multiChoice = new Multiple_ChoiceQuestions(); multiChoice.Title = txtbOptionalQuestionTitle; Options = txtbOptions.Split(';'); for (int j = 0; j < Options.Length; j++) { multiChoice.Add(new AnswerOption() { Title = Options[j] }); } evaluationForm.Add(multiChoice); } else { break; } } DBmessage dbm = business.RegisterEvaluationForm(txtbEvaTitle.Text, evaluationForm); ShowNotify(dbm); }