i am checking a string for three characters
Assert.AreEqual(myString.Substring(3,3), "DEF", "Failed as DEF was not observed");
the thing is here it can be DEF
or RES
, now to handle this what i can think of is the following
bool check = false;
if( myString.Substring(3,3) == "DEF" || myString.Substring(3,3) == "RED" )
check = true;
Assert.IsTrue(check,"Failed");
Console.WriteLine(""Passed);
IS THERE a way i can use some OR thing within Assert
p.s i'm writing unit test & yes i will use ternary operator instead....
C Introduction C is a general-purpose programming language created by Dennis Ritchie at the Bell Laboratories in 1972. It is a very popular language, despite being old. C is strongly associated with UNIX, as it was developed to write the UNIX operating system.
While C and C++ may sound similar, their features and usage differ. C is a procedural programming language that support objects and classes. On the other hand C++ is an enhanced version of C programming with object-oriented programming support.
C is a general-purpose language that most programmers learn before moving on to more complex languages. From Unix and Windows to Tic Tac Toe and Photoshop, several of the most commonly used applications today have been built on C. It is easy to learn because: A simple syntax with only 32 keywords.
Assert.IsTrue((myString.Substring(3,3) == "DEF" || myString.Substring(3,3) == "RED")?true:false,"Failed");
Using NUnit, the AnyOf constraint works:
Assert.That(myString.Substring(3,3), Is.AnyOf("DEF", "RED"));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With