public void CollectionExtensions_MapReduce_Map_EnumerableWithItems() { var expected = new[] { 2, 4, 6, 8, 10, 12, 14, 16, 18 }; var result = _target.Map(i => i * 2); Assert.IsTrue(expected.SequenceEqual(result)); }
public void TestUbuntu1004() { string filePath = Path.GetFullPath(@"../../../BencodeLibrary_Test/Resources/Ubuntu.torrent"); Assert.IsTrue(File.Exists(filePath), "Test file missing"); BDict torrentFile = BencodingUtils.DecodeFile(filePath) as BDict; // Check various aspects Assert.AreEqual("http://tracker.thepiratebay.org/announce", (torrentFile["announce"] as BString).Value); Assert.AreEqual("Torrent downloaded from http://thepiratebay.org", (torrentFile["comment"] as BString).Value); Assert.AreEqual(1272557269, (torrentFile["creation date"] as BInt).Value); BList announcelist = torrentFile["announce-list"] as BList; List<string> trackers = announcelist.OfType<BList>().Select(s => (s.First() as BString).Value).ToList(); string[] expectedTrackers = new[] { "http://tracker.thepiratebay.org/announce", "udp://tracker.thepiratebay.org:80/announce", "http://torrent.ubuntu.com:6969/announce", "http://ipv6.torrent.ubuntu.com:6969/announce", "udp://tracker.openbittorrent.com:80/announce", "http://tracker.openbittorrent.com/announce" }; Assert.IsTrue(expectedTrackers.SequenceEqual(trackers)); BDict infoDict = torrentFile["info"] as BDict; Assert.AreEqual(733419520, (infoDict["length"] as BInt).Value); Assert.AreEqual(524288, (infoDict["piece length"] as BInt).Value); Assert.AreEqual("ubuntu-10.04-desktop-i386.iso", (infoDict["name"] as BString).Value); BString pieces = infoDict["pieces"] as BString; Assert.AreEqual(27980, pieces.Value.Length); }
public void Verify_Data_Process_Method_FuzzBizz() { IEnumerable<string> expected = new[] { "1", "2", "Fizz", "4", "Buzz", "Fizz", "7", "8", "Fizz", "Buzz", "11", "Fizz", "13", "14", "FizzBuzz" }; Assert.IsTrue(expected.SequenceEqual(_h.FizzBuzz(1, 15))); }
public void ConstructedWithEnumerableBehaviorExpectationsIsCorrect() { // Fixture setup var expectations = new[] { new DelegatingBehaviorExpectation(), new DelegatingBehaviorExpectation(), new DelegatingBehaviorExpectation() }.Cast<IBehaviorExpectation>(); var sut = new CompositeBehaviorExpectation(expectations); // Exercise system var result = sut.BehaviorExpectations; // Verify outcome Assert.True(expectations.SequenceEqual(result)); // Teardown }
public void YieldEnumeratorOfClaims() { var expected = new[] { new Claim("foo", "bar"), new Claim("queue", "qux"), new Claim("Rafael", "Ricardo") }; var sut = new SimpleWebToken(expected); Assert.True(expected.SequenceEqual(sut)); Assert.True(expected.Cast<object>().SequenceEqual(sut.OfType<object>())); }
public void ConstructedWithEnumerableIdiomaticAssertionsIsCorrect() { // Fixture setup IEnumerable<IIdiomaticAssertion> assertions = new[] { new DelegatingIdiomaticAssertion(), new DelegatingIdiomaticAssertion(), new DelegatingIdiomaticAssertion() }.AsEnumerable(); var sut = new CompositeIdiomaticAssertion(assertions); // Exercise system var result = sut.Assertions; // Verify outcome Assert.True(assertions.SequenceEqual(result)); // Teardown }
public void DeleteRangeTest() { var initialRange = new SectorRange(0, 1000); var initialSector = CreateMock<ISector>(); var chopRange = new SectorRange(250, 750); var leftSector = CreateMock<ISector>(); var leftRange = new SectorRange(0, 250); var rightSector = CreateMock<ISector>(); var rightRange = new SectorRange(750, 1000); var leftAndRightRange = new[] { leftRange, rightRange }; var leftAndRightSectors = new[] { leftSector, rightSector }; var leftAndRightRangeAndSectors = new[] { leftRange.PairValue(leftSector), rightRange.PairValue(rightSector) }; When(initialSector.Segment(Eq(initialRange), EqSequence(leftAndRightRange))).ThenReturn(leftAndRightRangeAndSectors); var collection = new SectorCollection(new KeyValuePair<SectorRange, ISector>(initialRange, initialSector).Wrap()); collection.DeleteRange(chopRange); Verify(initialSector).Segment(Eq(initialRange), Any<IEnumerable<SectorRange>>(x => x.SequenceEqual(leftAndRightRange))); VerifyNoMoreInteractions(); AssertTrue(leftAndRightSectors.SequenceEqual(collection.EnumerateSectors())); }
public void ValuesAreCorrectWhenConstructedWithExplicitAutoDataAttribute() { // Fixture setup var dummyAutoDataAttribute = new AutoDataAttribute(); var expectedValues = new[] { new object(), new object(), new object() }; var sut = new InlineAutoDataAttribute(dummyAutoDataAttribute, expectedValues); // Exercise system var result = sut.Values; // Verify outcome Assert.True(expectedValues.SequenceEqual(result)); // Teardown }
public void cant_edit_IEnumerable_int() { IEnumerable<int> sut = new [] {1}; sut.ToArray()[0] = 2; Assert.IsFalse(sut.SequenceEqual(new []{2})); }
public void List_Manipulate_Rotate() { var arr = new[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; int shiftl = -3; //left shift _.List.Rotate(arr, shiftl); Assert.IsTrue(arr.SequenceEqual(new[] { 3, 4, 5, 6, 7, 8, 9, 0, 1, 2 })); //right shift back to normal _.List.Rotate(arr, -shiftl); Assert.IsTrue(arr.SequenceEqual(new[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 })); var shiftr = 5; //right shift again _.List.Rotate(arr, shiftr); Assert.IsTrue(arr.SequenceEqual(new[] { 5, 6, 7, 8, 9, 0, 1, 2, 3, 4 })); shiftl = -12; //testing overflow shift //should be equiv to shift two left _.List.Rotate(arr, shiftl); Assert.IsTrue(arr.SequenceEqual(new[] { 7, 8, 9, 0, 1, 2, 3, 4, 5, 6 })); shiftr = 15; //should be equiv to shift two right _.List.Rotate(arr, shiftr); Assert.IsTrue(arr.SequenceEqual(new[] { 2, 3, 4, 5, 6, 7, 8, 9, 0, 1 })); }
public void WritePrimitiveCollectionPropertyAsAvroTest() { var expected = new[] { 3, 4 }; var value = new ODataCollectionValue { Items = expected }; ODataProperty prop = new ODataProperty { Name = "prop1", Value = value }; MemoryStream ms = new MemoryStream(); this.CreateOutputContext(ms).WriteProperty(prop); ms.Flush(); ms.Seek(0, SeekOrigin.Begin); IEnumerable<object> results = null; using (var reader = AvroContainer.CreateGenericReader(ms)) using (var seqReader = new SequentialReader<object>(reader)) { results = seqReader.Objects; } var records = results.Cast<object[]>().ToList(); Assert.AreEqual(1, records.Count()); Assert.IsTrue(expected.SequenceEqual(records[0].Cast<int>())); }
public void Sequence() { var ints = new[] { 0, 1, 2, 3 }; Assert.That(ints.SequenceEqual(new[] {0, 1, 2, 3}), Is.True); }
public void GetFilesWithContinuationMarker() { //Arrange var response1 = new ListObjectsResponse { IsTruncated = true, NextMarker = "marker1" }; response1.S3Objects.AddRange(new [] { new S3Object { Key = "media/object1" }, new S3Object { Key = "media/object2" } }); var response2 = new ListObjectsResponse { IsTruncated = false }; response2.S3Objects.AddRange(new [] { new S3Object { Key = "media/object3" }, new S3Object { Key = "media/object4" } }); var clientMock = new Mock<IAmazonS3>(); clientMock.Setup(p => p.ListObjects(It.Is<ListObjectsRequest>(req => req.Prefix == "media/1001/" && req.Delimiter == "/" && req.Marker == null))) .Returns(response1); clientMock.Setup(p => p.ListObjects(It.Is<ListObjectsRequest>(req => req.Prefix == "media/1001/" && req.Delimiter == "/" && req.Marker == "marker1"))) .Returns(response2); var provider = CreateProvider(clientMock); //Act var actual = provider.GetFiles("1001/"); //Assert var expected = new[] { "object1", "object2", "object3", "object4" }; Assert.IsTrue(expected.SequenceEqual(actual)); clientMock.VerifyAll(); }
public void GetDirectoriesWithContinuationMarker() { //Arrange var response1 = new ListObjectsResponse { IsTruncated = true, NextMarker = "Marker1" }; response1.CommonPrefixes.AddRange(new[] { "media/1001/", "media/1002/", "media/1003/" }); var response2 = new ListObjectsResponse { IsTruncated = false }; response2.CommonPrefixes.AddRange(new[] { "media/1004/", "media/1005/", "media/1006/" }); var clientMock = new Mock<IAmazonS3>(); clientMock.Setup(p => p.ListObjects(It.Is<ListObjectsRequest>(req => req.Prefix == "media/" && req.Delimiter == "/" && req.Marker == null))) .Returns(response1); clientMock.Setup(p => p.ListObjects(It.Is<ListObjectsRequest>(req => req.Prefix == "media/" && req.Delimiter == "/" && req.Marker == "Marker1"))) .Returns(response2); var provider = CreateProvider(clientMock); //Act var actual = provider.GetDirectories("/"); //Assert var expected = new[] { "1001", "1002", "1003", "1004", "1005", "1006" }; Assert.IsTrue(expected.SequenceEqual(actual)); clientMock.VerifyAll(); }
public void GetDirectories() { //Arrange var response = new ListObjectsResponse { IsTruncated = false }; response.CommonPrefixes.AddRange(new[] { "media/1010/", "media/1011/", "media/1012/" }); var clientMock = new Mock<IAmazonS3>(); clientMock.Setup(p => p.ListObjects(It.Is<ListObjectsRequest>(req => req.Delimiter == "/" && req.Prefix == "media/"))) .Returns(response); var provider = CreateProvider(clientMock); //Act var actual = provider.GetDirectories("/"); //Assert var expected = new[] {"1010", "1011", "1012"}; Assert.IsTrue(expected.SequenceEqual(actual)); clientMock.VerifyAll(); }