@@ -194,6 +194,332 @@ public class NunitTests
194194 [ Implemented ]
195195 public void Nunit4_AssertNotNull_TestCodeFix ( string oldAssertion , string newAssertion ) => Nunit4VerifyFix ( "object actual" , oldAssertion , newAssertion ) ;
196196
197+ [ DataTestMethod ]
198+ [ AssertionDiagnostic ( "Assert.IsNaN(actual{0});" ) ]
199+ [ Implemented ]
200+ public void Nunit3_AssertIsNaN_TestAnalyzer ( string assertion )
201+ {
202+ Nunit3VerifyDiagnostic ( "double actual" , assertion ) ;
203+ Nunit3VerifyNoFix ( "double actual" , assertion ) ;
204+ }
205+
206+ [ DataTestMethod ]
207+ [ AssertionDiagnostic ( "ClassicAssert.IsNaN(actual{0});" ) ]
208+ [ Implemented ]
209+ public void Nunit4_AssertIsNaN_TestAnalyzer ( string assertion )
210+ {
211+ Nunit4VerifyDiagnostic ( "double actual" , assertion ) ;
212+ Nunit4VerifyNoFix ( "double actual" , assertion ) ;
213+ }
214+
215+ // IsEmpty
216+ [ DataTestMethod ]
217+ [ AssertionDiagnostic ( "Assert.IsEmpty(actual{0});" ) ]
218+ [ Implemented ]
219+ public void Nunit3_AssertIsEmpty_TestAnalyzer ( string assertion )
220+ {
221+ Nunit3VerifyDiagnostic ( "object[] actual" , assertion ) ;
222+ Nunit3VerifyDiagnostic ( "IEnumerable<int> actual" , assertion ) ;
223+ Nunit3VerifyDiagnostic ( "IEnumerable actual" , assertion ) ;
224+ Nunit3VerifyDiagnostic ( "string actual" , assertion ) ;
225+ }
226+
227+ [ DataTestMethod ]
228+ [ AssertionDiagnostic ( "ClassicAssert.IsEmpty(actual{0});" ) ]
229+ [ Implemented ]
230+ public void Nunit4_AssertIsEmpty_TestAnalyzer ( string assertion )
231+ {
232+ Nunit4VerifyDiagnostic ( "object[] actual" , assertion ) ;
233+ Nunit4VerifyDiagnostic ( "IEnumerable<int> actual" , assertion ) ;
234+ Nunit4VerifyDiagnostic ( "IEnumerable actual" , assertion ) ;
235+ Nunit4VerifyDiagnostic ( "string actual" , assertion ) ;
236+ }
237+
238+ [ DataTestMethod ]
239+ [ AssertionCodeFix (
240+ oldAssertion : "Assert.IsEmpty(actual{0});" ,
241+ newAssertion : "actual.Should().BeEmpty({0});" ) ]
242+ [ Implemented ]
243+ public void Nunit3_AssertIsEmpty_TestCodeFix ( string oldAssertion , string newAssertion )
244+ {
245+ Nunit3VerifyFix ( "object[] actual" , oldAssertion , newAssertion ) ;
246+ Nunit3VerifyFix ( "IEnumerable<int> actual" , oldAssertion , newAssertion ) ;
247+ Nunit3VerifyNoFix ( "IEnumerable actual" , oldAssertion ) ;
248+ Nunit3VerifyFix ( "string actual" , oldAssertion , newAssertion ) ;
249+ }
250+
251+ [ DataTestMethod ]
252+ [ AssertionCodeFix (
253+ oldAssertion : "ClassicAssert.IsEmpty(actual{0});" ,
254+ newAssertion : "actual.Should().BeEmpty({0});" ) ]
255+ [ Implemented ]
256+ public void Nunit4_AssertIsEmpty_TestCodeFix ( string oldAssertion , string newAssertion )
257+ {
258+ Nunit4VerifyFix ( "object[] actual" , oldAssertion , newAssertion ) ;
259+ Nunit4VerifyFix ( "IEnumerable<int> actual" , oldAssertion , newAssertion ) ;
260+ Nunit4VerifyNoFix ( "IEnumerable actual" , oldAssertion ) ;
261+ Nunit4VerifyFix ( "string actual" , oldAssertion , newAssertion ) ;
262+ }
263+
264+ // IsNotEmpty
265+ [ DataTestMethod ]
266+ [ AssertionDiagnostic ( "Assert.IsNotEmpty(actual{0});" ) ]
267+ [ Implemented ]
268+ public void Nunit3_AssertIsNotEmpty_TestAnalyzer ( string assertion )
269+ {
270+ Nunit3VerifyDiagnostic ( "object[] actual" , assertion ) ;
271+ Nunit3VerifyDiagnostic ( "IEnumerable<int> actual" , assertion ) ;
272+ Nunit3VerifyDiagnostic ( "IEnumerable actual" , assertion ) ;
273+ Nunit3VerifyDiagnostic ( "string actual" , assertion ) ;
274+ }
275+
276+ [ DataTestMethod ]
277+ [ AssertionDiagnostic ( "ClassicAssert.IsNotEmpty(actual{0});" ) ]
278+ [ Implemented ]
279+ public void Nunit4_AssertIsNotEmpty_TestAnalyzer ( string assertion )
280+ {
281+ Nunit4VerifyDiagnostic ( "object[] actual" , assertion ) ;
282+ Nunit4VerifyDiagnostic ( "IEnumerable<int> actual" , assertion ) ;
283+ Nunit4VerifyDiagnostic ( "IEnumerable actual" , assertion ) ;
284+ Nunit4VerifyDiagnostic ( "string actual" , assertion ) ;
285+ }
286+
287+ [ DataTestMethod ]
288+ [ AssertionCodeFix (
289+ oldAssertion : "Assert.IsNotEmpty(actual{0});" ,
290+ newAssertion : "actual.Should().NotBeEmpty({0});" ) ]
291+ [ Implemented ]
292+ public void Nunit3_AssertIsNotEmpty_TestCodeFix ( string oldAssertion , string newAssertion )
293+ {
294+ Nunit3VerifyFix ( "object[] actual" , oldAssertion , newAssertion ) ;
295+ Nunit3VerifyFix ( "IEnumerable<int> actual" , oldAssertion , newAssertion ) ;
296+ Nunit3VerifyNoFix ( "IEnumerable actual" , oldAssertion ) ;
297+ Nunit3VerifyFix ( "string actual" , oldAssertion , newAssertion ) ;
298+ }
299+
300+ [ DataTestMethod ]
301+ [ AssertionCodeFix (
302+ oldAssertion : "ClassicAssert.IsNotEmpty(actual{0});" ,
303+ newAssertion : "actual.Should().NotBeEmpty({0});" ) ]
304+ [ Implemented ]
305+ public void Nunit4_AssertIsNotEmpty_TestCodeFix ( string oldAssertion , string newAssertion )
306+ {
307+ Nunit4VerifyFix ( "object[] actual" , oldAssertion , newAssertion ) ;
308+ Nunit4VerifyFix ( "IEnumerable<int> actual" , oldAssertion , newAssertion ) ;
309+ Nunit4VerifyNoFix ( "IEnumerable actual" , oldAssertion ) ;
310+ Nunit4VerifyFix ( "string actual" , oldAssertion , newAssertion ) ;
311+ }
312+
313+ [ DataTestMethod ]
314+ [ AssertionDiagnostic ( "Assert.Zero(actual{0});" ) ]
315+ [ Implemented ]
316+ public void Nunit3_AssertZero_TestAnalyzer ( string assertion )
317+ {
318+ Nunit3VerifyDiagnostic ( "int actual" , assertion ) ;
319+ Nunit3VerifyDiagnostic ( "uint actual" , assertion ) ;
320+ Nunit3VerifyDiagnostic ( "long actual" , assertion ) ;
321+ Nunit3VerifyDiagnostic ( "ulong actual" , assertion ) ;
322+ Nunit3VerifyDiagnostic ( "float actual" , assertion ) ;
323+ Nunit3VerifyDiagnostic ( "double actual" , assertion ) ;
324+ Nunit3VerifyDiagnostic ( "decimal actual" , assertion ) ;
325+ }
326+
327+ [ DataTestMethod ]
328+ [ AssertionDiagnostic ( "ClassicAssert.Zero(actual{0});" ) ]
329+ [ Implemented ]
330+ public void Nunit4_AssertZero_TestAnalyzer ( string assertion )
331+ {
332+ Nunit4VerifyDiagnostic ( "int actual" , assertion ) ;
333+ Nunit4VerifyDiagnostic ( "uint actual" , assertion ) ;
334+ Nunit4VerifyDiagnostic ( "long actual" , assertion ) ;
335+ Nunit4VerifyDiagnostic ( "ulong actual" , assertion ) ;
336+ Nunit4VerifyDiagnostic ( "float actual" , assertion ) ;
337+ Nunit4VerifyDiagnostic ( "double actual" , assertion ) ;
338+ Nunit4VerifyDiagnostic ( "decimal actual" , assertion ) ;
339+ }
340+
341+ [ DataTestMethod ]
342+ [ AssertionCodeFix (
343+ oldAssertion : "Assert.Zero(actual{0});" ,
344+ newAssertion : "actual.Should().Be(0{0});" ) ]
345+ [ Implemented ]
346+ public void Nunit3_AssertZero_TestCodeFix ( string oldAssertion , string newAssertion )
347+ {
348+ Nunit3VerifyFix ( "int actual" , oldAssertion , newAssertion ) ;
349+ Nunit3VerifyFix ( "uint actual" , oldAssertion , newAssertion ) ;
350+ Nunit3VerifyFix ( "long actual" , oldAssertion , newAssertion ) ;
351+ Nunit3VerifyFix ( "ulong actual" , oldAssertion , newAssertion ) ;
352+ Nunit3VerifyFix ( "float actual" , oldAssertion , newAssertion ) ;
353+ Nunit3VerifyFix ( "double actual" , oldAssertion , newAssertion ) ;
354+ Nunit3VerifyFix ( "decimal actual" , oldAssertion , newAssertion ) ;
355+ }
356+
357+ [ DataTestMethod ]
358+ [ AssertionCodeFix (
359+ oldAssertion : "ClassicAssert.Zero(actual{0});" ,
360+ newAssertion : "actual.Should().Be(0{0});" ) ]
361+ [ Implemented ]
362+ public void Nunit4_AssertZero_TestCodeFix ( string oldAssertion , string newAssertion )
363+ {
364+ Nunit4VerifyFix ( "int actual" , oldAssertion , newAssertion ) ;
365+ Nunit4VerifyFix ( "uint actual" , oldAssertion , newAssertion ) ;
366+ Nunit4VerifyFix ( "long actual" , oldAssertion , newAssertion ) ;
367+ Nunit4VerifyFix ( "ulong actual" , oldAssertion , newAssertion ) ;
368+ Nunit4VerifyFix ( "float actual" , oldAssertion , newAssertion ) ;
369+ Nunit4VerifyFix ( "double actual" , oldAssertion , newAssertion ) ;
370+ Nunit4VerifyFix ( "decimal actual" , oldAssertion , newAssertion ) ;
371+ }
372+
373+ [ DataTestMethod ]
374+ [ AssertionDiagnostic ( "Assert.NotZero(actual{0});" ) ]
375+ [ Implemented ]
376+ public void Nunit3_AssertNotZero_TestAnalyzer ( string assertion )
377+ {
378+ Nunit3VerifyDiagnostic ( "int actual" , assertion ) ;
379+ Nunit3VerifyDiagnostic ( "uint actual" , assertion ) ;
380+ Nunit3VerifyDiagnostic ( "long actual" , assertion ) ;
381+ Nunit3VerifyDiagnostic ( "ulong actual" , assertion ) ;
382+ Nunit3VerifyDiagnostic ( "float actual" , assertion ) ;
383+ Nunit3VerifyDiagnostic ( "double actual" , assertion ) ;
384+ Nunit3VerifyDiagnostic ( "decimal actual" , assertion ) ;
385+ }
386+
387+ [ DataTestMethod ]
388+ [ AssertionDiagnostic ( "ClassicAssert.NotZero(actual{0});" ) ]
389+ [ Implemented ]
390+ public void Nunit4_AssertNotZero_TestAnalyzer ( string assertion )
391+ {
392+ Nunit4VerifyDiagnostic ( "int actual" , assertion ) ;
393+ Nunit4VerifyDiagnostic ( "uint actual" , assertion ) ;
394+ Nunit4VerifyDiagnostic ( "long actual" , assertion ) ;
395+ Nunit4VerifyDiagnostic ( "ulong actual" , assertion ) ;
396+ Nunit4VerifyDiagnostic ( "float actual" , assertion ) ;
397+ Nunit4VerifyDiagnostic ( "double actual" , assertion ) ;
398+ Nunit4VerifyDiagnostic ( "decimal actual" , assertion ) ;
399+ }
400+
401+ [ DataTestMethod ]
402+ [ AssertionCodeFix (
403+ oldAssertion : "Assert.NotZero(actual{0});" ,
404+ newAssertion : "actual.Should().NotBe(0{0});" ) ]
405+ [ Implemented ]
406+ public void Nunit3_AssertNotZero_TestCodeFix ( string oldAssertion , string newAssertion )
407+ {
408+ Nunit3VerifyFix ( "int actual" , oldAssertion , newAssertion ) ;
409+ Nunit3VerifyFix ( "uint actual" , oldAssertion , newAssertion ) ;
410+ Nunit3VerifyFix ( "long actual" , oldAssertion , newAssertion ) ;
411+ Nunit3VerifyFix ( "ulong actual" , oldAssertion , newAssertion ) ;
412+ Nunit3VerifyFix ( "float actual" , oldAssertion , newAssertion ) ;
413+ Nunit3VerifyFix ( "double actual" , oldAssertion , newAssertion ) ;
414+ Nunit3VerifyFix ( "decimal actual" , oldAssertion , newAssertion ) ;
415+ }
416+
417+ [ DataTestMethod ]
418+ [ AssertionCodeFix (
419+ oldAssertion : "ClassicAssert.NotZero(actual{0});" ,
420+ newAssertion : "actual.Should().NotBe(0{0});" ) ]
421+ [ Implemented ]
422+ public void Nunit4_AssertNotZero_TestCodeFix ( string oldAssertion , string newAssertion )
423+ {
424+ Nunit4VerifyFix ( "int actual" , oldAssertion , newAssertion ) ;
425+ Nunit4VerifyFix ( "uint actual" , oldAssertion , newAssertion ) ;
426+ Nunit4VerifyFix ( "long actual" , oldAssertion , newAssertion ) ;
427+ Nunit4VerifyFix ( "ulong actual" , oldAssertion , newAssertion ) ;
428+ Nunit4VerifyFix ( "float actual" , oldAssertion , newAssertion ) ;
429+ Nunit4VerifyFix ( "double actual" , oldAssertion , newAssertion ) ;
430+ Nunit4VerifyFix ( "decimal actual" , oldAssertion , newAssertion ) ;
431+ }
432+
433+ // Positive
434+ [ DataTestMethod ]
435+ [ AssertionDiagnostic ( "Assert.Positive(actual{0});" ) ]
436+ [ Implemented ]
437+ public void Nunit3_AssertPositive_TestAnalyzer ( string assertion )
438+ {
439+ Nunit3VerifyDiagnostic ( "int actual" , assertion ) ;
440+ Nunit3VerifyDiagnostic ( "uint actual" , assertion ) ;
441+ Nunit3VerifyDiagnostic ( "long actual" , assertion ) ;
442+ Nunit3VerifyDiagnostic ( "ulong actual" , assertion ) ;
443+ Nunit3VerifyDiagnostic ( "float actual" , assertion ) ;
444+ Nunit3VerifyDiagnostic ( "double actual" , assertion ) ;
445+ Nunit3VerifyDiagnostic ( "decimal actual" , assertion ) ;
446+ }
447+
448+ [ DataTestMethod ]
449+ [ AssertionDiagnostic ( "ClassicAssert.Positive(actual{0});" ) ]
450+ [ Implemented ]
451+ public void Nunit4_AssertPositive_TestAnalyzer ( string assertion )
452+ {
453+ Nunit4VerifyDiagnostic ( "int actual" , assertion ) ;
454+ Nunit4VerifyDiagnostic ( "uint actual" , assertion ) ;
455+ Nunit4VerifyDiagnostic ( "long actual" , assertion ) ;
456+ Nunit4VerifyDiagnostic ( "ulong actual" , assertion ) ;
457+ Nunit4VerifyDiagnostic ( "float actual" , assertion ) ;
458+ Nunit4VerifyDiagnostic ( "double actual" , assertion ) ;
459+ Nunit4VerifyDiagnostic ( "decimal actual" , assertion ) ;
460+ }
461+
462+ [ DataTestMethod ]
463+ [ AssertionCodeFix (
464+ oldAssertion : "Assert.Positive(actual{0});" ,
465+ newAssertion : "actual.Should().BePositive({0});" ) ]
466+ [ Implemented ]
467+ public void Nunit3_AssertPositive_TestCodeFix ( string oldAssertion , string newAssertion )
468+ {
469+ Nunit3VerifyFix ( "int actual" , oldAssertion , newAssertion ) ;
470+ Nunit3VerifyFix ( "uint actual" , oldAssertion , newAssertion ) ;
471+ Nunit3VerifyFix ( "long actual" , oldAssertion , newAssertion ) ;
472+ Nunit3VerifyFix ( "ulong actual" , oldAssertion , newAssertion ) ;
473+ Nunit3VerifyFix ( "float actual" , oldAssertion , newAssertion ) ;
474+ Nunit3VerifyFix ( "double actual" , oldAssertion , newAssertion ) ;
475+ Nunit3VerifyFix ( "decimal actual" , oldAssertion , newAssertion ) ;
476+ }
477+
478+ // Negative
479+ [ DataTestMethod ]
480+ [ AssertionDiagnostic ( "Assert.Negative(actual{0});" ) ]
481+ [ Implemented ]
482+ public void Nunit3_AssertNegative_TestAnalyzer ( string assertion )
483+ {
484+ Nunit3VerifyDiagnostic ( "int actual" , assertion ) ;
485+ Nunit3VerifyDiagnostic ( "uint actual" , assertion ) ;
486+ Nunit3VerifyDiagnostic ( "long actual" , assertion ) ;
487+ Nunit3VerifyDiagnostic ( "ulong actual" , assertion ) ;
488+ Nunit3VerifyDiagnostic ( "float actual" , assertion ) ;
489+ Nunit3VerifyDiagnostic ( "double actual" , assertion ) ;
490+ Nunit3VerifyDiagnostic ( "decimal actual" , assertion ) ;
491+ }
492+
493+ [ DataTestMethod ]
494+ [ AssertionDiagnostic ( "ClassicAssert.Negative(actual{0});" ) ]
495+ [ Implemented ]
496+ public void Nunit4_AssertNegative_TestAnalyzer ( string assertion )
497+ {
498+ Nunit4VerifyDiagnostic ( "int actual" , assertion ) ;
499+ Nunit4VerifyDiagnostic ( "uint actual" , assertion ) ;
500+ Nunit4VerifyDiagnostic ( "long actual" , assertion ) ;
501+ Nunit4VerifyDiagnostic ( "ulong actual" , assertion ) ;
502+ Nunit4VerifyDiagnostic ( "float actual" , assertion ) ;
503+ Nunit4VerifyDiagnostic ( "double actual" , assertion ) ;
504+ Nunit4VerifyDiagnostic ( "decimal actual" , assertion ) ;
505+ }
506+
507+ [ DataTestMethod ]
508+ [ AssertionCodeFix (
509+ oldAssertion : "Assert.Negative(actual{0});" ,
510+ newAssertion : "actual.Should().BeNegative({0});" ) ]
511+ [ Implemented ]
512+ public void Nunit3_AssertNegative_TestCodeFix ( string oldAssertion , string newAssertion )
513+ {
514+ Nunit3VerifyFix ( "int actual" , oldAssertion , newAssertion ) ;
515+ Nunit3VerifyFix ( "uint actual" , oldAssertion , newAssertion ) ;
516+ Nunit3VerifyFix ( "long actual" , oldAssertion , newAssertion ) ;
517+ Nunit3VerifyFix ( "ulong actual" , oldAssertion , newAssertion ) ;
518+ Nunit3VerifyFix ( "float actual" , oldAssertion , newAssertion ) ;
519+ Nunit3VerifyFix ( "double actual" , oldAssertion , newAssertion ) ;
520+ Nunit3VerifyFix ( "decimal actual" , oldAssertion , newAssertion ) ;
521+ }
522+
197523 #endregion
198524
199525 #region Assert.Comparisons.cs
0 commit comments