BadScript 2
Loading...
Searching...
No Matches
BadScript2.Tests.BadLinqTests Class Reference

Public Member Functions

void SelectTest ()
 Tests the LINQ.Select Function.
 
void WhereTest ()
 Tests the LINQ.Where Function.
 
void LastTest ()
 Tests the LINQ.Last Function.
 
void FirstTest ()
 Tests the Linq.First Function.
 
void LastOrDefaultTest ()
 Tests the Linq.LastOrDefault Function.
 
void FirstOrDefaultTest ()
 Tests the Linq.FirstOrDefault Function.
 
void TakeTest ()
 Tests the Linq.Take Function.
 
void SkipTest ()
 Tests the Linq.Skip Function.
 
void TakeLastTest ()
 Tests the Linq.TakeLast Function.
 
void SkipLastTest ()
 Tests the Linq.SkipLast Function.
 
void SelectManyTest ()
 Tests the Linq.SelectMany Function.
 
void SkipWhileTest ()
 Tests the Linq.SkipWhile Function.
 
void TakeWhileTest ()
 Test the Linq.TakeWhile Function.
 
void AllTest ()
 Tests the Linq.All Function.
 
void AnyTest ()
 Tests the Linq.Any Function.
 

Detailed Description

Definition at line 8 of file BadLinqTests.cs.

Member Function Documentation

◆ AllTest()

void BadScript2.Tests.BadLinqTests.AllTest ( )

Tests the Linq.All Function.

Definition at line 188 of file BadLinqTests.cs.

189 {
190 IEnumerable d = Enumerable.Range(0, 100);
191
192 // ReSharper disable once PossibleMultipleEnumeration
193 bool o = d.All("x=>x < 10");
194
195 // ReSharper disable once PossibleMultipleEnumeration
196 bool o1 = d.All("x=>x < 100");
197 Assert.Multiple(
198 () =>
199 {
200 Assert.That(o, Is.False);
201 Assert.That(o1, Is.True);
202 }
203 );
204 }

◆ AnyTest()

void BadScript2.Tests.BadLinqTests.AnyTest ( )

Tests the Linq.Any Function.

Definition at line 210 of file BadLinqTests.cs.

211 {
212 IEnumerable d = Enumerable.Range(0, 100);
213
214 // ReSharper disable once PossibleMultipleEnumeration
215 bool o = d.Any("x=>x < 0");
216
217 // ReSharper disable once PossibleMultipleEnumeration
218 bool o1 = d.Any("x=>x < 100");
219 Assert.That(o, Is.False);
220 Assert.That(o1, Is.True);
221 }

◆ FirstOrDefaultTest()

void BadScript2.Tests.BadLinqTests.FirstOrDefaultTest ( )

Tests the Linq.FirstOrDefault Function.

Definition at line 89 of file BadLinqTests.cs.

90 {
91 IEnumerable d = Enumerable.Empty<BadObject>();
92 object? o = d.FirstOrDefault("x=>x%2==0");
93
94 Assert.That(o, Is.Null);
95 }
The Base Class for all BadScript Objects.
Definition BadObject.cs:14

◆ FirstTest()

void BadScript2.Tests.BadLinqTests.FirstTest ( )

Tests the Linq.First Function.

Definition at line 66 of file BadLinqTests.cs.

67 {
68 IEnumerable d = Enumerable.Range(0, 100);
69 object o = d.First("x=>x%2==0");
70 Assert.That(o, Is.InstanceOf<int>());
71 Assert.That(o, Is.EqualTo(0));
72 }

◆ LastOrDefaultTest()

void BadScript2.Tests.BadLinqTests.LastOrDefaultTest ( )

Tests the Linq.LastOrDefault Function.

Definition at line 78 of file BadLinqTests.cs.

79 {
80 IEnumerable d = Enumerable.Empty<BadObject>();
81 object? o = d.LastOrDefault("x=>x%2==0");
82 Assert.That(o, Is.Null);
83 }

◆ LastTest()

void BadScript2.Tests.BadLinqTests.LastTest ( )

Tests the LINQ.Last Function.

Definition at line 54 of file BadLinqTests.cs.

55 {
56 IEnumerable d = Enumerable.Range(0, 100);
57 object o = d.Last("x=>x%2==0");
58 Assert.That(o, Is.InstanceOf<int>());
59 Assert.That(o, Is.EqualTo(98));
60 }

◆ SelectManyTest()

