本文整理汇总了C#中Microsoft.VisualStudio.TestTools.UnitTesting.List.All方法的典型用法代码示例。如果您正苦于以下问题:C# List.All方法的具体用法?C# List.All怎么用?C# List.All使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.VisualStudio.TestTools.UnitTesting.List
的用法示例。
在下文中一共展示了List.All方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: All
public void All()
{
// arrange
List<String> list = new List<String>() { "Backbone", "Angular", "React" };
// act
Boolean actual = list.All(x => x == "Angular" || x == "Backbone" || x == "React");
Boolean actualNotFound = list.All(x => x == "Angular" || x == "React");
// assert
Assert.AreEqual(true, actual);
Assert.AreEqual(false, actualNotFound);
}
示例2: GenerateProcessedVedeoTest
public void GenerateProcessedVedeoTest()
{
//Arrange
var calculator = new Mock<IResolutionCalculator>();
var paramFactory = new Mock<IMultimediaAdjusterParamFactory>();
var processedVideoList = new Mock<IProcessedVideoList>();
var processedVideoGenerator = new ProcessedVideoGenerator(calculator.Object, paramFactory.Object, processedVideoList.Object);
var videoParam = new VideoAdjusterParam();
var audioParam = new AudioAdjusterParam();
var sizeList = new List<IVideoSize>();
var mp4ProcessedVideos = new List<DomainProcessedVideo> {new DomainProcessedVideo()};
var webmProcessedVideos = new List<DomainProcessedVideo> {new DomainProcessedVideo()};
var metadata = new Mock<IVideoMetadata>();
metadata.Setup(p => p.VideoWidth).Returns(2345);
metadata.Setup(p => p.VideoHeight).Returns(345);
calculator.Setup(m => m.Calculate(metadata.Object.VideoWidth, metadata.Object.VideoHeight)).Returns(sizeList);
paramFactory.Setup(m => m.CreateVideoParam(metadata.Object)).Returns(videoParam);
paramFactory.Setup(m => m.CreateAudioParam(metadata.Object)).Returns(audioParam);
processedVideoList.Setup(m => m.CreateProcessedVideos(videoParam, audioParam, MetadataConstant.Mp4Container, sizeList, ContentType.Mp4Content)).Returns(mp4ProcessedVideos);
processedVideoList.Setup(m => m.CreateProcessedVideos(videoParam, audioParam, MetadataConstant.WebmContainer, sizeList, ContentType.WebmContent)).Returns(webmProcessedVideos);
//Act
List<DomainProcessedVideo> list = processedVideoGenerator.Generate(metadata.Object);
//Assert
Assert.AreEqual(mp4ProcessedVideos.Count + webmProcessedVideos.Count, list.Count);
Assert.IsTrue(mp4ProcessedVideos.All(p => list.Any(procVid => procVid == p)));
Assert.IsTrue(webmProcessedVideos.All(p => list.Any(procVid => procVid == p)));
}
示例3: ShouldRetunAListContaining6ArtistsBasedOnFilterForJoh
public void ShouldRetunAListContaining6ArtistsBasedOnFilterForJoh()
{
//arange
ArtistManager artistManager = new ArtistManager(new EFArtistDAL());
var artistReturnedList = new List<Artist>();
var artistFilter = new ArtistFilter();
artistFilter.ArtistNameAndAliasSearchTerm = "Joh";
List<String> expectedNames = new List<string>();
expectedNames.Add("John Mayer");
expectedNames.Add("Johnny Cash");
expectedNames.Add("Jack Johnson");
expectedNames.Add("John Coltrane");
expectedNames.Add("Elton John");
expectedNames.Add("John Frusciante");
//act
artistReturnedList = artistManager.GetAllRecordsBasedOnFilter(artistFilter);
List<string> actualNames = new List<string>();
foreach(var artist in artistReturnedList)
{
actualNames.Add(artist.ArtistName);
}
// same number of artist and same artits (regardless of order)
bool test = expectedNames.All(actualNames.Contains) && expectedNames.Count == actualNames.Count;
//assert
Assert.AreEqual(true, test);
}
示例4: TestFindShortestRouteBetweenAsyncProgress
public async Task TestFindShortestRouteBetweenAsyncProgress()
{
var cities = new Cities();
cities.ReadCities(CitiesTestFile);
var routes = new Routes(cities);
routes.ReadRoutes(LinksTestFile);
// do synchronous execution
var linksExpected = routes.FindShortestRouteBetween("Basel", "Zürich", TransportMode.Rail);
// do asynchronous execution
var messages = new List<string>();
var progress = new Progress<string>(msg => messages.Add(msg));
var linksActual = await routes.FindShortestRouteBetweenAsync("Basel", "Zürich", TransportMode.Rail, progress);
// let pending tasks execute
await Task.Yield();
// ensure that at least 5 progress calls are made
Assert.IsTrue(messages.Distinct().Count()>=5, "Less than 5 distinct progress messages");
// ensure that all progress messages end with " done"
Assert.IsTrue(messages.All(m => m.EndsWith(" done")),
string.Format("Progress message \"{0}\" does not end with \" done\"",
messages.FirstOrDefault(m => !m.EndsWith(" done"))));
}
示例5: ListExtensions_All_ReturnsFalseIfOneItemDoesNotMatchPredicate
public void ListExtensions_All_ReturnsFalseIfOneItemDoesNotMatchPredicate()
{
var list = new List<Int32>() { 1, 2, 4, 6 };
var result = list.All(x => x % 2 == 0);
TheResultingValue(result).ShouldBe(false);
}
示例6: AreAllStringsLongerThan5_ReturnsTrueWhenAllStringsSatisfy
public void AreAllStringsLongerThan5_ReturnsTrueWhenAllStringsSatisfy()
{
var stringData = new List<string> { "somethingLonger", "aaaaaaaa", "bbbbbbb", "something" };
var expected = stringData.All(s => s.Length > 5);
var result = Ex1.AreAllStringsLongerThan5(stringData);
result.Should().BeTrue();
}
示例7: ListExtensions_All_ReturnsTrueIfAllItemsMatchPredicate
public void ListExtensions_All_ReturnsTrueIfAllItemsMatchPredicate()
{
var list = new List<Int32>() { 2, 4, 6 };
var result = list.All(x => x % 2 == 0);
TheResultingValue(result).ShouldBe(true);
}
示例8: AreAllStringsLongerThan5_ReturnsFalseWhenTooShortStringExists
public void AreAllStringsLongerThan5_ReturnsFalseWhenTooShortStringExists()
{
var stringData = new List<string> {"somethingLonger", "aaaaaaaa", "bbbbbbb", "", "something", "4444"};
var expected = stringData.All(s => s.Length > 5);
var result = Ex1.AreAllStringsLongerThan5(stringData);
result.Should().BeFalse();
}
示例9: ListExtensions_All_ReturnsTrueIfListIsEmpty
public void ListExtensions_All_ReturnsTrueIfListIsEmpty()
{
var list = new List<Int32>();
var result = list.All(x => x % 2 == 0);
TheResultingValue(result).ShouldBe(true);
}
示例10: CompareEnumerable
public static bool CompareEnumerable(IEnumerable<int> e1, IEnumerable<int> e2)
{
if (e1 == null || e2 == null)
return false;
if (ReferenceEquals(e1, e2))
return true;
var l1 = new List<int>(e1);
var l2 = new List<int>(e2);
return l1.Count == l2.Count && l1.All(l2.Remove);
}
示例11: All_abnormal
public void All_abnormal()
{
// arrange
List<String> list = new List<String>() { "Backbone", "Angular", "React" };
// act and assert
try
{
list.All(null);
Assert.Fail();
}
catch (Exception e)
{
Assert.IsTrue(e is ArgumentNullException);
}
}
示例12: StorageFourStoreAddTriples
public void StorageFourStoreAddTriples()
{
StorageFourStoreDeleteGraph();
StorageFourStoreSaveGraph();
Graph g = new Graph();
List<Triple> ts = new List<Triple>();
ts.Add(new Triple(g.CreateUriNode(new Uri("http://example.org/subject")), g.CreateUriNode(new Uri("http://example.org/predicate")), g.CreateUriNode(new Uri("http://example.org/object"))));
FourStoreConnector fourstore = new FourStoreConnector(FourStoreTestUri);
fourstore.UpdateGraph("http://example.org/4storeTest", ts, null);
fourstore.LoadGraph(g, "http://example.org/4storeTest");
Assert.IsTrue(ts.All(t => g.ContainsTriple(t)), "Added Triple should not have been in the Graph");
}
示例13: GetUnderlyingType__The_Underlying_Type_Of_A_Property_Can_Be_Obtained
public void GetUnderlyingType__The_Underlying_Type_Of_A_Property_Can_Be_Obtained()
{
var properties = new MixedProperties();
var propertyInfo = properties.GetType().GetProperties();
var results = new List<bool>
{
propertyInfo[0].GetUnderlyingType() == typeof (bool),
propertyInfo[1].GetUnderlyingType() == typeof (DateTime),
propertyInfo[2].GetUnderlyingType() == typeof (Dog),
propertyInfo[3].GetUnderlyingType() == typeof (int),
propertyInfo[4].GetUnderlyingType() == typeof (DateTime),
propertyInfo[5].GetUnderlyingType() == typeof (string)
};
Assert.IsTrue(results.All(r => r));
}
示例14: IsNullableType__A_Nullable_Property_Can_Be_Detected_As_Nullable
public void IsNullableType__A_Nullable_Property_Can_Be_Detected_As_Nullable()
{
var properties = new MixedProperties();
var propertyInfo = properties.GetType().GetProperties();
var results = new List<bool>
{
propertyInfo[0].IsNullableType() == false,
propertyInfo[1].IsNullableType() == false,
propertyInfo[2].IsNullableType(),
propertyInfo[3].IsNullableType() == false,
propertyInfo[4].IsNullableType(),
propertyInfo[5].IsNullableType()
};
Assert.IsTrue(results.All(r => r));
}
示例15: GetDefaultValue__An_Default_Value_From_A_Property_Can_Be_Obtained
public void GetDefaultValue__An_Default_Value_From_A_Property_Can_Be_Obtained()
{
var properties = new MixedProperties();
var propertyInfo = properties.GetType().GetProperties();
var results = new List<bool>
{
(bool)propertyInfo[0].GetDefaultValue() == false,
(DateTime)propertyInfo[1].GetDefaultValue() == DateTime.MinValue,
(Dog)propertyInfo[2].GetDefaultValue() == null,
(int)propertyInfo[3].GetDefaultValue() == 0,
(DateTime?)propertyInfo[4].GetDefaultValue() == null,
(string)propertyInfo[5].GetDefaultValue() == null
};
Assert.IsTrue(results.All(r => r));
}