public void TestToggleSwitch() { ToggleSwitch toggle = new ToggleSwitch(); Ellipse ToggleButton = (Ellipse)toggle.FindName("ToggleRect"); Output ToggleOutput = (Output)toggle.FindName("Output"); Assert.IsTrue(ToggleOutput.State == false); //Simulate click on the toggle button ToggleButton.RaiseEvent(new MouseButtonEventArgs(Mouse.PrimaryDevice, 0, MouseButton.Left) { RoutedEvent = Mouse.MouseDownEvent, Source = this }); ToggleOutput.CallChange(); Assert.IsTrue(ToggleOutput.State == true); }