void BadScript2.Tests.BadLinqTests.SelectManyTest ( )

Tests the Linq.SelectMany Function.

Definition at line 146 of file BadLinqTests.cs.

147 {
148 List<BadObject> a = new BadObject[]
149 {
150 1,
151 2,
152 }.ToList();
153 IEnumerable d = new BadObject[]
154 {
155 new BadArray(a),
156 new BadArray(a),
157 };
158 object[] o = d.SelectMany("x=>x").Cast<object>().ToArray();
159 Assert.That(o, Has.Length.EqualTo(4));
160 }
Implements a Dynamic List/Array for the BadScript Language.
Definition BadArray.cs:17

◆ SelectTest()

void BadScript2.Tests.BadLinqTests.SelectTest ( )

Tests the LINQ.Select Function.

Definition at line 14 of file BadLinqTests.cs.

15 {
16 IEnumerable d = Enumerable.Range(0, 100);
17
18 foreach (object? o in d.Select("x=>x*2"))
19 {
20 Assert.Multiple(
21 () =>
22 {
23 Assert.That(o, Is.InstanceOf<decimal>());
24 Assert.That((decimal)o % 2, Is.EqualTo(0));
25 }
26 );
27 }
28 }

◆ SkipLastTest()

void BadScript2.Tests.BadLinqTests.SkipLastTest ( )

Tests the Linq.SkipLast Function.

Definition at line 134 of file BadLinqTests.cs.

135 {
136 IEnumerable d = Enumerable.Range(0, 100);
137 object[] o = d.SkipLast(10).Cast<object>().ToArray();
138 Assert.That(o, Has.Length.EqualTo(90));
139 }

◆ SkipTest()

void BadScript2.Tests.BadLinqTests.SkipTest ( )

Tests the Linq.Skip Function.

Definition at line 112 of file BadLinqTests.cs.

113 {
114 IEnumerable d = Enumerable.Range(0, 100);
115 object[] o = d.Skip(10).Cast<object>().ToArray();
116 Assert.That(o, Has.Length.EqualTo(90));
117 }

◆ SkipWhileTest()

void BadScript2.Tests.BadLinqTests.SkipWhileTest ( )

Tests the Linq.SkipWhile Function.

Definition at line 166 of file BadLinqTests.cs.

167 {
168 IEnumerable d = Enumerable.Range(0, 100);
169 object[] o = d.SkipWhile("x=>x < 10").Cast<object>().ToArray();
170 Assert.That(o, Has.Length.EqualTo(90));
171 }

◆ TakeLastTest()

void BadScript2.Tests.BadLinqTests.TakeLastTest ( )

Tests the Linq.TakeLast Function.

Definition at line 123 of file BadLinqTests.cs.

124 {
125 IEnumerable d = Enumerable.Range(0, 100);
126 object[] o = d.TakeLast(10).Cast<object>().ToArray();
127 Assert.That(o, Has.Length.EqualTo(10));
128 }

◆ TakeTest()

void BadScript2.Tests.BadLinqTests.TakeTest ( )

Tests the Linq.Take Function.

Definition at line 101 of file BadLinqTests.cs.

102 {
103 IEnumerable d = Enumerable.Range(0, 100);
104 object[] o = d.Take(10).Cast<object>().ToArray();
105 Assert.That(o, Has.Length.EqualTo(10));
106 }

◆ TakeWhileTest()

void BadScript2.Tests.BadLinqTests.TakeWhileTest ( )

Test the Linq.TakeWhile Function.

Definition at line 177 of file BadLinqTests.cs.

178 {
179 IEnumerable d = Enumerable.Range(0, 100);
180 object[] o = d.TakeWhile("x=>x < 10").Cast<object>().ToArray();
181 Assert.That(o, Has.Length.EqualTo(10));
182 }

◆ WhereTest()

void BadScript2.Tests.BadLinqTests.WhereTest ( )

Tests the LINQ.Where Function.

Definition at line 34 of file BadLinqTests.cs.

35 {
36 IEnumerable d = Enumerable.Range(0, 100);
37
38 foreach (object? o in d.Where("x=>x%2==0"))
39 {
40 Assert.Multiple(
41 () =>
42 {
43 Assert.That(o, Is.InstanceOf<int>());
44 Assert.That((int)o % 2, Is.EqualTo(0));
45 }
46 );
47 }
48 }

The documentation for this class was generated from the following file: