Skip to content

Commit

Permalink
Move explicit tests to issue #202.
Browse files Browse the repository at this point in the history
  • Loading branch information
JohanLarsson committed Jul 19, 2018
1 parent 8e50613 commit 03336b8
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 224 deletions.
112 changes: 0 additions & 112 deletions WpfAnalyzers.Test/WPF0019CastSenderToCorrectTypeTests/CodeFix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -310,118 +310,6 @@ private static void OnValueChanged(DependencyObject d, DependencyPropertyChanged
AnalyzerAssert.CodeFix(Analyzer, Fix, ExpectedDiagnostic, testCode, fixedCode);
}

[Explicit("Not handling this yet, will be a bit messy as we need to get the type from the arguments in the getvalue & setvalue methods and can still not be sure. Perhaps limited value?.")]
[Test]
public void DependencyPropertyRegisterAttached()
{
var testCode = @"
namespace RoslynSandbox
{
using System.Windows;
public static class Foo
{
public static readonly DependencyProperty BarProperty = DependencyProperty.RegisterAttached(
""Bar"",
typeof(int),
typeof(Foo),
new PropertyMetadata(1, OnValueChanged));
public static void SetBar(this FrameworkElement element, int value) => element.SetValue(BarProperty, value);
public static int GetBar(this FrameworkElement element) => (int)element.GetValue(BarProperty);
private static void OnValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var control = (↓DataGrid)d;
}
}
}";

var fixedCode = @"
namespace RoslynSandbox
{
using System.Windows;
public static class Foo
{
public static readonly DependencyProperty BarProperty = DependencyProperty.RegisterAttached(
""Bar"",
typeof(int),
typeof(Foo),
new PropertyMetadata(1, OnBarChanged));
public static void SetBar(this FrameworkElement element, int value) => element.SetValue(BarProperty, value);
public static int GetBar(this FrameworkElement element) => (int)element.GetValue(BarProperty);
private static void OnBarChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var control = (↓DataGrid)d;
}
}
}";
AnalyzerAssert.CodeFix(Analyzer, Fix, ExpectedDiagnostic, testCode, fixedCode);
}

[Explicit("Not handling this yet, will be a bit messy as we need to get the type from the arguments in the getvalue & setvalue methods and can still not be sure. Perhaps limited value?.")]
[Test]
public void DependencyPropertyRegisterAttachedReadOnly()
{
var testCode = @"
namespace RoslynSandbox
{
using System.Windows;
public static class Foo
{
private static readonly DependencyPropertyKey BarPropertyKey = DependencyProperty.RegisterAttachedReadOnly(
""Bar"",
typeof(int),
typeof(Foo),
new PropertyMetadata(default(int), OnValueChanged));
public static readonly DependencyProperty BarProperty = BarPropertyKey.DependencyProperty;
public static void SetBar(this FrameworkElement element, int value) => element.SetValue(BarPropertyKey, value);
public static int GetBar(this FrameworkElement element) => (int)element.GetValue(BarProperty);
private static void OnValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var control = (↓DataGrid)d;
}
}
}";

var fixedCode = @"
namespace RoslynSandbox
{
using System.Windows;
public static class Foo
{
private static readonly DependencyPropertyKey BarPropertyKey = DependencyProperty.RegisterAttachedReadOnly(
""Bar"",
typeof(int),
typeof(Foo),
new PropertyMetadata(default(int), OnBarChanged));
public static readonly DependencyProperty BarProperty = BarPropertyKey.DependencyProperty;
public static void SetBar(this FrameworkElement element, int value) => element.SetValue(BarPropertyKey, value);
public static int GetBar(this FrameworkElement element) => (int)element.GetValue(BarProperty);
private static void OnBarChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var control = (↓DataGrid)d;
}
}
}";
AnalyzerAssert.CodeFix(Analyzer, Fix, ExpectedDiagnostic, testCode, fixedCode);
}

