public void GetSpeciesObservationViewModel_ObservationWithProjectParameters_ProjectIsPopulatedInModel() { // Constants const string projectName = "My project"; const int observationId = 150; const string projectParameterName1 = "Degrees"; const string projectParameterValue1 = "25"; const string projectParamterPropertyIdentifier1 = "MyPropIdentifier1"; // Arrange LoginApplicationUser(); SpeciesObservationDataManager speciesObservationDataManager = new SpeciesObservationDataManager(SessionHandler.UserContext, SessionHandler.MySettings); // Arrange - Mock CoreData.SpeciesObservationManager.DataSource = new StubISpeciesObservationDataSource() { GetSpeciesObservationsIUserContextListOfInt64ICoordinateSystemISpeciesObservationSpecification = (userContext, speciesObservationIds, coordinateSystem, speciesObservationSpecification) => { SpeciesObservationList speciesObservationList = new SpeciesObservationList(); ISpeciesObservation speciesObservation = new ArtDatabanken.Data.SpeciesObservation(); speciesObservation.Id = observationId; speciesObservation.Project = new SpeciesObservationProject { ProjectName = projectName, ProjectParameters = new SpeciesObservationProjectParameterList { new SpeciesObservationProjectParameter { PropertyIdentifier = projectParamterPropertyIdentifier1, ProjectName = projectName, Property = projectParameterName1, Value = projectParameterValue1 } } }; speciesObservationList.Add(speciesObservation); return(speciesObservationList); } }; // Act var speciesObservationViewModel = speciesObservationDataManager.GetSpeciesObservationViewModel(observationId); // Assert Assert.AreEqual(1, speciesObservationViewModel.Projects.Count); Assert.AreEqual(projectName, speciesObservationViewModel.Projects[0].Name); Assert.AreEqual(projectParameterName1, speciesObservationViewModel.Projects[0].ProjectParameters[projectParamterPropertyIdentifier1].Name); Assert.AreEqual(projectParameterValue1, speciesObservationViewModel.Projects[0].ProjectParameters[projectParamterPropertyIdentifier1].Value); }
/// <summary> /// Creates the observation details view model. /// </summary> /// <param name="observationId">The observation identifier.</param> /// <param name="showAsDialog">if set to <c>true</c> the create models ShowAsDialog property is set to true.</param> /// <returns>A observation detail view model.</returns> public ObservationDetailViewModel CreateObservationDetailsViewModel(string observationId, bool showAsDialog) { ObservationDetailViewModel model = new ObservationDetailViewModel(); model.ObservationId = observationId; model.ShowAsDialog = showAsDialog; try { int obsId = int.Parse(observationId); SpeciesObservationDataManager speciesObservationDataManager = new SpeciesObservationDataManager(UserContext, MySettings); var speciesObservationViewModel = speciesObservationDataManager.GetSpeciesObservationViewModel(obsId); model.Projects = speciesObservationViewModel.Projects; model.Fields = speciesObservationDataManager.GetObservationDetailFields(speciesObservationViewModel); RemoveNewLinesInValueString(speciesObservationDataManager, model); } catch { } return(model); }