コード例 #1
0
        public void CalculationsView_Always_BreakWaterTypeComboboxCorrectlyInitialized()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            ConfigureHydraulicBoundaryDatabase(assessmentSection);
            mocks.ReplayAll();

            ClosingStructuresFailureMechanism failureMechanism = ConfigureFailureMechanism();

            // Call
            ShowCalculationsView(ConfigureCalculationGroup(failureMechanism, assessmentSection), failureMechanism, assessmentSection);

            // Assert
            var dataGridView           = (DataGridView) new ControlTester("dataGridView").TheObject;
            var breakWaterTypeComboBox = (DataGridViewComboBoxColumn)dataGridView.Columns[breakWaterTypeColumnIndex];

            DataGridViewComboBoxCell.ObjectCollection breakWaterTypeComboBoxItems = breakWaterTypeComboBox.Items;
            Assert.AreEqual(3, breakWaterTypeComboBoxItems.Count);
            Assert.AreEqual("Muur", breakWaterTypeComboBoxItems[0].ToString());
            Assert.AreEqual("Caisson", breakWaterTypeComboBoxItems[1].ToString());
            Assert.AreEqual("Havendam", breakWaterTypeComboBoxItems[2].ToString());
            mocks.VerifyAll();
        }
コード例 #2
0
        public void Constructor_DataGridViewCorrectlyInitialized()
        {
            // Call
            ShowMacroStabilityInwardsCalculationsView(new CalculationGroup(), new MacroStabilityInwardsFailureMechanism(), new AssessmentSectionStub());

            var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject;

            // Assert
            Assert.IsFalse(dataGridView.AutoGenerateColumns);
            Assert.AreEqual(5, dataGridView.ColumnCount);

            Assert.AreEqual("Naam", dataGridView.Columns[nameColumnIndex].HeaderText);
            Assert.AreEqual("Hydraulische belastingenlocatie", dataGridView.Columns[selectableHydraulicBoundaryLocationsColumnIndex].HeaderText);
            Assert.AreEqual("Stochastisch ondergrondmodel", dataGridView.Columns[stochasticSoilModelsColumnIndex].HeaderText);
            Assert.AreEqual("Ondergrondschematisatie", dataGridView.Columns[stochasticSoilProfilesColumnIndex].HeaderText);
            Assert.AreEqual("Aandeel van schematisatie\r\nin het stochastische ondergrondmodel\r\n[%]", dataGridView.Columns[stochasticSoilProfilesProbabilityColumnIndex].HeaderText);

            foreach (DataGridViewComboBoxColumn column in dataGridView.Columns.OfType <DataGridViewComboBoxColumn>())
            {
                Assert.AreEqual("This", column.ValueMember);
                Assert.AreEqual("DisplayName", column.DisplayMember);
            }

            var soilProfilesCombobox = (DataGridViewComboBoxColumn)dataGridView.Columns[stochasticSoilProfilesColumnIndex];

            DataGridViewComboBoxCell.ObjectCollection soilProfilesComboboxItems = soilProfilesCombobox.Items;
            Assert.AreEqual(1, soilProfilesComboboxItems.Count); // Row dependent

            var hydraulicBoundaryLocationCombobox = (DataGridViewComboBoxColumn)dataGridView.Columns[selectableHydraulicBoundaryLocationsColumnIndex];

            DataGridViewComboBoxCell.ObjectCollection hydraulicBoundaryLocationComboboxItems = hydraulicBoundaryLocationCombobox.Items;
            Assert.AreEqual(1, hydraulicBoundaryLocationComboboxItems.Count); // Row dependent
        }
