PageRenderTime 42ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

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

https://github.com/pombredanne/SharpDevelop
C# | 77 lines | 47 code | 5 blank | 25 comment | 0 complexity | 7d5cb90544b57659ce5cb1e43a4ad4e9 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. // ReplaceWithSingleCallToSingleIssueTests.cs
  3. //
  4. // Author:
  5. // Mike Krüger <mkrueger@xamarin.com>
  6. //
  7. // Copyright (c) 2013 Xamarin <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. namespace ICSharpCode.NRefactory.CSharp.CodeIssues
  31. {
  32. [TestFixture]
  33. public class ReplaceWithSingleCallToSingleIssueTests : InspectionActionTestBase
  34. {
  35. [Test]
  36. public void TestSimpleCase()
  37. {
  38. var input = @"using System.Linq;
  39. public class CSharpDemo {
  40. public void Bla () {
  41. int[] arr;
  42. var bla = arr.Where (x => x < 4).Single ();
  43. }
  44. }";
  45. TestRefactoringContext context;
  46. var issues = GetIssues(new ReplaceWithSingleCallToSingleIssue(), input, out context);
  47. Assert.AreEqual(1, issues.Count);
  48. CheckFix(context, issues, @"using System.Linq;
  49. public class CSharpDemo {
  50. public void Bla () {
  51. int[] arr;
  52. var bla = arr.Single (x => x < 4);
  53. }
  54. }");
  55. }
  56. [Test]
  57. public void TestDisable()
  58. {
  59. var input = @"using System.Linq;
  60. public class CSharpDemo {
  61. public void Bla () {
  62. int[] arr;
  63. // ReSharper disable ReplaceWithSingleCallToSingle
  64. var bla = arr.Where (x => x < 4).Single ();
  65. }
  66. }";
  67. TestRefactoringContext context;
  68. var issues = GetIssues(new ReplaceWithSingleCallToSingleIssue(), input, out context);
  69. Assert.AreEqual(0, issues.Count);
  70. }
  71. }
  72. }