public void RedactCompleteWordsNextToPunctuationRedactBlacklistedWords() { string[] args = { "string" }; var blacklistFilter = new BlacklistFilter(args); var message = new Message(DateTimeOffset.FromUnixTimeSeconds(Convert.ToInt64("1448470901")), "name", "tested string!"); blacklistFilter.ApplyRegexRedaction(message); Assert.That(message.content, Is.EqualTo("tested *redacted*!")); }
private void BindGridData() { var filter = new BlacklistFilter() { ID_CARD = txtIDCard.Text, }; _container.Filter = filter; _container = _service.Retrieve(_container); SetDataSourceHeader(gridBlackList, ListHeader(), _container.ResultObj); }
public void RedactWordTest() { var messages = new List <Message>(); var messageOne = new Message(DateTimeOffset.FromUnixTimeSeconds(Convert.ToInt64("1448470901")), "stan", "i tested stringone"); messages.Add(messageOne); var messageTwo = new Message(DateTimeOffset.FromUnixTimeSeconds(Convert.ToInt64("1448470901")), "bob", "i tested stringtwo"); messages.Add(messageTwo); var conversation = new Conversation("test", messages); string[] args = { "tested", "stringtwo" }; var BlacklistFilter = new BlacklistFilter(args); BlacklistFilter.ApplyFilter(conversation); var filteredMessages = conversation.messages.ToList(); Assert.That(filteredMessages[0].content, Is.EqualTo("i *redacted* stringone")); Assert.That(filteredMessages[1].content, Is.EqualTo("i *redacted* *redacted*")); }
public void LoadTest([Values("192.168.0.3:213", "10.1.0.3:344")] string address, [Values("www.cnn.com", "www.badsite.xxx")] string host) { string xml = "<?xml version='1.0' encoding='utf-8' ?>" + "<Blacklist>" + "<Hosts>" + "<IP address='10.0.0.0/8'/>" + "</Hosts>" + "<Urls>" + "<Url name='.xxx'/>" + "</Urls>" + "</Blacklist>"; XDocument document = XDocument.Parse(xml); Mock<ISettingsFileLoader> mockLoader = new Mock<ISettingsFileLoader>(); mockLoader.Setup(m => m.LoadFile(SettingsFileType.Blacklist)).Returns(document); Mock<IHttpHeaders> headers = new Mock<IHttpHeaders>(); headers.SetupGet(m => m["host"]).Returns(host); Mock<IHttpRequest> request = new Mock<IHttpRequest>(); request.SetupGet(m => m.Headers).Returns(headers.Object); BlacklistFilter blacklistFilter = new BlacklistFilter(mockLoader.Object); if (address == "10.1.0.3:344" || host == "www.badsite.xxx") { Assert.That( blacklistFilter.EvaluateFilter( request.Object, address ), Is.Not.Null ); } else { Assert.That(blacklistFilter.EvaluateFilter(request.Object, address), Is.Null); } }