本文整理汇总了C#中NUnit.Framework.List.IsNullOrEmpty方法的典型用法代码示例。如果您正苦于以下问题:C# List.IsNullOrEmpty方法的具体用法?C# List.IsNullOrEmpty怎么用?C# List.IsNullOrEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NUnit.Framework.List
的用法示例。
在下文中一共展示了List.IsNullOrEmpty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsNullOrEmptyTestCase
public void IsNullOrEmptyTestCase()
{
List<String> list = null;
Assert.IsTrue( list.IsNullOrEmpty() );
list = new List<String>();
Assert.IsTrue( list.IsNullOrEmpty() );
list.Add( RandomValueEx.GetRandomString() );
Assert.IsFalse( list.IsNullOrEmpty() );
}
示例2: TestIsNullOrEmptyNotEmpty
public void TestIsNullOrEmptyNotEmpty()
{
IEnumerable nullEnumerable = new[] { new object() };
IEnumerable<object> nullEnumerableT = new List<object> { new object(), new object() };
Assert.IsFalse(nullEnumerable.IsNullOrEmpty());
Assert.IsFalse(nullEnumerableT.IsNullOrEmpty());
}
示例3: TestIsNullOrEmptyEmpty
public void TestIsNullOrEmptyEmpty()
{
IEnumerable nullEnumerable = new object[] { };
IEnumerable<object> nullEnumerableT = new List<object>();
Assert.IsTrue(nullEnumerable.IsNullOrEmpty());
Assert.IsTrue(nullEnumerableT.IsNullOrEmpty());
}
示例4: IsNullOrEmptyTest
public void IsNullOrEmptyTest()
{
var data = new List<String>() { "A", "B", "C", "D", "E" };
var emptyData = new List<String>();
Assert.IsFalse(data.IsNullOrEmpty());
Assert.IsTrue(emptyData.IsNullOrEmpty());
Assert.IsTrue(((IEnumerable<String>) null).IsNullOrEmpty());
}
示例5: IsNullOrEmpty
public void IsNullOrEmpty()
{
IEnumerable<int> nullList = null;
IEnumerable<int> emptyList = new List<int>();
IEnumerable<int> nonEmptyList = MakeList(1, 2);
Assert.That(nullList.IsNullOrEmpty(), Is.True);
Assert.That(emptyList.IsNullOrEmpty(), Is.True);
Assert.That(nonEmptyList.IsNullOrEmpty(), Is.False);
}
示例6: Should_Return_False_If_Collection_Has_Multiple_Elements
public void Should_Return_False_If_Collection_Has_Multiple_Elements()
{
// arrange - create strong typed collection, with multiple items
var collection = new List<string>() { "a", "b", "c" };
// act
var target = collection.IsNullOrEmpty();
// assert
target.Should().BeFalse();
}
示例7: Should_Return_True_If_Collection_IsEmpty
public void Should_Return_True_If_Collection_IsEmpty()
{
// arrange - create empty collection
var collection = new List<string>();
// act
var target = collection.IsNullOrEmpty();
// assert
target.Should().BeTrue();
}
示例8: TestNullOrEmpty
public void TestNullOrEmpty()
{
// Arrange.
var sequence = new List<int> { 1, 2, 3 };
var emptySequence = new List<int>();
List<int> nullSequence = null;
// Assert.
Assert.IsFalse(sequence.IsNullOrEmpty());
Assert.IsTrue(emptySequence.IsNullOrEmpty());
Assert.IsTrue(nullSequence.IsNullOrEmpty());
}
示例9: IsNullOrEmpty_TreatsValueAsACollectionIfIsEnumerable
public void IsNullOrEmpty_TreatsValueAsACollectionIfIsEnumerable()
{
object nullList = null;
object emptyList = new List<int>();
object nonEmptyList = MakeList(1, 2, 3);
Assert.That(nullList.IsNullOrEmpty(), Is.True);
Assert.That(emptyList.IsNullOrEmpty(), Is.True);
Assert.That(nonEmptyList.IsNullOrEmpty(), Is.False);
}
示例10: IsNullOrEmptyCollectionTest
public void IsNullOrEmptyCollectionTest()
{
ICollection<int> col = null;
Assert.IsTrue(col.IsNullOrEmpty());
col = new List<int>();
Assert.IsTrue(col.IsNullOrEmpty());
col = new List<int>() { 42 };
Assert.IsFalse(col.IsNullOrEmpty());
}
示例11: TestIsNullOrEmpty1
public void TestIsNullOrEmpty1()
{
List<int> l1 = new List<int>
{
1,
2,
3,
4
};
Assert.IsFalse(l1.IsNullOrEmpty());
}
示例12: IsNullOrEmpty
public void IsNullOrEmpty()
{
List<Int32> test1 = new List<int>(3) { 0, 5, 0 };
Assert.AreEqual(false, test1.IsNullOrEmpty());
test1.RemoveAt(2);
Assert.AreEqual(false, test1.IsNullOrEmpty());
test1.Clear();
Assert.AreEqual(true, test1.IsNullOrEmpty());
test1 = null;
Assert.AreEqual(true, test1.IsNullOrEmpty());
}
示例13: TestIsNullOrEmpty2
public void TestIsNullOrEmpty2()
{
List<int> l1 = new List<int>();
Assert.IsTrue(l1.IsNullOrEmpty());
}
示例14: IsNullOrEmpty_ShouldReturnTrueForEmptyCollection
public void IsNullOrEmpty_ShouldReturnTrueForEmptyCollection()
{
IEnumerable<string> collection = new List<string>();
Assert.That(collection.IsNullOrEmpty(), Is.True);
}
示例15: IsNullOrEmpty_List_Test_Empty
public void IsNullOrEmpty_List_Test_Empty()
{
List<int> intList = new List<int>();
bool expected = true;
bool actual = intList.IsNullOrEmpty();
Assert.AreEqual(expected, actual);
}