コード例 #1
0
        /// <exception cref="System.Exception"></exception>
        public virtual void TestRetrieval()
        {
            Fixture().ResetConfig();
            var        config    = Fixture().Config();
            IReflector reflector = new ExcludingReflector(new[]
            {
                typeof(Before
                       )
            });

            config.ReflectWith(reflector);
            var alias = new TypeAlias(typeof(Before),
                                      typeof(After));

            config.AddAlias(alias);
            Reopen();
            var after = ((After
                          )RetrieveOnlyInstance(typeof(After)));

            Assert.AreEqual(0, after._id);
            config = Fixture().Config();
            config.ReflectWith(new ExcludingReflector(new Type[] {}));
            config.RemoveAlias(alias);
            Reopen();
            var before = ((Before
                           )RetrieveOnlyInstance(typeof(Before)));

            Assert.AreEqual(42, before._id);
        }
コード例 #2
0
        /// <exception cref="System.Exception"></exception>
        public virtual void TestRetrieval()
        {
            Fixture().ResetConfig();
            IConfiguration config    = Fixture().Config();
            IReflector     reflector = new ExcludingReflector(new Type[] { typeof(RemovedFieldDefragmentTestCase.Before
                                                                                  ) });

            config.ReflectWith(reflector);
            TypeAlias alias = new TypeAlias(typeof(RemovedFieldDefragmentTestCase.Before), typeof(
                                                RemovedFieldDefragmentTestCase.After));

            config.AddAlias(alias);
            Defragment();
            RemovedFieldDefragmentTestCase.After after = ((RemovedFieldDefragmentTestCase.After
                                                           )RetrieveOnlyInstance(typeof(RemovedFieldDefragmentTestCase.After)));
            config = Fixture().Config();
            config.ReflectWith(new ExcludingReflector(new Type[] {  }));
            config.RemoveAlias(alias);
            Reopen();
            RemovedFieldDefragmentTestCase.Before before = ((RemovedFieldDefragmentTestCase.Before
                                                             )RetrieveOnlyInstance(typeof(RemovedFieldDefragmentTestCase.Before)));
            Assert.AreEqual(42, before._id);
        }