Advertisement
Guest User

Untitled

a guest
May 26th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.67 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using Microsoft.VisualStudio.TestTools.UnitTesting;
  4. using System.Linq;
  5.  
  6. namespace TestAnnTask
  7. {
  8. [TestClass]
  9. public class UnitTest1
  10. {
  11. [TestMethod]
  12. public void SimpleTest()
  13. {
  14. var n = 10;
  15. var listBig = new List<List<int>>()
  16. {
  17. new List<int> {5, 7, 8, 9 },
  18. new List<int> {8, 9, 10, 12},
  19. new List<int> {2, 7, 7, 8, 9},
  20. };
  21. var expectedResult = listBig
  22. .SelectMany(t => t)
  23. .OrderBy(t => t)
  24. .Take(n);
  25. CollectionAssert.AreEqual(expectedResult, );
  26. }
  27.  
  28. [TestMethod]
  29. public void HardTest()
  30. {
  31. var n = 7;
  32. var listBig = new List<List<int>>()
  33. {
  34. Enumerable.Range(100, 500).ToList(),
  35. Enumerable.Range(1, 1000).ToList(),
  36. Enumerable.Range(50, 160).ToList(),
  37. Enumerable.Range(70, 1000).ToList(),
  38. Enumerable.Range(1000, 2000).ToList(),
  39. Enumerable.Range(1000, 4000).ToList(),
  40. };
  41. var expectedResult = listBig
  42. .SelectMany(t => t)
  43. .OrderBy(t => t)
  44. .Take(n);
  45. CollectionAssert.AreEqual(expectedResult, );
  46. }
  47.  
  48. [TestMethod]
  49. public void EmptyList()
  50. {
  51. var n = 7;
  52. var listBig = new List<List<int>>()
  53. {
  54. new List<int>() { },
  55. new List<int>() {1, 7, 8},
  56. };
  57. var expectedResult = listBig
  58. .SelectMany(t => t)
  59. .OrderBy(t => t)
  60. .Take(n);
  61. CollectionAssert.AreEqual(expectedResult, );
  62. }
  63.  
  64. [TestMethod]
  65. public void TestOneElementInList()
  66. {
  67. var n = 3;
  68. var listBig = new List<List<int>>()
  69. {
  70. new List<int>() {1},
  71. new List<int>() {2},
  72. new List<int>() {7},
  73. new List<int>() {18},
  74. };
  75. var expectedResult = listBig
  76. .SelectMany(t => t)
  77. .OrderBy(t => t)
  78. .Take(n);
  79. CollectionAssert.AreEqual(expectedResult, );
  80. }
  81. }
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement