Exemplo n.º 1
0
        public void shoud_map_to_a_constant()
        {
            IDataReader reader = GetDataReader();
            var         mapper =
                new DataReaderMapperBuilder <IgnoreType>("shoud_map_to_a_constant")
                .Map("name", TypeMaps.String("myname"))
                .Build();

            Assert.That(mapper.Map(reader).Name, Is.EqualTo("myname"));
        }
Exemplo n.º 2
0
        public void should_be_thread_safe()
        {
            IDataReader reader = GetDataReader();

            var sync = new CountdownEvent(2);

            Action method = () => {
                var mapper =
                    new DataReaderMapperBuilder <IgnoreType>("shoud_map_to_a_constant")
                    .Map("name", TypeMaps.String("myname"))
                    .Build();
                sync.Signal();
                Assert.That(mapper.Map(reader).Name, Is.EqualTo("myname"));
            };

            Action parallel = () => {
                ThreadPool.QueueUserWorkItem(state => method());
                ThreadPool.QueueUserWorkItem(state => method());
            };

            Assert.That(() => parallel(), Throws.Nothing);
            sync.Wait();
        }