public void AdverseEventViewModelToFormData_FullData() { //Arrange var aViewModel = new AdverseEventFormViewModel { Id = 6, AdverseExperience = "Broken arm", OnsetDate = new DateTime(2012, 3, 4), OnsetTime = new DateTime(2012, 4, 5, 12, 13, 14), EndDate = new DateTime(2011, 2, 3), EndTime = new DateTime(2011, 4, 5, 1, 2, 3), Outcome = 2, Intensity = 3, RelationshipToInvestigationalDrug = 4 }; var aFormData = CreateEmptyAdverseEventFormData(); //Act formController.MapAdverseEventViewModelToFormData(aViewModel, aFormData); //Assert Assert.That(aFormData.AdverseExperience.Value, Is.EqualTo("Broken arm")); Assert.That(aFormData.OnsetDate.Value, Is.EqualTo(new DateTime(2012, 3, 4).ToString(CultureInfo.InvariantCulture))); Assert.That(aFormData.OnsetTime.Value, Is.EqualTo(new DateTime(2012, 4, 5, 12, 13, 14).ToString(CultureInfo.InvariantCulture))); Assert.That(aFormData.EndDate.Value, Is.EqualTo(new DateTime(2011, 2, 3).ToString(CultureInfo.InvariantCulture))); Assert.That(aFormData.EndTime.Value, Is.EqualTo(new DateTime(2011, 4, 5, 1, 2, 3).ToString(CultureInfo.InvariantCulture))); Assert.That(aFormData.Outcome.Value, Is.EqualTo("2")); Assert.That(aFormData.Intensity.Value, Is.EqualTo("3")); Assert.That(aFormData.RelationshipToInvestigationalDrug.Value, Is.EqualTo("4")); }
public void AdverseEventFormDataToViewModel_EmptyData() { //Arrange var aFormData = CreateEmptyAdverseEventFormData(); //Act AdverseEventFormViewModel adverseEvent = formController.MapAdverseEventFormDataToViewModel(aFormData); //Assert Assert.That(String.IsNullOrEmpty(adverseEvent.FormCaption), Is.True); Assert.That(adverseEvent.IsCompleted, Is.False); Assert.That(String.IsNullOrEmpty(adverseEvent.VisitName), Is.True); Assert.That(adverseEvent.PatientNumber, Is.EqualTo(0)); Assert.That(adverseEvent.FormId, Is.EqualTo(0)); Assert.That(String.IsNullOrEmpty(adverseEvent.AdverseExperience), Is.True); Assert.That(adverseEvent.OnsetDate, Is.Null); Assert.That(adverseEvent.OnsetTime, Is.Null); Assert.That(adverseEvent.EndDate, Is.Null); Assert.That(adverseEvent.EndTime, Is.Null); Assert.That(adverseEvent.Outcome, Is.EqualTo(0)); Assert.That(adverseEvent.Intensity, Is.EqualTo(0)); Assert.That(adverseEvent.RelationshipToInvestigationalDrug, Is.EqualTo(0)); }
public void AdverseEventFormDataToViewModel_FullData() { //Arrange var aFormData = new AdverseEventFormData { Id = 6, Form = new Form { Id = 16, Caption = "Form16", FormState = FormState.Completed, Visit = new Visit { Caption = "Visit16", Patient = new Patient { PatientNumber = 160 } } }, AdverseExperience = new Question { Id = 3, DataType = QuestionDataType.String, Value = "Broken legs" }, OnsetDate = new Question { Id = 4, DataType = QuestionDataType.Date, Value = new DateTime(2011, 11, 8, 9, 10, 11).ToString( CultureInfo.InvariantCulture) }, OnsetTime = new Question { Id = 5, DataType = QuestionDataType.Time, Value = new DateTime(2011, 11, 8, 9, 10, 11).ToString( CultureInfo.InvariantCulture) }, EndDate = new Question { Id = 6, DataType = QuestionDataType.Date, Value = new DateTime(2012, 1, 10, 11, 12, 13).ToString( CultureInfo.InvariantCulture) }, EndTime = new Question { Id = 7, DataType = QuestionDataType.Date, Value = new DateTime(2012, 1, 10, 11, 12, 13).ToString( CultureInfo.InvariantCulture) }, Outcome = new Question { Id = 8, DataType = QuestionDataType.Enum, Value = "1" }, Intensity = new Question { Id = 9, DataType = QuestionDataType.Enum, Value = "2" }, RelationshipToInvestigationalDrug = new Question { Id = 10, DataType = QuestionDataType.Enum, Value = "3" } }; //Act AdverseEventFormViewModel adverseEvent = formController.MapAdverseEventFormDataToViewModel(aFormData); //Assert Assert.That(adverseEvent.FormId, Is.EqualTo(16)); Assert.That(adverseEvent.FormCaption, Is.EqualTo("Form16")); Assert.That(adverseEvent.IsCompleted, Is.True); Assert.That(adverseEvent.VisitName, Is.EqualTo("Visit16")); Assert.That(adverseEvent.PatientNumber, Is.EqualTo(160)); Assert.That(adverseEvent.Id, Is.EqualTo(6)); Assert.That(adverseEvent.AdverseExperience, Is.EqualTo("Broken legs")); Assert.That(adverseEvent.OnsetDate, Is.Not.Null); Assert.That(adverseEvent.OnsetDate.Value.ToShortDateString(), Is.EqualTo(new DateTime(2011, 11, 8).ToShortDateString())); Assert.That(adverseEvent.OnsetTime, Is.Not.Null); Assert.That(adverseEvent.OnsetTime.Value.ToLongTimeString(), Is.EqualTo(new DateTime(2011, 12, 5, 9, 10, 11).ToLongTimeString())); Assert.That(adverseEvent.EndDate, Is.Not.Null); Assert.That(adverseEvent.EndDate.Value.ToShortDateString(), Is.EqualTo(new DateTime(2012, 1, 10).ToShortDateString())); Assert.That(adverseEvent.EndTime, Is.Not.Null); Assert.That(adverseEvent.EndTime.Value.ToLongTimeString(), Is.EqualTo(new DateTime(2011, 12, 5, 11, 12, 13).ToLongTimeString())); Assert.That(adverseEvent.Outcome, Is.EqualTo(1)); Assert.That(adverseEvent.Intensity, Is.EqualTo(2)); Assert.That(adverseEvent.RelationshipToInvestigationalDrug, Is.EqualTo(3)); Assert.That(adverseEvent.AdverseExperienceQuestionId, Is.EqualTo(aFormData.AdverseExperience.Id)); Assert.That(adverseEvent.OnsetDateQuestionId, Is.EqualTo(aFormData.OnsetDate.Id)); Assert.That(adverseEvent.OnsetTimeQuestionId, Is.EqualTo(aFormData.OnsetTime.Id)); Assert.That(adverseEvent.EndDateQuestionId, Is.EqualTo(aFormData.EndDate.Id)); Assert.That(adverseEvent.EndTimeQuestionId, Is.EqualTo(aFormData.EndTime.Id)); Assert.That(adverseEvent.OutcomeQuestionId, Is.EqualTo(aFormData.Outcome.Id)); Assert.That(adverseEvent.IntensityQuestionId, Is.EqualTo(aFormData.Intensity.Id)); Assert.That(adverseEvent.RelationshipToInvestigationalDrugQuestionId, Is.EqualTo(aFormData.RelationshipToInvestigationalDrug.Id)); }