Files
TimberWinR/TimberWinR.UnitTests/Configuration.cs
Eric Fontana 65de7cbc93 Added Validate method
Added tests to validate the configuration.
2014-07-28 10:55:17 -04:00

76 lines
2.0 KiB
C#

using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TimberWinR;
using TimberWinR.Inputs;
using TimberWinR.Filters;
using Newtonsoft.Json.Linq;
namespace TimberWinR.UnitTests
{
[TestFixture]
public class ConfigurationTest
{
[Test]
public void TestInvalidMatchConfig()
{
string grokJson = @"{
""TimberWinR"":{
""Filters"":[
{
""grok"":{
""condition"": ""[type] == \""Win32-FileLog\"""",
""match"":[
""Text""
]
}
}]
}
}";
try
{
Configuration c = Configuration.FromString(grokJson);
Assert.IsTrue(false, "Should have thrown an exception");
}
catch (TimberWinR.Parser.Grok.GrokFilterException ex)
{
}
}
[Test]
public void TestInvalidAddTagConfig()
{
string grokJson = @"{
""TimberWinR"":{
""Filters"":[
{
""grok"":{
""condition"": ""[type] == \""Win32-FileLog\"""",
""match"":[
""Text"", """"
],
""add_tag"": [
""rn_%{Index}"",
],
}
}]
}
}";
try
{
Configuration c = Configuration.FromString(grokJson);
Assert.IsTrue(false, "Should have thrown an exception");
}
catch (TimberWinR.Parser.Grok.GrokAddTagException ex)
{
}
}
}
}