public void Test_IsEmpty() { var list = new List<int>(); Assert.IsTrue(list.IsNullOrEmpty()); list.Add(2); Assert.IsFalse(list.IsNullOrEmpty()); list = null; Assert.IsTrue(list.IsNullOrEmpty()); }
public void IsNullOrEmpty() { var list = new List<int> {1, 2, 3, 4, 5}; Assert.IsFalse(list.IsNullOrEmpty()); list.Clear(); Assert.IsTrue(list.IsNullOrEmpty()); list = null; Assert.IsTrue(list.IsNullOrEmpty()); }
public void AllConjugationsHaveGettersForAllVerbConjugationGroups() { var problems = new List<string>(); Assembly .GetAssembly(typeof (IConjugation)) .GetTypes() .Where( t => t.GetInterfaces().Contains(typeof (IConjugation)) && t.Namespace != null && !t.Namespace.ToLowerInvariant().Contains("irregular") && !t.IsAbstract) .ForEach(c => { List<string> staticMethodsReturningConjugation = c.GetMethods() .Where(m => m.IsStatic && m.ReturnType == typeof (IConjugation)) .Select(m => m.Name) .ToList(); for(int i = 1; i <= 4; i++) { if (staticMethodsReturningConjugation.Contains(string.Format("Get{0}", i))) { continue; } problems.Add(string.Format("{0} class does not contain method Get{1}", c.Name, i)); } }); if (problems.IsNullOrEmpty()) { return; } Assert.Fail(string.Join("; ", problems)); }
public void IsNullOrEmpty() { List<object> nullList = null; List<string> list = new List<string> { Guid.NewGuid().ToString() }; Assert.IsTrue(new List<string>().IsNullOrEmpty()); Assert.IsTrue(nullList.IsNullOrEmpty()); Assert.IsFalse(list.IsNullOrEmpty()); }
public void IsNullOrEmpty() { // Type var @this = new List<string>(); // Examples bool value1 = @this.IsNullOrEmpty(); // return true; @this.Add("Fizz"); bool value2 = @this.IsNullOrEmpty(); // return false; @this = null; bool value3 = @this.IsNullOrEmpty(); // return true; // Unit Test Assert.IsTrue(value1); Assert.IsFalse(value2); Assert.IsTrue(value3); }
public void ListIsNullOrEmpty() { List<object> nullList = null; Assert.IsTrue(nullList.IsNullOrEmpty()); List<object> emptyList = new List<object> { }; Assert.IsTrue(emptyList.IsNullOrEmpty()); List<object> fullList = new List<object>() { 1, "I'm a string", 2.04f, DateTime.Now }; Assert.IsFalse(fullList.IsNullOrEmpty()); }
public void IsNullOrEmptyTest() { List<string> nullArray = null; Assert.AreEqual(nullArray.IsNullOrEmpty(),true); var emptyArray = new List<string>(); Assert.AreEqual(emptyArray.IsNullOrEmpty(),true); var arrayWithNull = new List<string> {null}; Assert.AreEqual(arrayWithNull.IsNullOrEmpty(), true); var notEmpty = new List<string> {"Some Value"}; Assert.AreEqual(notEmpty.IsNullOrEmpty(),false); }
public void IsNullOrEmpty() { // Type List<string> @thisNull = null; IEnumerable<string> @thisEmpty = new List<string>().AsEnumerable(); IEnumerable<string> @thisNotEmpty = new List<string> {"Fizz"}.AsEnumerable(); // Exemples bool result1 = @thisNull.IsNullOrEmpty(); // return true; bool result2 = @thisEmpty.IsNullOrEmpty(); // return true; bool result3 = @thisNotEmpty.IsNullOrEmpty(); // return false; // Unit Test Assert.IsTrue(result1); Assert.IsTrue(result2); Assert.IsFalse(result3); }
public void ReturnsFalseIfNotNullOrEmpty() { List<string> list = new List<string>() { "Test" }; Assert.IsFalse(list.IsNullOrEmpty()); }
public void ReturnsTrueIfEmpty() { List<int> emptyList = new List<int>(); Assert.IsTrue(emptyList.IsNullOrEmpty()); }
public void TestIsNullOrEmpty1() { List<int> l1 = new List<int> { 1, 2, 3, 4 }; Assert.IsFalse(l1.IsNullOrEmpty()); }
public void TestIsNullOrEmpty2() { List<int> l1 = new List<int>(); Assert.IsTrue(l1.IsNullOrEmpty()); }
public void IsNullOrEmpty() { List<int> list = null; Assert.IsTrue(list.IsNullOrEmpty()); list = new List<int>(); Assert.IsTrue(list.IsNullOrEmpty()); list.Add(50); Assert.IsFalse(list.IsNullOrEmpty()); }