public void SetUp() { Tags = new TagCollection(); Tags.Add(new Tag() { name = "v0.2.0" }); Tags.Add(new Tag() { name = "v0.1.0" }); }
public TagCollection Difference(TagCollection other) { var retn = new TagCollection(); List<Tag> shorter = (tags.Count < other.tags.Count) ? tags : other.tags; List<Tag> longer = (tags.Count < other.tags.Count) ? other.tags : tags; for (int i = 0; i < longer.Count; i++) { if (!shorter.Contains(longer[i])) { retn.Add(longer[i]); } } return retn; }
public void CanAddAndCheckContainsTags() { // ARRANGE var tags = new TagCollection(3); // ACT tags.Add("key1", "value1"); tags.Add("key2", "value2"); tags.Add("key0", "value0"); tags = tags.AsReadOnly(); // ASSERT Assert.IsTrue(tags.IndexOf("key0") >= 0); Assert.AreEqual("value0", tags[tags.IndexOf("key0")].Value); Assert.IsTrue(tags.IndexOf("key1") >= 0); Assert.AreEqual("value1", tags[tags.IndexOf("key1")].Value); Assert.IsTrue(tags.IndexOf("key2") >= 0); Assert.AreEqual("value2", tags[tags.IndexOf("key2")].Value); Assert.IsFalse(tags.IndexOf("key3") >= 0); }
//--------------------------------------------------------------------- #region TagAddRemoveEvents private void TagAdded(string tag) { foreach (var item in TagCollection) { if (item.Text == tag) { item.Count++; return; } } TagCollection.Add(new TagModel(tag)); }
public static TagCollection SelectAll() { TagCollection List = new TagCollection(); using (IDataReader rd = SqlHelper.ExecuteReader(DAL.con(), CommandType.StoredProcedure, "tblRss_sp_tblRssTag_Select_SelectAll_linhnx")) { while (rd.Read()) { List.Add(getFromReader(rd)); } } return(List); }
/// <inheritdoc /> public override ITag[] Execute() { if (tags == null) { tags = new TagCollection(); while (MoveNext()) { tags.Add(Current); } } return(tags.ToArray()); }
public void GivenCollection_WhenAddingTag_ThenCountIsIncrementedAndContains() { // Arrange var oldCount = _tags.GetCount <string>(); // Act _tags.Add <string>(); var newCount = _tags.GetCount <string>(); // Assert Assert.That(newCount, Is.EqualTo(oldCount + 1)); Assert.That(_tags.Contains <string>()); }
private static TagCollection ReadNodeTags(XElement node) { var tagCollection = new TagCollection(); foreach (var tagElement in node.Elements("tag")) { var key = tagElement.Attribute("k").Value; var value = tagElement.Attribute("v").Value; tagCollection.Add(key, value); } return(tagCollection); }
public void Add_sets_limit_type() { // arrange var target = new TagCollection(); const TagType expected = TagType.Byte; // act target.Add((byte)127); // assert var actual = target.LimitType; Assert.Equal(expected, actual); }
private static TagCollection ParseTags(string value) { var result = new TagCollection(); if (!string.IsNullOrWhiteSpace(value)) { var tags = value.TrimStart('[').TrimEnd(']').Split(','); foreach (var tag in tags) { result.Add(tag.Trim(" \"".ToCharArray())); } } return(result); }
public TagCollection Union(TagCollection other) { var retn = new TagCollection(); List <Tag> shorter = (tags.Count < other.tags.Count) ? tags : other.tags; List <Tag> longer = (tags.Count < other.tags.Count) ? other.tags : tags; for (int i = 0; i < shorter.Count; i++) { if (longer.Contains(shorter[i])) { retn.Add(shorter[i]); } } return(retn); }
public static TagCollection SelectTagCloud(int top) { TagCollection List = new TagCollection(); SqlParameter[] obj = new SqlParameter[1]; obj[0] = new SqlParameter("top", top); using (IDataReader rd = SqlHelper.ExecuteReader(DAL.con(), CommandType.StoredProcedure , "tblRss_sp_tblRssTag_Select_SelectTagCloud_linhnx", obj)) { while (rd.Read()) { List.Add(getFromReader(rd)); } } return(List); }
public static TagCollection SelectByTinId(SqlConnection con, int Tin_Id) { TagCollection List = new TagCollection(); SqlParameter[] obj = new SqlParameter[1]; obj[0] = new SqlParameter("Tin_Id", Tin_Id); using (IDataReader rd = SqlHelper.ExecuteReader(con, CommandType.StoredProcedure , "tblRss_sp_tblRssTag_Select_SelectByTinId_linhnx", obj)) { while (rd.Read()) { List.Add(getFromReader(rd)); } } return(List); }
/// <summary> /// Initializes the TagElement list from the given string array /// </summary> /// <param name="tagsList">Array of parsed tags (words)</param> private void SetTagList(string[] tagsList) { for (int i = 0; i < tagsList.Length; i++) { tagsList[i] = tagsList[i].Trim(_notAllowedChars); if (!string.IsNullOrEmpty(tagsList[i])) { var newTagElement = new TagElement(tagsList[i], _searchPath); if (!_bannedTagsList.Contains(tagsList[i]) && !_taglist.Contains(newTagElement)) { _taglist.Add(newTagElement); } } } }
public void Add_sets_limit_type() { // arrange TagCollection target; TagType expected; TagType actual; target = new TagCollection(); expected = TagType.Byte; // act target.Add((byte)127); // assert actual = target.LimitType; Assert.AreEqual(expected, actual); }
public ForumThreads ListTaggedLatestThreads(long tenantId, long?pageId, int pageSize, IList <Tag> tags, bool recursive, IUnitOfWork unitOfWork = null) { TagCollection tagCollection = new TagCollection(); foreach (Tag tag in tags) { tagCollection.Add(tag); } IDatabaseManager dbm = _databaseManagerFactory.GetDatabaseManager(unitOfWork); try { int pageIndex = 0; ForumThreads threads = new ForumThreads(); string sql = _sqlManager.GetSql(recursive ? "Sql.ListTaggedLatestThreadsRecursive.sql" : "Sql.ListTaggedLatestThreads.sql"); dbm.SetSQL(sql); dbm.AddParameter("@TenantId", FieldType.BigInt, tenantId); dbm.AddParameter("@PageId", FieldType.BigInt, pageId ?? (object)DBNull.Value); dbm.AddParameter("@PageIndex", FieldType.Int, pageIndex); dbm.AddParameter("@PageSize", FieldType.Int, pageSize); dbm.AddTypedParameter("@Tags", FieldType.Structured, tagCollection.Count == 0 ? null : tagCollection, "cms.TagTableType"); dbm.ExecuteReader(); while (dbm.Read()) { threads.Add(new ForumThreadExtended { Thread = GetThread(dbm), User = GetUser(dbm), LastPostUserId = dbm.DataReaderValue("LastPostUserId") == DBNull.Value ? null : (long?)dbm.DataReaderValue("LastPostUserId"), LastPostUser = dbm.DataReaderValue("LastPostAlias") == DBNull.Value ? null : GetUser(dbm, "LastPost"), PageId = (long)dbm.DataReaderValue("PageId") }); } return(threads); } finally { if (unitOfWork == null) { dbm.Dispose(); } } }
public void Add_adds_unnamed_long() { // arrange TagCollection target; TagLong actual; long expected; expected = 4611686018427387903; target = new TagCollection(); // act actual = target.Add(expected); // assert Assert.IsNotNull(actual); Assert.IsTrue(target.Contains(actual)); Assert.IsEmpty(actual.Name); Assert.AreEqual(expected, actual.Value); }
public void Add_adds_unnamed_short() { // arrange TagCollection target; TagShort actual; short expected; expected = (short)(short.MaxValue >> 1); target = new TagCollection(); // act actual = target.Add(expected); // assert Assert.IsNotNull(actual); Assert.IsTrue(target.Contains(actual)); Assert.IsEmpty(actual.Name); Assert.AreEqual(expected, actual.Value); }
public void Add_adds_unnamed_int() { // arrange TagCollection target; TagInt actual; int expected; expected = 1073741823; target = new TagCollection(); // act actual = target.Add(expected); // assert Assert.NotNull(actual); Assert.True(target.Contains(actual)); Assert.Empty(actual.Name); Assert.Equal(expected, actual.Value); }
public void Add_adds_unnamed_bytearray_object() { // arrange TagCollection target; Tag actual; object expected; expected = new byte[] { 2, 4, 8, 16, 32, 64, 128 }; target = new TagCollection(); // act actual = target.Add(expected); // assert Assert.NotNull(actual); Assert.True(target.Contains(actual)); Assert.Empty(actual.Name); Assert.Equal(expected, actual.GetValue()); }
public void Add_adds_unnamed_intarray_object() { // arrange TagCollection target; Tag actual; object expected; expected = new[] { 2190, 2994, 3248, 4294394 }; target = new TagCollection(); // act actual = target.Add(expected); // assert Assert.NotNull(actual); Assert.True(target.Contains(actual)); Assert.Empty(actual.Name); Assert.Equal(expected, actual.GetValue()); }
public void Add_adds_unnamed_byte() { // arrange TagCollection target; TagByte actual; byte expected; expected = (byte)(byte.MaxValue >> 1); target = new TagCollection(); // act actual = target.Add(expected); // assert Assert.NotNull(actual); Assert.True(target.Contains(actual)); Assert.Empty(actual.Name); Assert.Equal(expected, actual.Value); }
public void Add_adds_unnamed_string() { // arrange TagCollection target; TagString actual; string expected; expected = "HELLO WORLD THIS IS A TEST STRING ÅÄÖ!"; target = new TagCollection(); // act actual = target.Add(expected); // assert Assert.IsNotNull(actual); Assert.IsTrue(target.Contains(actual)); Assert.IsEmpty(actual.Name); Assert.AreEqual(expected, actual.Value); }
public void Add_adds_unnamed_string_object() { // arrange TagCollection target; Tag actual; object expected; expected = "HELLO WORLD THIS IS A TEST STRING ÅÄÖ!"; target = new TagCollection(); // act actual = target.Add(expected); // assert Assert.NotNull(actual); Assert.True(target.Contains(actual)); Assert.Empty(actual.Name); Assert.Equal(expected, actual.GetValue()); }
public void Add_adds_unnamed_double() { // arrange TagCollection target; TagDouble actual; double expected; expected = 8.98846567431158E+307; target = new TagCollection(); // act actual = target.Add(expected); // assert Assert.IsNotNull(actual); Assert.IsTrue(target.Contains(actual)); Assert.IsEmpty(actual.Name); Assert.AreEqual(expected, actual.Value); }
public void Add_adds_unnamed_float_object() { // arrange TagCollection target; Tag actual; object expected; expected = 1.701412E+38F; target = new TagCollection(); // act actual = target.Add(expected); // assert Assert.IsNotNull(actual); Assert.IsTrue(target.Contains(actual)); Assert.IsEmpty(actual.Name); Assert.AreEqual(expected, actual.GetValue()); }
public void Add_adds_unnamed_float() { // arrange TagCollection target; TagFloat actual; float expected; expected = 1.701412E+38F; target = new TagCollection(); // act actual = target.Add(expected); // assert Assert.NotNull(actual); Assert.True(target.Contains(actual)); Assert.Empty(actual.Name); Assert.Equal(expected, actual.Value); }
public void Add_adds_unnamed_double_object() { // arrange TagCollection target; Tag actual; object expected; expected = 8.98846567431158E+307; target = new TagCollection(); // act actual = target.Add(expected); // assert Assert.NotNull(actual); Assert.True(target.Contains(actual)); Assert.Empty(actual.Name); Assert.Equal(expected, actual.GetValue()); }
public void Add_adds_unnamed_long_object() { // arrange TagCollection target; Tag actual; object expected; expected = 4611686018427387903; target = new TagCollection(); // act actual = target.Add(expected); // assert Assert.NotNull(actual); Assert.True(target.Contains(actual)); Assert.Empty(actual.Name); Assert.Equal(expected, actual.GetValue()); }
public void Add_adds_unnamed_short_object() { // arrange TagCollection target; Tag actual; object expected; expected = (short)(short.MaxValue >> 1); target = new TagCollection(); // act actual = target.Add(expected); // assert Assert.NotNull(actual); Assert.True(target.Contains(actual)); Assert.Empty(actual.Name); Assert.Equal(expected, actual.GetValue()); }
public void Add_adds_unnamed_bytearray() { // arrange TagCollection target; TagByteArray actual; byte[] expected; expected = new byte[] { 2, 4, 8, 16, 32, 64, 128 }; target = new TagCollection(); // act actual = target.Add(expected); // assert Assert.IsNotNull(actual); Assert.IsTrue(target.Contains(actual)); Assert.IsEmpty(actual.Name); Assert.AreEqual(expected, actual.Value); }
public void Add_adds_unnamed_intarray() { // arrange TagCollection target; TagIntArray actual; int[] expected; expected = new[] { 2190, 2994, 3248, 4294394 }; target = new TagCollection(); // act actual = target.Add(expected); // assert Assert.IsNotNull(actual); Assert.IsTrue(target.Contains(actual)); Assert.IsEmpty(actual.Name); Assert.AreEqual(expected, actual.Value); }
public void Export3Error2() { using (var ms = new MemoryStream()) { var tag_base = new TagCollection(); tag_base.Add("title", "foo"); tag_base.Add("name", "bar"); tag_base.Export(ms, null); } }
public void Export3Test() { using (var ms = new MemoryStream()) { var tag_base = new TagCollection(); tag_base.Add("title", "foo"); tag_base.Add("name", "bar"); tag_base.Export(ms, Encoding.UTF8); } }
public void ConstructorTest3() { var tag_base = new TagCollection(); tag_base.Add("title", "foo"); tag_base.Add("name", "bar"); var new_tag = new TagCollection(tag_base); Assert.AreEqual(2, new_tag.Count); Assert.AreEqual("foo", new_tag["title"]); Assert.AreEqual("bar", new_tag["name"]); }
public void Export3Error3() { using (var ms = new MemoryStream(new byte[256], false)) { var tag_base = new TagCollection(); tag_base.Add("title", "foo"); tag_base.Add("name", "bar"); tag_base.Export(ms, Encoding.UTF8); } }
public void AddError3() { var tag_base = new TagCollection(); tag_base.Add(string.Empty, "foo"); }
public void AddError6() { var tag_base = new TagCollection(); tag_base.Add("title", "foo\n"); }
public void ConstructorTest7() { var tag_base = new TagCollection(); tag_base.Add("title", "foo"); tag_base.Add("name", "bar"); var buffer = tag_base.Export(Encoding.UTF8); var new_tag = new TagCollection(buffer, Encoding.UTF8); Assert.AreEqual(2, new_tag.Count); Assert.AreEqual("foo", new_tag["title"]); Assert.AreEqual("bar", new_tag["name"]); }
public void Test_ConnectionManager() { for (int i = 0; i < 4; i++) { TcpListener listener = new TcpListener(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 60000)); listener.Start(); var listenerAcceptSocket = listener.BeginAcceptSocket(null, null); TcpClient client = new TcpClient(); client.Connect(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 60000)); var server = listener.EndAcceptSocket(listenerAcceptSocket); listener.Stop(); var tcpClient = new BaseConnection(new SocketCap(client.Client), null, Test_Library_Net_Amoeba.MaxReceiveCount, _bufferManager); var tcpServer = new BaseConnection(new SocketCap(server), null, Test_Library_Net_Amoeba.MaxReceiveCount, _bufferManager); List<ConnectionManager> connectionManagers = new List<ConnectionManager>(); { ConnectionManager serverConnectionManager; ConnectionManager clientConnectionManager; Node serverNode = null; Node clientNode = null; byte[] serverSessionId = null; byte[] clientSessionId = null; { var id = new byte[32]; _random.NextBytes(id); var uris = new string[] { "tcp:localhost:9000", "tcp:localhost:9001", "tcp:localhost:9002" }; serverNode = new Node(id, uris); } { var id = new byte[32]; _random.NextBytes(id); var uris = new string[] { "tcp:localhost:9000", "tcp:localhost:9001", "tcp:localhost:9002" }; clientNode = new Node(id, uris); } { serverSessionId = new byte[32]; _random.NextBytes(serverSessionId); } { clientSessionId = new byte[32]; _random.NextBytes(clientSessionId); } serverConnectionManager = new ConnectionManager(tcpServer, serverSessionId, serverNode, ConnectDirection.In, _bufferManager); clientConnectionManager = new ConnectionManager(tcpClient, clientSessionId, clientNode, ConnectDirection.Out, _bufferManager); var serverTask = Task.Run(() => serverConnectionManager.Connect()); var clientTask = Task.Run(() => clientConnectionManager.Connect()); Task.WaitAll(serverTask, clientTask); Assert.IsTrue(CollectionUtils.Equals(serverConnectionManager.SesstionId, clientSessionId), "ConnectionManager SessionId #1"); Assert.IsTrue(CollectionUtils.Equals(clientConnectionManager.SesstionId, serverSessionId), "ConnectionManager SessionId #2"); Assert.AreEqual(serverConnectionManager.Node, clientNode, "ConnectionManager Node #1"); Assert.AreEqual(clientConnectionManager.Node, serverNode, "ConnectionManager Node #2"); connectionManagers.Add(serverConnectionManager); connectionManagers.Add(clientConnectionManager); } connectionManagers.Randomize(); { var queue = new WaitQueue<PullNodesEventArgs>(); var receiverConnection = connectionManagers[0]; var senderConnection = connectionManagers[1]; receiverConnection.PullNodesEvent += (object sender, PullNodesEventArgs e) => { queue.Enqueue(e); }; List<Node> nodes = new List<Node>(); for (int j = 0; j < 32; j++) { Node node = null; { var id = new byte[32]; _random.NextBytes(id); var uris = new string[] { "net.tcp://localhost:9000", "net.tcp://localhost:9001", "net.tcp://localhost:9002" }; node = new Node(id, uris); } nodes.Add(node); } senderConnection.PushNodes(nodes); var item = queue.Dequeue(); Assert.IsTrue(CollectionUtils.Equals(nodes, item.Nodes), "ConnectionManager #1"); } connectionManagers.Randomize(); { var queue = new WaitQueue<PullBlocksLinkEventArgs>(); var receiverConnection = connectionManagers[0]; var senderConnection = connectionManagers[1]; receiverConnection.PullBlocksLinkEvent += (object sender, PullBlocksLinkEventArgs e) => { queue.Enqueue(e); }; var keys = new List<Key>(); for (int j = 0; j < 32; j++) { Key key = null; { var id = new byte[32]; _random.NextBytes(id); key = new Key(HashAlgorithm.Sha256, id); } keys.Add(key); } senderConnection.PushBlocksLink(keys); var item = queue.Dequeue(); Assert.IsTrue(CollectionUtils.Equals(keys, item.Keys), "ConnectionManager #2"); } connectionManagers.Randomize(); { var queue = new WaitQueue<PullBlocksRequestEventArgs>(); var receiverConnection = connectionManagers[0]; var senderConnection = connectionManagers[1]; receiverConnection.PullBlocksRequestEvent += (object sender, PullBlocksRequestEventArgs e) => { queue.Enqueue(e); }; var keys = new List<Key>(); for (int j = 0; j < 32; j++) { Key key = null; { var id = new byte[32]; _random.NextBytes(id); key = new Key(HashAlgorithm.Sha256, id); } keys.Add(key); } senderConnection.PushBlocksRequest(keys); var item = queue.Dequeue(); Assert.IsTrue(CollectionUtils.Equals(keys, item.Keys), "ConnectionManager #3"); } connectionManagers.Randomize(); { var queue = new WaitQueue<PullBlockEventArgs>(); var receiverConnection = connectionManagers[0]; var senderConnection = connectionManagers[1]; receiverConnection.PullBlockEvent += (object sender, PullBlockEventArgs e) => { queue.Enqueue(e); }; var buffer = _bufferManager.TakeBuffer(1024 * 1024 * 8); var key = new Key(HashAlgorithm.Sha256, Sha256.ComputeHash(buffer)); senderConnection.PushBlock(key, new ArraySegment<byte>(buffer, 0, 1024 * 1024 * 4)); var item = queue.Dequeue(); Assert.AreEqual(key, item.Key, "ConnectionManager #4.1"); Assert.IsTrue(CollectionUtils.Equals(buffer, 0, item.Value.Array, item.Value.Offset, 1024 * 1024 * 4), "ConnectionManager #4.2"); _bufferManager.ReturnBuffer(buffer); _bufferManager.ReturnBuffer(item.Value.Array); } connectionManagers.Randomize(); { var queue = new WaitQueue<PullBroadcastMetadatasRequestEventArgs>(); var receiverConnection = connectionManagers[0]; var senderConnection = connectionManagers[1]; receiverConnection.PullBroadcastMetadatasRequestEvent += (object sender, PullBroadcastMetadatasRequestEventArgs e) => { queue.Enqueue(e); }; var digitalSignature = new DigitalSignature("123", DigitalSignatureAlgorithm.Rsa2048_Sha256); var signatures = new SignatureCollection(); for (int j = 0; j < 32; j++) { signatures.Add(digitalSignature.ToString()); } senderConnection.PushBroadcastMetadatasRequest(signatures); var item = queue.Dequeue(); Assert.IsTrue(CollectionUtils.Equals(signatures, item.Signatures), "ConnectionManager #5.1"); } connectionManagers.Randomize(); { var queue = new WaitQueue<PullBroadcastMetadatasEventArgs>(); var receiverConnection = connectionManagers[0]; var senderConnection = connectionManagers[1]; receiverConnection.PullBroadcastMetadatasEvent += (object sender, PullBroadcastMetadatasEventArgs e) => { queue.Enqueue(e); }; var digitalSignature = new DigitalSignature("123", DigitalSignatureAlgorithm.Rsa2048_Sha256); var metadatas1 = new List<BroadcastMetadata>(); for (int j = 0; j < 4; j++) { var key = new Key(HashAlgorithm.Sha256, new byte[32]); var metadata = new Metadata(1, key, CompressionAlgorithm.Xz, CryptoAlgorithm.Aes256, new byte[32 + 32]); var broadcastMetadata = new BroadcastMetadata("Type", DateTime.UtcNow, metadata, digitalSignature); metadatas1.Add(broadcastMetadata); } senderConnection.PushBroadcastMetadatas(metadatas1); var item = queue.Dequeue(); Assert.IsTrue(CollectionUtils.Equals(metadatas1, item.BroadcastMetadatas), "ConnectionManager #6.1"); } connectionManagers.Randomize(); { var queue = new WaitQueue<PullUnicastMetadatasRequestEventArgs>(); var receiverConnection = connectionManagers[0]; var senderConnection = connectionManagers[1]; receiverConnection.PullUnicastMetadatasRequestEvent += (object sender, PullUnicastMetadatasRequestEventArgs e) => { queue.Enqueue(e); }; var digitalSignature = new DigitalSignature("123", DigitalSignatureAlgorithm.Rsa2048_Sha256); var signatures = new SignatureCollection(); for (int j = 0; j < 32; j++) { signatures.Add(digitalSignature.ToString()); } senderConnection.PushUnicastMetadatasRequest(signatures); var item = queue.Dequeue(); Assert.IsTrue(CollectionUtils.Equals(signatures, item.Signatures), "ConnectionManager #7.1"); } connectionManagers.Randomize(); { var queue = new WaitQueue<PullUnicastMetadatasEventArgs>(); var receiverConnection = connectionManagers[0]; var senderConnection = connectionManagers[1]; receiverConnection.PullUnicastMetadatasEvent += (object sender, PullUnicastMetadatasEventArgs e) => { queue.Enqueue(e); }; var digitalSignature = new DigitalSignature("123", DigitalSignatureAlgorithm.Rsa2048_Sha256); var metadatas1 = new List<UnicastMetadata>(); for (int j = 0; j < 4; j++) { var key = new Key(HashAlgorithm.Sha256, new byte[32]); var metadata = new Metadata(1, key, CompressionAlgorithm.Xz, CryptoAlgorithm.Aes256, new byte[32 + 32]); var unicastMetadata = new UnicastMetadata("Type", digitalSignature.ToString(), DateTime.UtcNow, metadata, digitalSignature); metadatas1.Add(unicastMetadata); } senderConnection.PushUnicastMetadatas(metadatas1); var item = queue.Dequeue(); Assert.IsTrue(CollectionUtils.Equals(metadatas1, item.UnicastMetadatas), "ConnectionManager #8.1"); } connectionManagers.Randomize(); { var queue = new WaitQueue<PullMulticastMetadatasRequestEventArgs>(); var receiverConnection = connectionManagers[0]; var senderConnection = connectionManagers[1]; receiverConnection.PullMulticastMetadatasRequestEvent += (object sender, PullMulticastMetadatasRequestEventArgs e) => { queue.Enqueue(e); }; var tags = new TagCollection(); for (int j = 0; j < 32; j++) { var id = new byte[32]; _random.NextBytes(id); tags.Add(new Tag(RandomString.GetValue(256), id)); } senderConnection.PushMulticastMetadatasRequest(tags); var item = queue.Dequeue(); Assert.IsTrue(CollectionUtils.Equals(tags, item.Tags), "ConnectionManager #9.1"); } connectionManagers.Randomize(); { var queue = new WaitQueue<PullMulticastMetadatasEventArgs>(); var receiverConnection = connectionManagers[0]; var senderConnection = connectionManagers[1]; receiverConnection.PullMulticastMetadatasEvent += (object sender, PullMulticastMetadatasEventArgs e) => { queue.Enqueue(e); }; var digitalSignature = new DigitalSignature("123", DigitalSignatureAlgorithm.Rsa2048_Sha256); var metadatas1 = new List<MulticastMetadata>(); for (int j = 0; j < 4; j++) { var key = new Key(HashAlgorithm.Sha256, new byte[32]); var metadata = new Metadata(1, key, CompressionAlgorithm.Xz, CryptoAlgorithm.Aes256, new byte[32 + 32]); var tag = new Tag("oooo", new byte[32]); var miner = new Miner(CashAlgorithm.Version1, -1, TimeSpan.Zero); var multicastMetadata = new MulticastMetadata("Type", tag, DateTime.UtcNow, metadata, miner, digitalSignature); metadatas1.Add(multicastMetadata); } senderConnection.PushMulticastMetadatas(metadatas1); var item = queue.Dequeue(); Assert.IsTrue(CollectionUtils.Equals(metadatas1, item.MulticastMetadatas), "ConnectionManager #10.1"); } foreach (var connectionManager in connectionManagers) { connectionManager.Dispose(); } client.Close(); server.Close(); } }
public void AddError1() { var tag_base = new TagCollection(); tag_base.Add(null, "foo"); }
public void Export2Test() { var buffer = new byte[100]; var tag_base = new TagCollection(); tag_base.Add("title", "foo"); tag_base.Add("name", "bar"); tag_base.Export(buffer, 0, 100, Encoding.UTF8); }
public void AddError5() { var tag_base = new TagCollection(); tag_base.Add("title=", "foo"); }
public void Export1Test() { var tag_base = new TagCollection(); tag_base.Add("title", "foo"); tag_base.Add("name", "bar"); var buffer = tag_base.Export(Encoding.UTF8); }
public void AddError2() { var tag_base = new TagCollection(); tag_base.Add("title", null); }
public override TagCollection ReadCollection(TagList owner) { TagCollection tags; int length; owner.ListType = (TagType)this.ReadByte(); tags = new TagCollection(owner, owner.ListType); length = this.ReadInt(); for (int i = 0; i < length; i++) { ITag tag; switch (owner.ListType) { case TagType.Byte: tag = TagFactory.CreateTag(TagType.Byte, this.ReadByte()); break; case TagType.ByteArray: tag = TagFactory.CreateTag(TagType.ByteArray, this.ReadByteArray()); break; case TagType.Compound: tag = TagFactory.CreateTag(TagType.Compound); tag.Value = this.ReadDictionary((TagCompound)tag); break; case TagType.Double: tag = TagFactory.CreateTag(TagType.Double, this.ReadDouble()); break; case TagType.End: tag = new TagEnd(); break; case TagType.Float: tag = TagFactory.CreateTag(TagType.Float, this.ReadFloat()); break; case TagType.Int: tag = TagFactory.CreateTag(TagType.Int, this.ReadInt()); break; case TagType.IntArray: tag = TagFactory.CreateTag(TagType.IntArray, this.ReadIntArray()); break; case TagType.List: tag = TagFactory.CreateTag(TagType.List); tag.Value = this.ReadCollection((TagList)tag); break; case TagType.Long: tag = TagFactory.CreateTag(TagType.Long, this.ReadLong()); break; case TagType.Short: tag = TagFactory.CreateTag(TagType.Short, this.ReadShort()); break; case TagType.String: tag = TagFactory.CreateTag(TagType.String, this.ReadString()); break; default: throw new InvalidDataException("Invalid list type."); } tags.Add(tag); } return tags; }
public void Export3Error1() { var tag_base = new TagCollection(); tag_base.Add("title", "foo"); tag_base.Add("name", "bar"); tag_base.Export(null, Encoding.UTF8); }
/// <summary> /// Gets all tags /// </summary> /// <returns></returns> public TagCollection GetAllTags() { TagCollection tc = ZCache.Get<TagCollection>("AllTags"); if (tc == null) { tc = new TagCollection(); TagCollection temp = TagCollection.FetchAll(); foreach (Tag t in temp) { Tag tag = tc.Find( delegate(Tag tempTag) { return tempTag.Name == t.Name; }); if (tag == null) tc.Add(t); } ZCache.InsertCache("AllTags", tc, 90); } return tc; }
public void AddError1() { var tag_base = new TagCollection(); tag_base.Add("foo", "bar"); }