public void GetPersonByName_PersonNotFound_ReturnsNull() { var repo = new Mock <ElementRepository <Person> >(); repo.Setup(x => x.GetById("Joe")).Returns((Person)null); var informant = new PersonInformant(repo.Object, null); Assert.IsNull(informant.GetPersonByNameOrCode("Joe")); }
public void GetPersonByName_PersonFound_ReturnsPerson() { var componentFile = new Mock <ProjectElementComponentFile>(); var person = new Mock <Person>(); person.Setup(p => p.GetInformedConsentComponentFile()).Returns(componentFile.Object); var repo = new Mock <ElementRepository <Person> >(); repo.Setup(x => x.GetById("Joe")).Returns(person.Object); var informant = new PersonInformant(repo.Object, null); Assert.AreEqual(person.Object, informant.GetPersonByNameOrCode("Joe")); }
/// ------------------------------------------------------------------------------------ /// <summary> /// When the binding helper gets to writing field values to the metadata file, we need /// to make sure the English values for male and female are written to the file, not /// the localized values for male and female (which is what is in the gender combo box). /// </summary> /// ------------------------------------------------------------------------------------ private void HandleBinderTranslateBoundValueBeingSaved(object sender, TranslateBoundValueBeingSavedArgs args) { if (args.BoundControl == _participants) { var participantNames = FieldInstance.GetMultipleValuesFromText(_participants.Text).ToArray(); for (int index = 0; index < participantNames.Length; index++) { var person = _personInformant.GetPersonByNameOrCode(participantNames[index]); if (person != null) { participantNames[index] = person.Id; } } args.NewValue = FieldInstance.GetTextFromMultipleValues(participantNames); } }