[Test]
public void DependencyPropertyOverrideMetadata()
{
Expand Down
112 changes: 0 additions & 112 deletions WpfAnalyzers.Test/WPF0021DirectCastSenderToExactTypeTests/CodeFix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -306,118 +306,6 @@ private static void OnValueChanged(DependencyObject d, DependencyPropertyChanged
AnalyzerAssert.CodeFix(Analyzer, Fix, ExpectedDiagnostic, testCode, fixedCode);
}

[Explicit("Not handling this yet, will be a bit messy as we need to get the type from the arguments in the getvalue & setvalue methods and can still not be sure. Perhaps limited value?.")]
[Test]
public void DependencyPropertyRegisterAttached()
{
var testCode = @"
namespace RoslynSandbox
{
using System.Windows;
public static class Foo
{
public static readonly DependencyProperty BarProperty = DependencyProperty.RegisterAttached(
""Bar"",
typeof(int),
typeof(Foo),
new PropertyMetadata(1, OnBarChanged));
public static void SetBar(this FrameworkElement element, int value) => element.SetValue(BarProperty, value);
public static int GetBar(this FrameworkElement element) => (int)element.GetValue(BarProperty);
private static void OnBarChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var control = (↓DataGrid)d;
}
}
}";

var fixedCode = @"
namespace RoslynSandbox
{
using System.Windows;
public static class Foo
{
public static readonly DependencyProperty BarProperty = DependencyProperty.RegisterAttached(
""Bar"",
typeof(int),
typeof(Foo),
new PropertyMetadata(1, OnBarChanged));
public static void SetBar(this FrameworkElement element, int value) => element.SetValue(BarProperty, value);
public static int GetBar(this FrameworkElement element) => (int)element.GetValue(BarProperty);
private static void OnBarChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var control = (FrameworkElement)d;
}
}
}";
AnalyzerAssert.CodeFix(Analyzer, Fix, ExpectedDiagnostic, testCode, fixedCode);
}

[Explicit("Not handling this yet, will be a bit messy as we need to get the type from the arguments in the getvalue & setvalue methods and can still not be sure. Perhaps limited value?.")]
[Test]
public void DependencyPropertyRegisterAttachedReadOnly()
{
var testCode = @"
namespace RoslynSandbox
{
using System.Windows;
public static class Foo
{
private static readonly DependencyPropertyKey BarPropertyKey = DependencyProperty.RegisterAttachedReadOnly(
""Bar"",
typeof(int),
typeof(Foo),
new PropertyMetadata(default(int), OnBarChanged));
public static readonly DependencyProperty BarProperty = BarPropertyKey.DependencyProperty;
public static void SetBar(this FrameworkElement element, int value) => element.SetValue(BarPropertyKey, value);
public static int GetBar(this FrameworkElement element) => (int)element.GetValue(BarProperty);
private static void OnBarChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var control = (↓DataGrid)d;
}
}
}";

var fixedCode = @"
namespace RoslynSandbox
{
using System.Windows;
public static class Foo
{
private static readonly DependencyPropertyKey BarPropertyKey = DependencyProperty.RegisterAttachedReadOnly(
""Bar"",
typeof(int),
typeof(Foo),
new PropertyMetadata(default(int), OnBarChanged));
public static readonly DependencyProperty BarProperty = BarPropertyKey.DependencyProperty;
public static void SetBar(this FrameworkElement element, int value) => element.SetValue(BarPropertyKey, value);
public static int GetBar(this FrameworkElement element) => (int)element.GetValue(BarProperty);
private static void OnBarChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var control = (FrameworkElement)d;
}
}
}";
AnalyzerAssert.CodeFix(Analyzer, Fix, ExpectedDiagnostic, testCode, fixedCode);
}

[Test]
public void DependencyPropertyOverrideMetadata()
{
Expand Down

0 comments on commit 03336b8

Please sign in to comment.