예제 #1
0
        public void LoadSection()
        {
            SectionStub uut = new SectionStub();

            uut.LoadFromString(@"<handlerSection>
    <handlers>
      <add storageClassName=""Syslog.TrafficLogger.DbStorer,TrafficLogger"" parserClassName=""Syslog.TrafficLogger.MessageParer,TrafficLogger"" filterIPAdresses="""" connectionString=""Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=syslog;Data Source=.\sql2008r2"">
        <handlerProperties>
          <add key=""match"" value="" type=traffic .* subtype=allowed "" />
          <add key=""table"" value=""sys_log"" />
        </handlerProperties>
      </add>
    </handlers>
  </handlerSection>
");

            Assert.AreEqual(1, uut.Handlers.Count);
            Assert.AreEqual(2, uut.Handlers[0].HandlerProperties.Count);
            Assert.AreEqual(" type=traffic .* subtype=allowed ", uut.Handlers[0].HandlerProperties["match"].Value);
            Assert.AreEqual("sys_log", uut.Handlers[0].HandlerProperties["table"].Value);
        }
예제 #2
0
        public void BeforeEach()
        {
            _sectionProvider = new Mock <ISectionProvider>();
            _typeFactory     = new Mock <ITypeFactory>();
            _mappingFactory  = new Mock <IMappingFactory>();
            _strategyManager = new Mock <IStrategyManager>();
            _mappingStrategy = new Mock <IMappingStrategy>();
            _typeMapping     = new Mock <ITypeMapping>();

            _xElement    = new XElement("element");
            _section     = new SectionStub(_xElement);
            _fooInstance = new Foo();

            _sectionProvider.Setup(sp => sp.GetSection <IFoo>(_mappingStrategy.Object, null)).Returns(_section);
            _strategyManager.Setup(sm => sm.GetStrategyFor <IFoo>()).Returns(_mappingStrategy.Object);
            _typeFactory.Setup(tf => tf.InstanceOf(typeof(IFoo))).Returns(_fooInstance);
            _mappingFactory.Setup(mf => mf.CreateMapping(typeof(Foo), _xElement, _mappingStrategy.Object))
            .Returns(_typeMapping.Object);

            _sut = new MappingEngine(_sectionProvider.Object, _typeFactory.Object, _mappingFactory.Object, _strategyManager.Object);
        }