Ejemplo n.º 1
0
		/// <summary>
		/// Initialize the application entry point.
		/// </summary>
		/// <param name="application">
		/// A <see cref="ApplicationBase"/> to handle request.
		/// </param>
		/// <exception cref="ArgumentNullException">When <paramref name="application"/> is <value>null</value>.</exception>
		/// <exception cref="InvalidOperationException">When called more then once.</exception>
		public static void Initialize(ApplicationBase application)
		{
			if(null == application)
				throw new ArgumentNullException("application");
			if(!(_application is Uninitialized))
				throw new InvalidOperationException("Already initialized.");
			_application = application;
		}
Ejemplo n.º 2
0
 /// <summary>
 /// Initialize the application entry point.
 /// </summary>
 /// <param name="application">
 /// A <see cref="ApplicationBase"/> to handle request.
 /// </param>
 /// <exception cref="ArgumentNullException">When <paramref name="application"/> is <value>null</value>.</exception>
 /// <exception cref="InvalidOperationException">When called more then once.</exception>
 public static void Initialize(ApplicationBase application)
 {
     if (null == application)
     {
         throw new ArgumentNullException("application");
     }
     if (!(_application is Uninitialized))
     {
         throw new InvalidOperationException("Already initialized.");
     }
     _application = application;
 }
Ejemplo n.º 3
0
        public void Initialize_twice_throwsInvalidOperationException()
        {
            // arrange:
            string          appName         = "SampleApp";
            ApplicationBase appSingleton    = MockRepository.GeneratePartialMock <ApplicationBase>(appName);
            ApplicationBase secondSingleton = MockRepository.GeneratePartialMock <ApplicationBase>("test");

            // act:
            Application.Initialize(appSingleton);

            // assert:
            Assert.Throws <InvalidOperationException>(delegate { Application.Initialize(secondSingleton); });
            appSingleton.VerifyAllExpectations();
        }
Ejemplo n.º 4
0
        public void whenInitialized_forwardToApplicationSingleton()
        {
            // arrange:
            string          appName      = "SampleApp";
            EnvironmentBase environment  = MockRepository.GenerateStrictMock <EnvironmentBase>();
            IEnterprise     enterprise   = MockRepository.GenerateStrictMock <IEnterprise>();
            ApplicationBase appSingleton = MockRepository.GeneratePartialMock <ApplicationBase>(appName);

            appSingleton.Expect(a => a.Environment).Return(environment).Repeat.Once();
            appSingleton.Expect(a => a.Enterprise).Return(enterprise).Repeat.Once();

            // act:
            Application.Initialize(appSingleton);

            // assert:
            Assert.AreEqual(appName, Application.Name);
            Assert.AreSame(environment, Application.Environment);
            Assert.AreSame(enterprise, Application.Enterprise);
            appSingleton.VerifyAllExpectations();
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Reset the application entry point (for testing purpose).
 /// </summary>
 internal static void Reset()
 {
     _application = new Uninitialized();
 }
Ejemplo n.º 6
0
		/// <summary>
		/// Reset the application entry point (for testing purpose). 
		/// </summary>
		internal static void Reset()
		{
			_application = new Uninitialized();
		}