public void TestResolvers() { ResolverCollection resolvers = new ResolverCollection(); ConfigurationSectionHelper testHelper = new ConfigurationSectionHelper(); testHelper.Resolvers = resolvers; Assert.AreEqual(resolvers, testHelper.Resolvers); }
public void Resolver_Collection_Is_Reset() { BaseResolver.Current = new BaseResolver(); BaseResolver2.Current = new BaseResolver2(); BaseResolver3.Current = new BaseResolver3(); ResolverCollection.ResetAll(); Assert.AreEqual(0, ResolverCollection.Count); Assert.Throws <InvalidOperationException>(() => { var c = BaseResolver.Current; }); Assert.Throws <InvalidOperationException>(() => { var c = BaseResolver2.Current; }); Assert.Throws <InvalidOperationException>(() => { var c = BaseResolver3.Current; }); //this should not error! BaseResolver.Current = new BaseResolver(); BaseResolver2.Current = new BaseResolver2(); BaseResolver3.Current = new BaseResolver3(); Assert.Pass(); }
public override void TearDown() { base.TearDown(); _testApp = null; ResolverCollection.ResetAll(); }
public void TestAdd() { ResolverCollection collection = new ResolverCollection(); ResolverConfigurationElement element = new ResolverConfigurationElement(); collection.Add(element); ResolverConfigurationElement[] returnedElements = new ResolverConfigurationElement[1]; collection.CopyTo(returnedElements, 0); Assert.AreEqual(element, returnedElements[0]); }
public virtual void TestTearDown() { UmbracoExamineSearcher.DisableInitializationCheck = null; BaseUmbracoIndexer.DisableInitializationCheck = null; //reset all resolvers ResolverCollection.ResetAll(); //reset resolution itself (though this should be taken care of by resetting any of the resolvers above) Resolution.Reset(); }
/// <summary> /// This will dispose and reset all resources used to run the application /// </summary> /// <remarks> /// IMPORTANT: Never dispose this object if you require the Umbraco application to run, disposing this object /// is generally used for unit testing and when your application is shutting down after you have booted Umbraco. /// </remarks> void IDisposable.Dispose() { // Only operate if we haven't already disposed if (_disposed) { return; } using (new WriteLock(_disposalLocker)) { // Check again now we're inside the lock if (_disposed) { return; } //clear the cache if (ApplicationCache != null) { ApplicationCache.RuntimeCache.ClearAllCache(); ApplicationCache.IsolatedRuntimeCache.ClearAllCaches(); } //reset all resolvers ResolverCollection.ResetAll(); //reset resolution itself (though this should be taken care of by resetting any of the resolvers above) Resolution.Reset(); //reset the instance objects this.ApplicationCache = null; if (_databaseContext != null) //need to check the internal field here { if (_databaseContext.ScopeProvider.AmbientScope != null) { var scope = _databaseContext.ScopeProvider.AmbientScope; scope.Dispose(); } /* * if (DatabaseContext.IsDatabaseConfigured && DatabaseContext.Database != null) * { * DatabaseContext.Database.Dispose(); * } */ } this.DatabaseContext = null; this.Services = null; this._isReady = false; //set the internal field // Indicate that the instance has been disposed. _disposed = true; } }
public void TestParsingResolvers() { ConfigurationSectionHelper helper = new ConfigurationSectionHelper(); ResolverConfigurationElement resolver = new ResolverConfigurationElement(); resolver.ResolverTypeName = "RockSolidIoc.Tests.MockFriendlyResolver"; resolver.TypeName = "System.String"; ResolverCollection collection = new ResolverCollection(); collection.Add(resolver); helper.Resolvers = collection; Configurator testConfigurator = new Configurator(); IIocContainer result = testConfigurator.Configure(helper); string s = result.Resolve<string>(); MockFriendlyResolver.Mock.Verify(p => p.ResolveDependency(typeof(string), result), Times.Exactly(1)); MockFriendlyResolver.ResetMock(); }
public void TestIsNotReadOnly() { ResolverCollection collection = new ResolverCollection(); Assert.IsFalse(collection.IsReadOnly()); }
public virtual void TestTearDown() { ResolverCollection.ResetAll(); Resolution.Reset(); }