コード例 #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 Test()
		{
			TypeAlias alias = new TypeAlias(typeof(ReAddFieldTestCase.Version1), typeof(ReAddFieldTestCase.Version2
				));
			Fixture().Config().AddAlias(alias);
			Reopen();
			Assert.AreEqual(42, ((ReAddFieldTestCase.Version2)RetrieveOnlyInstance(typeof(ReAddFieldTestCase.Version2
				))).id);
			Fixture().Config().RemoveAlias(alias);
			Reopen();
			ReAddFieldTestCase.Version1 original = ((ReAddFieldTestCase.Version1)RetrieveOnlyInstance
				(typeof(ReAddFieldTestCase.Version1)));
			Assert.AreEqual("ltuae", original.name);
			Assert.AreEqual(42, original.id);
		}
コード例 #3
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);
		}
コード例 #4
0
			public virtual void Test()
			{
				ICommonConfigurationProvider config = ((ICommonConfigurationProvider)Subject());
				Config4Impl legacy = Db4oLegacyConfigurationBridge.AsLegacy(config);
				ICommonConfiguration common = config.Common;
				common.ActivationDepth = 42;
				Assert.AreEqual(42, legacy.ActivationDepth());
				Assert.AreEqual(42, common.ActivationDepth);
				// TODO: assert
				common.Add(new _IConfigurationItem_41());
				TypeAlias alias = new TypeAlias("foo", "bar");
				common.AddAlias(alias);
				Assert.AreEqual("bar", legacy.ResolveAliasStoredName("foo"));
				Assert.AreEqual("foo", legacy.ResolveAliasRuntimeName("bar"));
				common.RemoveAlias(alias);
				Assert.AreEqual("foo", legacy.ResolveAliasStoredName("foo"));
				common.AllowVersionUpdates = false;
				Assert.IsFalse(legacy.AllowVersionUpdates());
				common.AutomaticShutDown = false;
				Assert.IsFalse(legacy.AutomaticShutDown());
				common.BTreeNodeSize = 42;
				Assert.AreEqual(42, legacy.BTreeNodeSize());
				common.Callbacks = false;
				Assert.AreEqual(CallBackMode.None, legacy.CallbackMode());
				common.CallConstructors = false;
				Assert.IsTrue(legacy.CallConstructors().DefiniteNo());
				common.DetectSchemaChanges = false;
				Assert.IsFalse(legacy.DetectSchemaChanges());
				DiagnosticCollector collector = new DiagnosticCollector();
				common.Diagnostic.AddListener(collector);
				IDiagnostic diagnostic = DummyDiagnostic();
				legacy.DiagnosticProcessor().OnDiagnostic(diagnostic);
				collector.Verify(new object[] { diagnostic });
				common.ExceptionsOnNotStorable = true;
				Assert.IsTrue(legacy.ExceptionsOnNotStorable());
				common.InternStrings = true;
				Assert.IsTrue(legacy.InternStrings());
				// TODO: assert
				common.MarkTransient("Foo");
				common.MessageLevel = 3;
				Assert.AreEqual(3, legacy.MessageLevel());
				IObjectClass objectClass = common.ObjectClass(typeof(CommonAndLocalConfigurationTestSuite.BaseConfigurationProviderTestUnit.Item
					));
				objectClass.CascadeOnDelete(true);
				Assert.IsTrue(((Config4Class)legacy.ObjectClass(typeof(CommonAndLocalConfigurationTestSuite.BaseConfigurationProviderTestUnit.Item
					))).CascadeOnDelete().DefiniteYes());
				Assert.IsTrue(((Config4Class)common.ObjectClass(typeof(CommonAndLocalConfigurationTestSuite.BaseConfigurationProviderTestUnit.Item
					))).CascadeOnDelete().DefiniteYes());
				common.OptimizeNativeQueries = false;
				Assert.IsFalse(legacy.OptimizeNativeQueries());
				Assert.IsFalse(common.OptimizeNativeQueries);
				common.Queries.EvaluationMode(QueryEvaluationMode.Lazy);
				Assert.AreEqual(QueryEvaluationMode.Lazy, legacy.EvaluationMode());
				// TODO: test reflectWith()
				// TODO: this probably won't sharpen :/
				TextWriter outStream = Sharpen.Runtime.Out;
				common.OutStream = outStream;
				Assert.AreEqual(outStream, legacy.OutStream());
				IStringEncoding stringEncoding = new _IStringEncoding_113();
				common.StringEncoding = stringEncoding;
				Assert.AreEqual(stringEncoding, legacy.StringEncoding());
				common.TestConstructors = false;
				Assert.IsFalse(legacy.TestConstructors());
				common.TestConstructors = true;
				Assert.IsTrue(legacy.TestConstructors());
				common.UpdateDepth = 1024;
				Assert.AreEqual(1024, legacy.UpdateDepth());
				common.WeakReferences = false;
				Assert.IsFalse(legacy.WeakReferences());
				common.WeakReferenceCollectionInterval = 1024;
				Assert.AreEqual(1024, legacy.WeakReferenceCollectionInterval());
			}
コード例 #5
0
			/// <exception cref="System.Exception"></exception>
			public virtual void Test()
			{
				Fixture().ResetConfig();
				IConfiguration config = Fixture().Config();
				config.ReflectWith(((IReflector)ExcludingReflector.Value));
				TypeAlias alias = new TypeAlias(typeof(RemovedClassRefactoringTestSuite.Sub), typeof(
					RemovedClassRefactoringTestSuite.NoSuper));
				config.AddAlias(alias);
				if ((((bool)DoDefragment.Value)))
				{
					Defragment();
				}
				else
				{
					Reopen();
				}
				RemovedClassRefactoringTestSuite.NoSuper result = ((RemovedClassRefactoringTestSuite.NoSuper
					)RetrieveOnlyInstance(typeof(RemovedClassRefactoringTestSuite.NoSuper)));
				Assert.AreEqual("sub", result._subField);
				RemovedClassRefactoringTestSuite.NoSuper newSuper = new RemovedClassRefactoringTestSuite.NoSuper
					("foo");
				Store(newSuper);
				IQuery q = NewQuery(typeof(RemovedClassRefactoringTestSuite.NoSuper));
				q.Descend("_subField").Constrain("foo");
				IObjectSet objectSet = q.Execute();
				Assert.AreEqual(1, objectSet.Count);
				result = ((RemovedClassRefactoringTestSuite.NoSuper)objectSet.Next());
				Assert.AreEqual("foo", result._subField);
				Db().Refresh(result, int.MaxValue);
			}