public void TestFilter_GetSetFilterName() { // Substitute of the interface Filter var filterSub = Substitute.For <IInterfaceFilter>(); // Give a new Name to the filter string newName = "Rainbow"; // Give to the filterSub the new name filterSub.GetFilterName().Returns <string>(newName); // Set the filter with the new name iFilter.SetFilterName(newName); // Check if the names are equals Assert.AreEqual(iFilter.GetFilterName(), filterSub.GetFilterName()); }
// Manage the combo box for the filters // Apply the filter when one is selected private void ComboBoxFilter_SelectedIndexChanged(object sender, EventArgs e) { // If the combobox is selected > 0 It means that one filter was selected // So the user can choose a Edge to apply (enable the combobox edge) if (comboBoxFilter.SelectedIndex > 0) { SetComboboxEdgeActive(true); } // If the combobox is selected < 0 It means that no filter was selected // So the user cannot choose an Edge until he hasn't chose a filter (disable the combobox edge) else { SetComboboxEdgeActive(false); } // Once a filter/no filter was choosen by the user it will be applied on the bitmap loaded try { // Get the original bitmap to apply the filter currentBitmapFilter = inputManager.GetOriginalImageFromFile().CopyToSquareCanvas(pictureBoxForImageLoaded.Width); // Get the name of the filter selected by the user and add it to the interface filter filter.SetFilterName(comboBoxFilter.SelectedItem.ToString()); // Apply the filter selected on the bitmap through the manager currentBitmapFilter = filterManager.ApplyFilter(currentBitmapFilter, filter); // Put the bimtap with the applied filter on the picture box pictureBoxForImageLoaded.Image = currentBitmapFilter; } // If there is any exception it will be catch and set the bitmap to null catch (Exception ex) { Console.WriteLine(e); pictureBoxForImageLoaded.Image = null; } }