public void TestRemoveEmptyElements() { string[] arrayWithEmpties = new string[] { "", "lorem", "ipsum", null, String.Empty, "xxx" }; string[] expectedArray = new string[] { "lorem", "ipsum", "xxx" }; int expectedLength = 3; string[] returnedArray = LipsumUtilities.RemoveEmptyElements(arrayWithEmpties); CollectionAssert.DoesNotContain(returnedArray, ""); CollectionAssert.AllItemsAreNotNull(returnedArray); CollectionAssert.AllItemsAreInstancesOfType(returnedArray, typeof(String)); #if PORTABLE Assert.AreEqual(expectedLength, returnedArray.Length); CollectionAssert.AreEqual(expectedArray, returnedArray); #else CollectionAssert.AreCountEqual(expectedLength, returnedArray); CollectionAssert.AreElementsEqual(expectedArray, returnedArray); #endif }
public void EmptyGraph() { algo = new DataTableJoinSortAlgorithm(this.graph); algo.Compute(); Assert.IsNull(algo.StartVertex); CollectionAssert.AreCountEqual(0, algo.Joins); }
public void UsersOnly() { DataTableJoinVertex users = this.graph.AddVertex(this.dataSource.Users, "U"); algo = new DataTableJoinSortAlgorithm(this.graph); algo.Compute(); Assert.IsNotNull(algo.StartVertex); Assert.AreEqual(users, algo.StartVertex); CollectionAssert.AreCountEqual(0, algo.Joins); ShowJoins(); }
public void ConcatTwoTuples() { ITuple tuple2 = new Tuple(); tuple2.Add("tuple2"); this.target.Add("target"); this.target.Concat(tuple2); CollectionAssert.AreCountEqual(2, target); Assert.AreEqual("target", target[0]); Assert.AreEqual("tuple2", target[1]); }
protected void CheckResult() { CollectionAssert.AreCountEqual(g.VerticesCount, topo.SortedVertices); IVertex u = null; foreach (IVertex v in this.topo.SortedVertices) { if (u != null) { CheckOrder(u, v); } u = v; } }
public void AddAndRemoveOneEdge() { AdjacencyGraph g = new AdjacencyGraph(); IVertex v = g.AddVertex(); IVertex u = g.AddVertex(); IEdge edge = g.AddEdge(u, v); this.target = new ReversedEdgeAugmentorAlgorithm(g); target.AddReversedEdges(); target.RemoveReversedEdges(); Assert.AreEqual(2, this.target.VisitedGraph.VerticesCount); Assert.AreEqual(1, this.target.VisitedGraph.EdgesCount); CollectionAssert.AreCountEqual(0, this.target.AugmentedEdges); Assert.AreEqual(0, this.target.ReversedEdges.Count); }
public void SortsEventIndexDescending() { List <Post> sorted = _posts.OrderBy(p => p, new DateDescendingPostComparer(StartDateField)).ToList(); CollectionAssert.AreCountEqual(_originalPosts, sorted); CollectionAssert.AreEquivalent(_originalPosts, sorted); // Assert that // - posts without date come first, // - posts following the first date post also have dates, // - posts without date are sorted by title (ascending), // - posts with date are sorted by date (descending). bool firstDatePostReached = false; DateTime?lastDate = null; Post lastPost = null; foreach (Post post in sorted) { DateTime date; bool hasDate = DateTime.TryParse(post[StartDateField], out date); if (hasDate) { firstDatePostReached = true; } if (firstDatePostReached && !hasDate) { Assert.Fail("There are posts without dates following a post with a date."); } if (!firstDatePostReached && lastPost != null) { Assert.GreaterEqualThan(post.Title, lastPost.Title); } if (firstDatePostReached && lastDate != null && hasDate) { Assert.LowerEqualThan(date, lastDate.Value, post.Title + " " + lastPost.Title); } lastPost = post; lastDate = hasDate ? date : (DateTime?)null; } }
public void AddOneEdge() { AdjacencyGraph g = new AdjacencyGraph(); IVertex v = g.AddVertex(); IVertex u = g.AddVertex(); IEdge edge = g.AddEdge(u, v); this.target = new ReversedEdgeAugmentorAlgorithm(g); target.AddReversedEdges(); Assert.AreEqual(2, this.target.VisitedGraph.VerticesCount); Assert.AreEqual(2, this.target.VisitedGraph.EdgesCount); CollectionAssert.AreCountEqual(1, this.target.AugmentedEdges); VerifyReversedEdges(); IEdge reversedEdge = this.target.ReversedEdges[edge]; Assert.IsNotNull(reversedEdge); Assert.IsTrue(this.target.AugmentedEdges.Contains(reversedEdge)); }
public void AddAndCount() { this.target.Add(0); CollectionAssert.AreCountEqual(1, this.target); }
public void AreCountEqualNull() { CollectionAssert.AreCountEqual(null, null); }
public void AreCountEqual() { CollectionAssert.AreCountEqual(4, arr); }