コード例 #3
0
        public void CalculationsView_FailureMechanismWithForeshoreProfiles_ForeshoreProfilesComboboxCorrectlyInitialized()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            ConfigureHydraulicBoundaryDatabase(assessmentSection);
            mocks.ReplayAll();

            ClosingStructuresFailureMechanism failureMechanism = ConfigureFailureMechanism();

            // Call
            ShowCalculationsView(ConfigureCalculationGroup(failureMechanism, assessmentSection), failureMechanism, assessmentSection);

            // Assert
            var dataGridView             = (DataGridView) new ControlTester("dataGridView").TheObject;
            var foreshoreProfileComboBox = (DataGridViewComboBoxColumn)dataGridView.Columns[foreshoreProfileColumnIndex];

            DataGridViewComboBoxCell.ObjectCollection foreshoreProfileComboBoxItems = foreshoreProfileComboBox.Items;
            Assert.AreEqual(3, foreshoreProfileComboBoxItems.Count);
            Assert.AreEqual("<selecteer>", foreshoreProfileComboBoxItems[0].ToString());
            Assert.AreEqual("Profiel 1", foreshoreProfileComboBoxItems[1].ToString());
            Assert.AreEqual("Profiel 2", foreshoreProfileComboBoxItems[2].ToString());
            mocks.VerifyAll();
        }
コード例 #4
0
        public void CalculationsView_FailureMechanismWithCorrespondingSoilProfiles_SoilProfilesComboboxCorrectlyInitialized()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            ConfigureHydraulicBoundaryDatabase(assessmentSection);
            mocks.ReplayAll();

            MacroStabilityInwardsFailureMechanism failureMechanism = ConfigureFailureMechanism();

            // Call
            ShowMacroStabilityInwardsCalculationsView(ConfigureCalculationGroup(assessmentSection, failureMechanism),
                                                      failureMechanism, assessmentSection);

            var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject;

            // Assert
            DataGridViewComboBoxCell.ObjectCollection soilProfilesComboboxItems = ((DataGridViewComboBoxCell)dataGridView.Rows[0].Cells[stochasticSoilProfilesColumnIndex]).Items;
            Assert.AreEqual(3, soilProfilesComboboxItems.Count);
            Assert.AreEqual("<selecteer>", soilProfilesComboboxItems[0].ToString());
            Assert.AreEqual("Profile 1", soilProfilesComboboxItems[1].ToString());
            Assert.AreEqual("Profile 2", soilProfilesComboboxItems[2].ToString());

            soilProfilesComboboxItems = ((DataGridViewComboBoxCell)dataGridView.Rows[1].Cells[stochasticSoilProfilesColumnIndex]).Items;
            Assert.AreEqual(2, soilProfilesComboboxItems.Count);
            Assert.AreEqual("<selecteer>", soilProfilesComboboxItems[0].ToString());
            Assert.AreEqual("Profile 5", soilProfilesComboboxItems[1].ToString());

            mocks.VerifyAll();
        }
コード例 #5
0
        public void GivenCalculationsView_WhenHydraulicBoundaryDatabaseWithLocationsUpdatedAndNotified_ThenSelectableHydraulicBoundaryLocationsComboboxCorrectlyUpdated()
        {
            // Given
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            ConfigureHydraulicBoundaryDatabase(assessmentSection);
            mocks.ReplayAll();

            ShowCalculationsView(ConfigureCalculationGroup(assessmentSection), new TestCalculatableFailureMechanism(), assessmentSection);

            var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject;
            var hydraulicBoundaryLocationCombobox = (DataGridViewComboBoxColumn)dataGridView.Columns[selectableHydraulicBoundaryLocationsColumnIndex];

            // Precondition
            Assert.AreEqual(5, hydraulicBoundaryLocationCombobox.Items.Count);

            // When
            assessmentSection.HydraulicBoundaryDatabase.Locations.Add(new HydraulicBoundaryLocation(3, "Location 3", 5.5, 6.6));
            assessmentSection.HydraulicBoundaryDatabase.Locations.NotifyObservers();

            // Then
            DataGridViewComboBoxCell.ObjectCollection hydraulicBoundaryLocationComboboxItems = hydraulicBoundaryLocationCombobox.Items;
            Assert.AreEqual(7, hydraulicBoundaryLocationComboboxItems.Count);
            Assert.AreEqual("<selecteer>", hydraulicBoundaryLocationComboboxItems[0].ToString());
            Assert.AreEqual("Location 1 (2 m)", hydraulicBoundaryLocationComboboxItems[1].ToString());
            Assert.AreEqual("Location 2 (6 m)", hydraulicBoundaryLocationComboboxItems[2].ToString());
            Assert.AreEqual("Location 3 (9 m)", hydraulicBoundaryLocationComboboxItems[3].ToString());
            Assert.AreEqual("Location 1 (4 m)", hydraulicBoundaryLocationComboboxItems[4].ToString());
            Assert.AreEqual("Location 2 (5 m)", hydraulicBoundaryLocationComboboxItems[5].ToString());
            Assert.AreEqual("Location 3 (7 m)", hydraulicBoundaryLocationComboboxItems[6].ToString());
            mocks.VerifyAll();
        }
コード例 #6
0
        public void Constructor_HydraulicBoundaryDatabaseWithLocations_SelectableHydraulicBoundaryLocationsComboboxCorrectlyInitialized()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            ConfigureHydraulicBoundaryDatabase(assessmentSection);
            mocks.ReplayAll();

            // Call
            ShowCalculationsView(ConfigureCalculationGroup(assessmentSection), new TestCalculatableFailureMechanism(), assessmentSection);

            // Assert
            var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject;
            var hydraulicBoundaryLocationCombobox = (DataGridViewComboBoxColumn)dataGridView.Columns[selectableHydraulicBoundaryLocationsColumnIndex];

            DataGridViewComboBoxCell.ObjectCollection hydraulicBoundaryLocationComboboxItems = hydraulicBoundaryLocationCombobox.Items;
            Assert.AreEqual(5, hydraulicBoundaryLocationComboboxItems.Count);
            Assert.AreEqual("<selecteer>", hydraulicBoundaryLocationComboboxItems[0].ToString());
            Assert.AreEqual("Location 1 (2 m)", hydraulicBoundaryLocationComboboxItems[1].ToString());
            Assert.AreEqual("Location 2 (6 m)", hydraulicBoundaryLocationComboboxItems[2].ToString());
            Assert.AreEqual("Location 1 (4 m)", hydraulicBoundaryLocationComboboxItems[3].ToString());
            Assert.AreEqual("Location 2 (5 m)", hydraulicBoundaryLocationComboboxItems[4].ToString());
            mocks.VerifyAll();
        }
コード例 #7
0
        /// <summary>
        /// Show the list of parameters available for logging
        /// </summary>
        /// <param name="database">parameter database</param>
        void IUserInterface.PopulateParameterList(ParameterDatabase database)
        {
            Trace("PopulateParameterList");

            this.parameterGrid.Rows.Clear();

            foreach (Parameter parameter in database.Parameters)
            {
                DataGridViewRow row = new DataGridViewRow();
                row.CreateCells(this.parameterGrid);
                row.Cells[(int)GridColumns.Enabled].Value   = false;
                row.Cells[(int)GridColumns.Parameter].Value = parameter;

                DataGridViewComboBoxCell cell = (DataGridViewComboBoxCell)row.Cells[(int)GridColumns.Conversions];
                cell.DisplayMember = "Units";
                foreach (Conversion conversion in parameter.Conversions)
                {
                    DataGridViewComboBoxCell.ObjectCollection items = cell.Items;
                    items.Add(conversion);
                }
                Conversion defaultConversion = parameter.Conversions[0];
                cell.Value = defaultConversion;

                this.parameterGrid.Rows.Add(row);
            }

            this.parameterGrid.Sort(this.parameterGrid.Columns[1], ListSortDirection.Ascending);
        }
コード例 #8
0
        /// <summary>
        /// Returns possible destination files for given project item
        /// </summary>
        private DataGridViewComboBoxCell.ObjectCollection CreateDestinationOptions(DataGridViewComboBoxCell cell, ProjectItem item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            if (!destinationItemsCache.ContainsKey(item.ContainingProject))
            {
                DataGridViewComboBoxCell.ObjectCollection resxItems = new DataGridViewComboBoxCell.ObjectCollection(cell);
                foreach (ResXProjectItem projectItem in item.ContainingProject.GetResXItemsAround(true, false))
                {
                    if (!string.IsNullOrEmpty(projectItem.Class) && !string.IsNullOrEmpty(projectItem.Namespace))
                    {
                        string key = projectItem.ToString();
                        resxItems.Add(key);
                        if (!resxItemsCache.ContainsKey(key))
                        {
                            resxItemsCache.Add(key, projectItem);
                        }
                    }
                }
                destinationItemsCache.Add(item.ContainingProject, resxItems);
            }

            return(destinationItemsCache[item.ContainingProject]);
        }
コード例 #9
0
        private void PopulateStatusComboBox(DataGridViewComboBoxCell.ObjectCollection collection)
        {
            var values = Enum.GetValues(typeof(RecordStatus));

            foreach (var value in values)
            {
                collection.Add(value.ToString());
            }
        }
コード例 #10
0
        public void GivenCalculationsView_WhenStochasticSoilModelsUpdatedAndNotified_ThenStochasticSoilModelsAndStochasticSoilProfilesComboboxCorrectlyUpdated()
        {
            // Given
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            ConfigureHydraulicBoundaryDatabase(assessmentSection);
            mocks.ReplayAll();

            MacroStabilityInwardsFailureMechanism failureMechanism = ConfigureFailureMechanism();

            ShowMacroStabilityInwardsCalculationsView(ConfigureCalculationGroup(assessmentSection, failureMechanism), failureMechanism, assessmentSection);

            var dataGridView         = (DataGridView) new ControlTester("dataGridView").TheObject;
            var soilModelsComboBox   = (DataGridViewComboBoxColumn)dataGridView.Columns[stochasticSoilModelsColumnIndex];
            var soilProfilesComboBox = (DataGridViewComboBoxColumn)dataGridView.Columns[stochasticSoilProfilesColumnIndex];

            // Precondition
            Assert.AreEqual(4, soilModelsComboBox.Items.Count);
            Assert.AreEqual(6, soilProfilesComboBox.Items.Count);

            // When
            failureMechanism.StochasticSoilModels.AddRange(new[]
            {
                MacroStabilityInwardsStochasticSoilModelTestFactory.CreateValidStochasticSoilModel("Model F", new[]
                {
                    new Point2D(0.0, 0.0),
                    new Point2D(5.0, 0.0)
                })
            }, string.Empty);
            failureMechanism.StochasticSoilModels.NotifyObservers();

            // Then
            DataGridViewComboBoxCell.ObjectCollection soilModelItems   = soilModelsComboBox.Items;
            DataGridViewComboBoxCell.ObjectCollection soilProfileItems = soilProfilesComboBox.Items;
            Assert.AreEqual(5, soilModelItems.Count);
            Assert.AreEqual("<selecteer>", soilModelItems[0].ToString());
            Assert.AreEqual("Model A", soilModelItems[1].ToString());
            Assert.AreEqual("Model C", soilModelItems[2].ToString());
            Assert.AreEqual("Model E", soilModelItems[3].ToString());
            Assert.AreEqual("Model F", soilModelItems[4].ToString());

            Assert.AreEqual(8, soilProfileItems.Count);
            Assert.AreEqual("<selecteer>", soilProfileItems[0].ToString());
            Assert.AreEqual("Profile 1", soilProfileItems[1].ToString());
            Assert.AreEqual("Profile 2", soilProfileItems[2].ToString());
            Assert.AreEqual("Profile 3", soilProfileItems[3].ToString());
            Assert.AreEqual("Profile 4", soilProfileItems[4].ToString());
            Assert.AreEqual("Profile 5", soilProfileItems[5].ToString());
            Assert.AreEqual("A", soilProfileItems[6].ToString());

            mocks.VerifyAll();
        }
