public void FindByValue_CollectionEmpty() { Dictionary <int, string> collection = new Dictionary <int, string>(); Dictionary <int, string> foundItems = collection.FindByValue("d"); Assert.IsTrue(foundItems != null && foundItems.Count == 0); }
public void FindByValue_EqualityOnDerivation() { Dictionary <int, object> collection = new Dictionary <int, object>(); collection.Add(0, new object()); collection.Add(1, 1); collection.Add(2, "a"); Dictionary <int, object> foundItems = collection.FindByValue("a"); Assert.IsTrue(foundItems.Count == 1); }
public void FindByValue_ItemDoesNotExist() { Dictionary <int, string> collection = new Dictionary <int, string>(); collection.Add(0, "a"); collection.Add(1, "b"); collection.Add(2, "c"); Dictionary <int, string> foundItems = collection.FindByValue("d"); Assert.IsTrue(foundItems.Count == 0); }
public void FindByValue_ItemExistsMoreThanOnce() { Dictionary <int, string> collection = new Dictionary <int, string>(); collection.Add(0, "a"); collection.Add(1, "b"); collection.Add(2, "c"); collection.Add(3, "c"); collection.Add(4, "c"); Dictionary <int, string> foundItems = collection.FindByValue("c"); Assert.IsTrue(foundItems.Count == 3); Assert.IsTrue(foundItems.ContainsKey(2) && foundItems[2] == "c"); Assert.IsTrue(foundItems.ContainsKey(3) && foundItems[3] == "c"); Assert.IsTrue(foundItems.ContainsKey(4) && foundItems[4] == "c"); }
public void FindByValue_CollectionEmpty() { Dictionary<int, string> collection = new Dictionary<int, string>(); Dictionary<int, string> foundItems = collection.FindByValue("d"); Assert.IsTrue(foundItems != null && foundItems.Count == 0); }
public void FindByValue_EqualityOnDerivation() { Dictionary<int, object> collection = new Dictionary<int,object>(); collection.Add(0, new object()); collection.Add(1, 1); collection.Add(2, "a"); Dictionary<int, object> foundItems = collection.FindByValue("a"); Assert.IsTrue(foundItems.Count == 1); }
public void FindByValue_ItemExistsMoreThanOnce() { Dictionary<int, string> collection = new Dictionary<int, string>(); collection.Add(0, "a"); collection.Add(1, "b"); collection.Add(2, "c"); collection.Add(3, "c"); collection.Add(4, "c"); Dictionary<int, string> foundItems = collection.FindByValue("c"); Assert.IsTrue(foundItems.Count == 3); Assert.IsTrue(foundItems.ContainsKey(2) && foundItems[2] == "c"); Assert.IsTrue(foundItems.ContainsKey(3) && foundItems[3] == "c"); Assert.IsTrue(foundItems.ContainsKey(4) && foundItems[4] == "c"); }
public void FindByValue_ItemDoesNotExist() { Dictionary<int, string> collection = new Dictionary<int, string>(); collection.Add(0, "a"); collection.Add(1, "b"); collection.Add(2, "c"); Dictionary<int, string> foundItems = collection.FindByValue("d"); Assert.IsTrue(foundItems.Count == 0); }
public void CreateAdditionalActionsButtons(FilePresenterButtonInfo[] additionalActions) { foreach (FilePresenterButtonInfo buttonInfo in additionalActions) { ButtonBase b; if (!buttonInfo.ToggleButton && !buttonInfo.RadioToggleButton) { b = new Button(); } else if (buttonInfo.RadioToggleButton) { Style style = new Style { TargetType = typeof(System.Windows.Controls.RadioButton) }; System.Windows.Controls.RadioButton radioButton = new System.Windows.Controls.RadioButton() { Style = style, IsChecked = buttonInfo.IsToggled }; radioButton.Checked += (sender, args) => buttonInfo.IsToggled = radioButton.IsChecked == true; radioButton.GroupName = "AAA"; b = radioButton; } else { ToggleButton toggleButton = new ToggleButton { IsChecked = buttonInfo.IsToggled }; toggleButton.Checked += (sender, args) => buttonInfo.IsToggled = toggleButton.IsChecked == true; b = toggleButton; } additionalButtons[buttonInfo] = b; if (!string.IsNullOrEmpty(buttonInfo.ButtonName)) { b.Name = buttonInfo.ButtonName; } StackPanel stackPanel = new StackPanel(); stackPanel.Orientation = Orientation.Horizontal; b.Content = stackPanel; stackPanel.Children.Add(new Image() { Source = buttonInfo.Icon, Height = 16, Margin = ViewToolkitResources.Thickness2 }); stackPanel.Children.Add(new System.Windows.Controls.Label() { Content = buttonInfo.Text, Padding = ViewToolkitResources.Thickness2 }); b.Click += delegate(object sender, RoutedEventArgs args) { ButtonBase bSender = (ButtonBase)sender; if (bSender is ToggleButton) { foreach (KeyValuePair <FilePresenterButtonInfo, ButtonBase> otherButton in additionalButtons) { if (otherButton.Value is System.Windows.Controls.RadioButton && !otherButton.Value.Equals(sender)) { otherButton.Key.IsToggled = false; } } additionalButtons.FindByValue(bSender).Key.IsToggled = ((ToggleButton)sender).IsChecked == true; } additionalButtons.FindByValue(bSender).Key.UpdateFileContentAction(this); }; MainToolBar.Items.Add(b); filePresenterButtons.Add(buttonInfo); } }
public void FindByValue_CollectionNull() { Dictionary <int, int> collection = null; collection.FindByValue(0); }