internal static void TestFollowerConcurrency(AbstractClient C) { const int Iterations = 10000; // Two threads racing each other adding and removing followers new Thread(new ThreadStart(() => { for (int i = 0; i < Iterations; i++) { C.AddFollower(R.Next()); } })).Start(); new Thread(new ThreadStart(() => { for (int i = 0; i < Iterations; i++) { var List = C.GetCurrentFollowers(); if (List.Count > 0) { C.RemoveFollower(List[R.Next(List.Count)]); } else { // Remove non-existant followers should work too! C.RemoveFollower(R.Next()); } } })).Start(); // No exception should be thrown Assert.Pass(); }
/// <summary> /// Take data from another client, the other client should be discarded shortly after so this /// instance can take oker /// </summary> /// <param name="Other">Client to take followers and messages from</param> public void TakeOverFrom(AbstractClient Other) { this.Followers = new HashSet<int>(Other.GetCurrentFollowers()); this.Messages = new Queue<Payload>(Other.GetMessages()); }
// Shared with Connected client too internal static void TestFollowers(AbstractClient C) { C.AddFollower(1); C.AddFollower(2); // Double add C.AddFollower(2); C.AddFollower(3); var Followers = C.GetCurrentFollowers(); Assert.That(Followers.Count == 3, "Dummy client's follower adding error! A follower with the same ID can only be added once!"); Assert.That(Followers.Contains(2), "Dummy client's follower adding error!"); Assert.False(Followers.Contains(4), "Dummy client's follower checking error!"); // External modification must not affect internal operation Followers.Add(5); Assert.False(C.GetCurrentFollowers().Contains(5), "Dummy client's GetCurrentFollowers should not return the internal follower list!"); }
internal static void TestMessages(AbstractClient C) { C.QueueMessage(P1); C.QueueMessage(P2); var Messages = C.GetMessages(); C.QueueMessage(null); Assert.That(Messages.Count == 2, "Dummy client's message adding error! Null message should not be queued"); Assert.That(Messages.Contains(P2), "Dummy client's message adding error!"); Assert.False(Messages.Contains(P3), "Dummy client's message checking error!"); // External modification must not affect internal operation Messages.Enqueue(P3); Assert.False(C.GetMessages().Contains(P3), "Dummy client's GetMessages should not return the internal list!"); }
internal MICLoginRequest(AbstractClient client, KinveyAuthRequest.Builder builder, EnumLoginType loginType, ThirdPartyIdentity identity, User user = null) : base(client, builder, loginType, identity) { }
internal static void TestMessageConcurrency(AbstractClient C) { const int Iterations = 10000; new Thread(new ThreadStart(() => { for (int i = 0; i < Iterations; i++) { C.QueueMessage(RandomPayload()); } })).Start(); new Thread(new ThreadStart(() => { for (int i = 0; i < Iterations; i++) { C.QueueMessage(RandomPayload()); } })).Start(); // No exception should be thrown Assert.Pass(); }
/// <summary> /// Espelhas o resultado do layout em um cliente /// </summary> /// <param name="e"></param>Cliente /// <returns></returns>AbstractClient public AbstractClient ToClient(AbstractClient e) { if (!string.IsNullOrEmpty(this.Nome)) { e.RazaoSocial = this.Nome; } if (!string.IsNullOrEmpty(this.Uf)) { e.Uf = this.Uf; } if (!string.IsNullOrEmpty(this.Telefone)) { var tel = this.Telefone.Split('/'); if (tel.Length > 0) { e.Telefone = tel[0].Trim(); if (tel.Length > 1) { e.TelefoneComercial = tel[1].Trim(); } } } if (!string.IsNullOrEmpty(this.Situacao)) { e.SituacaoJuridica = this.Situacao; } if (!string.IsNullOrEmpty(this.Bairro)) { e.Bairro = this.Bairro; } if (!string.IsNullOrEmpty(this.Logradouro)) { e.NomeEndereco = this.Logradouro; } if (!string.IsNullOrEmpty(this.Numero)) { e.NumeroEndereco = this.Numero; } if (!string.IsNullOrEmpty(this.Cep)) { e.Cep = this.Cep; } if (!string.IsNullOrEmpty(this.Municipio)) { e.Cidade = this.Municipio; } if (!string.IsNullOrEmpty(this.Abertura)) { e.Abertura = this.Abertura; } if (!string.IsNullOrEmpty(this.NaturezaJuridica)) { e.NaturezaJuridica = this.NaturezaJuridica; } if (!string.IsNullOrEmpty(this.Fantasia)) { e.NomeFantasia = this.Fantasia; } //essa sera a entrada //c.CpfCnpj = this.Cnpj; if (this.UltimaAtualizacao.HasValue) { e.UltimaAtualizacao = this.UltimaAtualizacao; } if (!string.IsNullOrEmpty(this.Status)) { e.StatusCliente = this.Status; } if (!string.IsNullOrEmpty(this.Tipo)) { e.Tipo = this.Tipo; } if (!string.IsNullOrEmpty(this.Complemento)) { e.Complemento = this.Complemento; } if (!string.IsNullOrEmpty(this.Email)) { e.Email = this.Email; } if (!string.IsNullOrEmpty(this.Efr)) { e.Efr = this.Efr; } if (!string.IsNullOrEmpty(this.MotivoSituacao)) { e.MotivoSituacao = this.MotivoSituacao; } if (!string.IsNullOrEmpty(this.SituacaoEspecial)) { e.SituacaoEspecial = this.SituacaoEspecial; } if (!string.IsNullOrEmpty(this.DataSituacaoEspecial)) { e.DataSituacaoEspecial = this.DataSituacaoEspecial; } if (this.CapitalSocial != 0) { e.CapitalSocial = this.CapitalSocial; } return(e); }
/// <summary> /// Take data from another client, the other client should be discarded shortly after so this /// instance can take oker /// </summary> /// <param name="Other">Client to take followers and messages from</param> public void TakeOverFrom(AbstractClient Other) { this.Followers = new HashSet <int>(Other.GetCurrentFollowers()); this.Messages = new Queue <Payload>(Other.GetMessages()); }
public void AddConnection(AbstractClient abstractClient) { _clients.Add(abstractClient); // создать файл по пути path предварительно }
public void RegisterClient(AbstractClient client) { clients.Add(client); }
public void Handle(AbstractClient client, byte[] buffer) { }