PageRenderTime 40ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/src/Libraries/NRefactory/ICSharpCode.NRefactory.Tests/CSharp/CodeIssues/AdditionalOfTypeIssuesTests.cs

https://github.com/pombredanne/SharpDevelop
C# | 77 lines | 43 code | 9 blank | 25 comment | 0 complexity | db2482848204ebd34d98412aeb87f1e5 MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, CC-BY-SA-3.0, Apache-2.0, BSD-3-Clause, LGPL-2.0, CC-BY-3.0
  1. //
  2. // AdditionalOfTypeIssuesTests.cs
  3. //
  4. // Author:
  5. // Mike Kr端ger <mkrueger@xamarin.com>
  6. //
  7. // Copyright (c) 2013 Xamarin Inc. (http://xamarin.com)
  8. //
  9. // Permission is hereby granted, free of charge, to any person obtaining a copy
  10. // of this software and associated documentation files (the "Software"), to deal
  11. // in the Software without restriction, including without limitation the rights
  12. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  13. // copies of the Software, and to permit persons to whom the Software is
  14. // furnished to do so, subject to the following conditions:
  15. //
  16. // The above copyright notice and this permission notice shall be included in
  17. // all copies or substantial portions of the Software.
  18. //
  19. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  22. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  23. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  24. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  25. // THE SOFTWARE.
  26. using System;
  27. using NUnit.Framework;
  28. using ICSharpCode.NRefactory.CSharp.Refactoring;
  29. using ICSharpCode.NRefactory.CSharp.CodeActions;
  30. using System.Linq;
  31. namespace ICSharpCode.NRefactory.CSharp.CodeIssues
  32. {
  33. [TestFixture]
  34. public class AdditionalOfTypeIssuesTests : InspectionActionTestBase
  35. {
  36. [Test]
  37. public void TestAdditionalCase ()
  38. {
  39. Test<AdditionalOfTypeIssues>(@"using System.Linq;
  40. class Test
  41. {
  42. public void Foo(object[] obj)
  43. {
  44. obj.Where(o => (o is Test));
  45. }
  46. }", @"using System.Linq;
  47. class Test
  48. {
  49. public void Foo(object[] obj)
  50. {
  51. obj.OfType<Test> ();
  52. }
  53. }");
  54. }
  55. [Test]
  56. public void TestInvalid ()
  57. {
  58. TestWrongContext<AdditionalOfTypeIssues>(@"using System.Linq;
  59. class Test
  60. {
  61. public void Foo(object[] obj)
  62. {
  63. obj.OfType<IDisposable> ().Where(o => this is IDisposable);
  64. }
  65. }");
  66. }
  67. }
  68. }