本文整理汇总了C#中Microsoft.VisualStudio.TestTools.UnitTesting.List.IsNullOrEmpty方法的典型用法代码示例。如果您正苦于以下问题:C# List.IsNullOrEmpty方法的具体用法?C# List.IsNullOrEmpty怎么用?C# List.IsNullOrEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.VisualStudio.TestTools.UnitTesting.List
的用法示例。
在下文中一共展示了List.IsNullOrEmpty方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Test_IsEmpty
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());
}
示例2: 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());
}
示例3: AllConjugationsHaveGettersForAllVerbConjugationGroups
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));
}
示例4: IsNullOrEmpty
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());
}
示例5: 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);
}
示例6: ListIsNullOrEmpty
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());
}
示例7: IsNullOrEmptyTest
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);
}
示例8: IsNullOrEmpty
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);
}
示例9: ReturnsFalseIfNotNullOrEmpty
public void ReturnsFalseIfNotNullOrEmpty()
{
List<string> list = new List<string>() { "Test" };
Assert.IsFalse(list.IsNullOrEmpty());
}
示例10: ReturnsTrueIfEmpty
public void ReturnsTrueIfEmpty()
{
List<int> emptyList = new List<int>();
Assert.IsTrue(emptyList.IsNullOrEmpty());
}
示例11: TestIsNullOrEmpty1
public void TestIsNullOrEmpty1()
{
List<int> l1 = new List<int>
{
1,
2,
3,
4
};
Assert.IsFalse(l1.IsNullOrEmpty());
}
示例12: TestIsNullOrEmpty2
public void TestIsNullOrEmpty2()
{
List<int> l1 = new List<int>();
Assert.IsTrue(l1.IsNullOrEmpty());
}
示例13: 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());
}