// GET: /token public ActionResult Index(string device) { // Load Twilio configuration from Web.config var accountSid = ConfigurationManager.AppSettings["TwilioAccountSid"]; var apiKey = ConfigurationManager.AppSettings["TwilioApiKey"]; var apiSecret = ConfigurationManager.AppSettings["TwilioApiSecret"]; var ipmServiceSid = ConfigurationManager.AppSettings["TwilioIpmServiceSid"]; // Create a random identity for the client var identity = Internet.UserName(); // Create an IP messaging grant for this token var grants = new HashSet <IGrant> { new IpMessagingGrant { EndpointId = $"TwilioChatDemo:{identity}:{device}", ServiceSid = ipmServiceSid } }; // Create an Access Token generator var token = new Token( accountSid, apiKey, apiSecret, identity, grants: grants ); return(Json(new { identity = identity, token = token.ToJwt() }, JsonRequestBehavior.AllowGet)); }
public async Task E_Possivel_Invocar_a_UsersController_GetAll_Retornando_BadRequest() { var serviceMock = new Mock <IUserService>(); serviceMock.Setup(m => m.GetAll()).ReturnsAsync(new List <UserDto> { new UserDto { Id = Guid.NewGuid(), Name = Name.FullName(), Email = Internet.Email(), CreateAt = DateTime.UtcNow }, new UserDto { Id = Guid.NewGuid(), Name = Name.FullName(), Email = Internet.Email(), CreateAt = DateTime.UtcNow } }); _controller = new UsersController(serviceMock.Object); _controller.ModelState.AddModelError("Id", "Formato Invalido"); var result = await _controller.GetAll(); Assert.True(result is BadRequestObjectResult); }
// GET: /token public ActionResult Index(string Device) { // Load Twilio configuration from Web.config var AccountSid = ConfigurationManager.AppSettings["TwilioAccountSid"]; var ApiKey = ConfigurationManager.AppSettings["TwilioApiKey"]; var ApiSecret = ConfigurationManager.AppSettings["TwilioApiSecret"]; var IpmServiceSid = ConfigurationManager.AppSettings["TwilioIpmServiceSid"]; // Create a random identity for the client var Identity = Internet.UserName(); // Create an Access Token generator var Token = new AccessToken(AccountSid, ApiKey, ApiSecret); Token.Identity = Identity; // Create an IP messaging grant for this token var grant = new IpMessagingGrant(); grant.EndpointId = $"TwilioChatDemo:{Identity}:{Device}"; grant.ServiceSid = IpmServiceSid; Token.AddGrant(grant); return(Json(new { identity = Identity, token = Token.ToJWT() }, JsonRequestBehavior.AllowGet)); }
private static void GenEmployment(int nRecords) { for (int i = 0; i < nRecords; i++) { try { Employee insertEmployee = new Employee(); insertEmployee.FirstName = Name.First(); insertEmployee.LastName = Name.Last(); insertEmployee.Phone = GenPhone(); insertEmployee.Email = Internet.Email(); insertEmployee.City = Faker.Address.City(); insertEmployee.Province = GetRandProvince(); insertEmployee.Street = Faker.Address.StreetAddress(); insertEmployee.PostalCode = GetPostalCode(); insertEmployee.Role = SelectRandomFromString(new string[] { "kitchen assistant", "Helper" }); insertEmployee.Type = "F"; if (insertEmployee.Type == "F") { insertEmployee.Salary = RandomNumber.Next(500, 4000); insertEmployee.EmploymentDate = DateTime.Now.AddDays(RandomNumber.Next(-500, 0)); } insertEmployee.Create(); } catch { } } }
public void GivenIHaveEnteredInvalidDetail(int ignore) { _ignore = ignore - 1; if (!(ignore == 1)) { _spartaFormPage.Firstname = Name.First(); } if (!(ignore == 2)) { _spartaFormPage.Lastname = Name.Last(); } if (!(ignore == 3)) { _spartaFormPage.Age = RandomNumber.Next(99).ToString(); } if (!(ignore == 4)) { _spartaFormPage.Address = Address.StreetAddress(); } if (!(ignore == 5)) { _spartaFormPage.Postcode = Address.UkPostCode(); } if (!(ignore == 6)) { _spartaFormPage.EmailAddress = Internet.Email(); } if (!(ignore == 7)) { _spartaFormPage.PhoneNumber = Phone.Number(); } }
public async Task E_Possivel_Invocar_a_UsersController_GetAll_Retornando_Ok() { var serviceMock = new Mock <IUserService>(); serviceMock.Setup(m => m.GetAll()).ReturnsAsync(new List <UserDto> { new UserDto { Id = Guid.NewGuid(), Name = Name.FullName(), Email = Internet.Email(), CreateAt = DateTime.UtcNow }, new UserDto { Id = Guid.NewGuid(), Name = Name.FullName(), Email = Internet.Email(), CreateAt = DateTime.UtcNow } }); _controller = new UsersController(serviceMock.Object); var result = await _controller.GetAll(); Assert.True(result is OkObjectResult); var resultValue = ((OkObjectResult)result).Value as IEnumerable <UserDto>; Assert.NotNull(resultValue); Assert.True(resultValue.Count() == 2); }
public Retorno VerificaConexao() { try { Abrir(); Fechar(); return(new Retorno(true)); } catch (Exception ex) { if (Internet.Conectado()) { Erro erro = new Erro() { Descricao = ex.Message, Imagem = Guid.NewGuid().ToString(), CasoDeUso = EnumCasoDeUso.BASE, Camada = EnumCamada.DATA, Funcionalidade = EnumFuncionalidade.VERIFICA_CONEXAO, Entidade = "Conexão" }; Util.Print(erro); if (Internet.Conectado()) { ISEmail.EnviarErro(erro); } } return(new Retorno(false, String.Format(Mensagens.MSG_03, ex.Message))); } }
public void ShouldBySycnedAfterStartUpIfConnected() { Internet.SetConnected(true); _onlineDataService.SetUserDataExists(true, DateTime.Now.AddDays(-1)); Target.Startup(UserName); Assert.IsTrue(_onlineDataService.ConnectionTracker.Synced); }
public void Should_Generate_Password() { string password = Internet.Password(8, 16); Assert.That(password, Has.Length.GreaterThanOrEqualTo(8) .And.Length.LessThanOrEqualTo(16)); }
public void Should_Generate_Slug() { string slug = Internet.Slug(); Assert.That(slug, Is.StringMatching("^[A-Za-z_\\.\\-]+$")); }
public void Should_Generate_Mac_Address_With_Existing_Prefix() { string mac = Internet.MacAddress("0F:3A"); Assert.That(mac, Is.StringMatching(@"^0F:3A:([0-9A-F]{2}:){3}([0-9A-F]{2})$")); }
public void Should_Generate_Mac_Address_With_Custom_Group_Split() { string mac = Internet.MacAddress(groupSplit: '-'); Assert.That(mac, Is.StringMatching(@"^([0-9A-F]{2}-){5}([0-9A-F]{2})$")); }
public void Should_Generate_Mac_Address() { string mac = Internet.MacAddress(); Assert.That(mac, Is.StringMatching(@"^([0-9A-F]{2}:){5}([0-9A-F]{2})$")); }
// GET: /token public ActionResult Index(string Device) { // Load Twilio configuration from Web.config var accountSid = ConfigurationManager.AppSettings["TwilioAccountSid"]; var apiKey = ConfigurationManager.AppSettings["TwilioApiKey"]; var apiSecret = ConfigurationManager.AppSettings["TwilioApiSecret"]; var videoConfigSid = ConfigurationManager.AppSettings["TwilioConfigurationSid"]; // Create a random identity for the client var identity = Internet.UserName(); // Create an Access Token generator var token = new AccessToken(accountSid, apiKey, apiSecret); token.Identity = identity; // Create a video grant for this token var grant = new ConversationsGrant(); grant.ConfigurationProfileSid = videoConfigSid; token.AddGrant(grant); return(Json(new { identity = identity, token = token.ToJWT() }, JsonRequestBehavior.AllowGet)); }
public Retorno CarregaUltimoRegistro(string tabela, string chavePrimaria) { try { CommandSQL = new StringBuilder(); CommandSQL.Append("SELECT MAX(" + chavePrimaria + ") FROM " + tabela); Command = CriaComandoSQL(CommandSQL.ToString()); return(new Retorno(Command.ExecuteScalar())); } catch (Exception ex) { if (Internet.Conectado()) { ISEmail.EnviarErro(new Erro() { Descricao = ex.Message, Imagem = Guid.NewGuid().ToString(), CasoDeUso = EnumCasoDeUso.BASE, Camada = EnumCamada.DATA, Funcionalidade = EnumFuncionalidade.RECUPERA_ULTIMO_REGISTRO, Entidade = "Ultimo Registro" } ); } return(new Retorno(false, String.Format(Mensagens.MSG_05, ex.Message, "Recuperar Ultimo Registro"))); } }
public void Should_Create_Email_Address_From_Given_Name() { string email = Internet.Email("Bob Smith"); Assert.That(email, Is.StringMatching(@"^bob[_\.]smith@") .And.StringMatching(EMAIL_REGEX)); }
public void emailUser(string username, string pass, string email) { string subject = "Successful User Registration"; string message = "You are successfully added as a User. Your username: "******" and your password: "******" are now in use. Be mindful of changing the password at your first login."; try { bool isSuccess = Internet.sendMail(email, subject, message); if (isSuccess) { notifySendSuccess.Icon = SystemIcons.Application; notifySendSuccess.BalloonTipText = "Email sent successfully!"; notifySendSuccess.ShowBalloonTip(1000); } else { MessageBox.Show("Something went wrong!\nPlease check your internet connection and email address", "Mail Sender", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception) { MessageBox.Show("Something went wrong!\nPlease check your internet connection and email address", "Mail Sender", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public FrmTcmbKurlari() { InitializeComponent(); _tarih = new Tarih(); _internet = new Internet(_tarih); }
public void E_Possivel_Mapear_Lista_Entity_P_Lista_DTOs() { var listEntity = new List <UserEntity>(); for (int i = 0; i < 10; i++) { var entity = new UserEntity { Id = Guid.NewGuid(), Name = Name.FullName(), Email = Internet.Email(), CreateAt = DateTime.UtcNow, UpdateAt = DateTime.UtcNow }; listEntity.Add(entity); } var listDto = Mapper.Map <List <UserDto> >(listEntity); Assert.True(listDto.Count() == listEntity.Count()); for (int i = 0; i < listEntity.Count(); i++) { Assert.Equal(listDto[i].Id, listEntity[i].Id); Assert.Equal(listDto[i].Name, listEntity[i].Name); Assert.Equal(listDto[i].Email, listEntity[i].Email); Assert.Equal(listDto[i].CreateAt, listEntity[i].CreateAt); Assert.Equal(listDto[i].UpdateAt, listEntity[i].UpdateAt); } }
public async Task Should_add_a_message() { var seededConference = await TestDataManager.SeedConference(); _newConferenceId = seededConference.Id; var participants = seededConference.Participants; var from = participants.First(x => x.UserRole == UserRole.Judge).DisplayName; var messageText = Internet.DomainWord(); var to = "VH Officer"; var command = new AddInstantMessageCommand(_newConferenceId, from, messageText, to); await _handler.Handle(command); List <InstantMessage> instantMessages; using (var db = new VideoApiDbContext(VideoBookingsDbContextOptions)) { instantMessages = await db.InstantMessages .Where(x => x.ConferenceId == command.ConferenceId).ToListAsync(); } var message = instantMessages.First(); message.Should().NotBeNull(); message.From.Should().Be(from); message.MessageText.Should().Be(messageText); message.TimeStamp.Should().BeBefore(DateTime.UtcNow); message.ConferenceId.Should().Be(command.ConferenceId); message.To.Should().Be(to); }
private void netcheck_fun() { try { //检测多次网络是否畅通 if (Init_Check_Neting) { return; } int count = 5; bool flag = false; Init_Check_Neting = true; while (count > 0) { count--; flag = Internet.IsConnectInternet(); if (!flag) { Thread.Sleep(1000); } else { count = 0; } } this.Init_Check_Net = flag; Init_Check_Neting = false; } catch (Exception ex) { LogisTrac.WriteLog(ex.Message); } }
public void Should_Create_Email_Address() { string email = Internet.Email(); Assert.That(email, Is.StringMatching(EMAIL_REGEX) .And.Not.Contains("www")); }
public void IPv6CIDR_HappyDays() { var ipV6withMask = Internet.IPv6CIDR(); Assert.IsTrue(Regex.Match(ipV6withMask, "[0-9abcdef]{4}:[0-9abcdef]{4}:[0-9abcdef]{4}:[0-9abcdef]{4}:[0-9abcdef]{4}:[0-9abcdef]{4}:[0-9abcdef]{4}:[0-9abcdef]{4}/[0-9]{1,3}").Success, $"{nameof(ipV6withMask)} is '{ipV6withMask}'"); }
public void IPv6Address_HappyDays() { var ipV6Address = Internet.IPv6Address(); Assert.IsTrue(Regex.Match(ipV6Address, "[0-9abcdef]{4}:[0-9abcdef]{4}:[0-9abcdef]{4}:[0-9abcdef]{4}:[0-9abcdef]{4}:[0-9abcdef]{4}:[0-9abcdef]{4}:[0-9abcdef]{4}").Success, $"{nameof(ipV6Address)} is '{ipV6Address}'"); }
public void IPv4CIDR_HappyDays() { var ipV4cidr = Internet.IPv4CIDR(); Assert.AreEqual(1, RegexMatchesCount(ipV4cidr, "/")); Assert.AreEqual(3, RegexMatchesCount(ipV4cidr, @"\.")); }
/// <summary> /// Utilise la page de recherche de Imdb pour retrouver les adresses de la ou des pages /// consacrees au film /// </summary> /// <returns></returns> protected override List <string> PageRecherche(string Titre) { List <string> result = new List <string>(); MainForm.WriteMessageToConsole("Recherche page film " + Titre); string requete = string.Format(PAGE_RECHERCHE, requeteIMDB(Titre)); HtmlDocument doc = Internet.getInstance().loadPage(requete); MainForm.WriteMessageToConsole("Requete " + requete); HtmlNodeCollection ahrefs = doc.DocumentNode.SelectNodes(LIENS_PAGES_FILMS); if (ahrefs != null) { MainForm.WriteMessageToConsole(ahrefs.Count + " pages de film trouvees"); foreach (HtmlNode ahref in ahrefs) { string adresse = string.Format(PAGE_FILM, ahref.Attributes["href"].Value); if (!result.Contains(adresse)) { result.Add(adresse); } } } else { MainForm.WriteMessageToConsole("Page non trouvée"); } return(result); }
public void Should_Get_Domain_Word() { var word = Internet.DomainWord(); Console.WriteLine($@"DomainWord=[{word}]"); Assert.IsTrue(Regex.IsMatch(word, @"^\w+$")); }
public void Should_Get_Secure_Url() { var url = Internet.SecureUrl(); Console.WriteLine($@"Url=[{url}]"); Assert.IsTrue(Regex.IsMatch(url, @"(https:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]+\.[^\s]{2,}|www\.[a-zA-Z0-9]+\.[^\s]{2,})")); }
public void Should_Get_Domain_Name() { var domain = Internet.DomainName(); Console.WriteLine($@"DomainName=[{domain}]"); Assert.IsTrue(Regex.IsMatch(domain, @"\w+\.\w+")); }
public void Should_Create_User_Name_From_Given_Name() { var username = Internet.UserName("Bob Smith"); Console.WriteLine($@"UserName=[{username}]"); Assert.IsTrue(Regex.IsMatch(username, @"bob[_\.]smith")); }
private void ProgressChanged(Internet.DownloadTask task) { string file = Path.GetFileName(task.FileName); string text = string.Format("Downloading file : \"{0}\"... {1}% [{2} out of {3}] completed.", file, task.ProgressPercentage, Functions.FormatMemory(task.Received), Functions.FormatMemory(task.Total)); Interactivity.SetStatus(text); Interactivity.SetProgress(task.Received, task.Total); }
private void username_completed(Internet.DownloadTask task) { usernameButton.UseWaitCursor = false; if (task.Status == Internet.ProgressStatus.Completed) { LoadUsernames(); usernameBox.Text = ""; usernameStatus.Text = "Added " + task.Token.ToString(); } else { usernameStatus.Text = task.Error.Message; } }
public static void DownloadUserid(string name, Internet.DownloadTaskHandler complete) { string url = "http://uhunt.felix-halim.net/api/uname2uid/" + name; DownloadTask dt = new DownloadTask(url, null, name, 2); if (LocalDatabase.ContainsUser(name)) { dt.Result = LocalDatabase.GetUserid(name); dt.Status = ProgressStatus.Completed; if (complete != null) complete(dt); } else { dt.DownloadCompletedEvent += __DownloadUseridCompleted; if (complete != null) dt.DownloadCompletedEvent += complete; DownloadAsync(dt, Priority.High); } }