コード例 #11
0
        // Добавление в список пунктов в ComboBoxColumn
        private void AddRangeComboBoxColumn(DataGridViewComboBoxCell.ObjectCollection cbcell, Type type)
        {
            SortedList <int, NameAndCount> listNameServiceCount;
            Dictionary <int, int>          listClientNameServiceCount;

            if (type == typeof(NameWork))
            {
                listNameServiceCount       = AllNameWorks;
                listClientNameServiceCount = CurrentClient.NWCounts;
            }
            else if (type == typeof(NameDevice))
            {
                listNameServiceCount       = AllNameDevices;
                listClientNameServiceCount = CurrentClient.NDCounts;
            }
            else
            {
                listNameServiceCount       = AllAddInfo;
                listClientNameServiceCount = CurrentClient.AICounts;
            }

            // Заполнение пунктами из списка клиента с сортировкой по количеству использования в порядке убывания

            //listClientNameServiceCount.OrderByDescending(k => k.Value)
            //                          .Select(k => cbcell.Add(listNameServiceCount[k.Key].Name));

            IEnumerable <string> ls = listClientNameServiceCount.OrderByDescending(k => k.Value)
                                      .Select(k => listNameServiceCount[k.Key].Name);

            foreach (string s in ls)
            {
                cbcell.Add(s);
            }

            // Остальные пункты, не входящие в список клиента, тоже в порядке убывания

            //listNameServiceCount.OrderByDescending(k => k.Value.Count)
            //                    .Where(k => !listClientNameServiceCount.ContainsKey(k.Key))
            //                    .Select(k => cbcell.Add(listNameServiceCount[k.Key].Name));

            ls = listNameServiceCount.OrderByDescending(k => k.Value.Count)
                 .Where(k => !listClientNameServiceCount.ContainsKey(k.Key))
                 .Select(k => listNameServiceCount[k.Key].Name);

            foreach (string s in ls)
            {
                cbcell.Add(s);
            }
        }
コード例 #12
0
        public void GivenCalculationsView_WhenForeshoreProfilesUpdatedAndNotified_ThenForeshoreProfilesComboboxCorrectlyUpdated()
        {
            // Given
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            ConfigureHydraulicBoundaryDatabase(assessmentSection);
            mocks.ReplayAll();

            ClosingStructuresFailureMechanism failureMechanism = ConfigureFailureMechanism();

            ShowCalculationsView(ConfigureCalculationGroup(failureMechanism, assessmentSection), failureMechanism, assessmentSection);

            var dataGridView             = (DataGridView) new ControlTester("dataGridView").TheObject;
            var foreshoreProfileComboBox = (DataGridViewComboBoxColumn)dataGridView.Columns[foreshoreProfileColumnIndex];

            // Precondition
            Assert.AreEqual(3, foreshoreProfileComboBox.Items.Count);

            // When
            failureMechanism.ForeshoreProfiles.AddRange(new[]
            {
                new TestForeshoreProfile("Profiel 3", "3"),
                new TestForeshoreProfile("Profiel 4", "4")
            }, string.Empty);
            failureMechanism.ForeshoreProfiles.NotifyObservers();

            // Then
            DataGridViewComboBoxCell.ObjectCollection foreshoreProfileItems = foreshoreProfileComboBox.Items;
            Assert.AreEqual(5, foreshoreProfileItems.Count);
            Assert.AreEqual("<selecteer>", foreshoreProfileItems[0].ToString());
            Assert.AreEqual("Profiel 1", foreshoreProfileItems[1].ToString());
            Assert.AreEqual("Profiel 2", foreshoreProfileItems[2].ToString());
            Assert.AreEqual("Profiel 3", foreshoreProfileItems[3].ToString());
            Assert.AreEqual("Profiel 4", foreshoreProfileItems[4].ToString());

            mocks.VerifyAll();
        }