public void ShouldReturnNullForNotRunningApplications()
    {
      TestApplicationManager applicationManager = new TestApplicationManager();

      TestApplication result = applicationManager.GetRunningApplication(this.applicationHost);

      Assert.Null(result);
    }
    public void ShouldStopApplication()
    {
      TestApplicationManager applicationManager = new TestApplicationManager();
      TestApplication application = (TestApplication)ApplicationManager.GetApplicationManager().CreateObject(this.applicationHost.ApplicationId, typeof(TestApplication), this.applicationHost.VirtualPath, Path.GetFullPath(this.applicationHost.PhysicalPath), false, true);

      applicationManager.StopApplication(application);

      Assert.DoesNotContain(this.applicationHost.ApplicationId, ApplicationManager.GetApplicationManager().GetRunningApplications().Select(app => app.ID));
    }
    public void ShouldReturnApplicationInstanceForRunningApplications()
    {
      TestApplicationManager applicationManager = new TestApplicationManager();
      TestApplication application = (TestApplication)ApplicationManager.GetApplicationManager().CreateObject(this.applicationHost.ApplicationId, typeof(TestApplication), this.applicationHost.VirtualPath, Path.GetFullPath(this.applicationHost.PhysicalPath), false, true);
      
      TestApplication result = applicationManager.GetRunningApplication(this.applicationHost);

      Assert.Equal(application, result);
    }
    public void ShouldStartApplication()
    {
      TestApplicationManager applicationManager = new TestApplicationManager();

      TestApplication result = applicationManager.StartApplication(this.applicationHost);

      Assert.NotNull(result);
      Assert.True(RemotingServices.IsObjectOutOfAppDomain(result));
      Assert.True(RemotingServices.IsTransparentProxy(result));
      Assert.Contains(this.applicationHost.ApplicationId, ApplicationManager.GetApplicationManager().GetRunningApplications().Select(app => app.ID));
    }
    public void ShouldReturnAllRunningApplications()
    {
      ApplicationManager.GetApplicationManager().GetRunningApplications().Select(a => a.ID).ToList().ForEach(i => ApplicationManager.GetApplicationManager().ShutdownApplication(i));

      TestApplicationManager applicationManager = new TestApplicationManager();
      TestApplication application = (TestApplication)ApplicationManager.GetApplicationManager().CreateObject(this.applicationHost.ApplicationId, typeof(TestApplication), this.applicationHost.VirtualPath, Path.GetFullPath(this.applicationHost.PhysicalPath), false, true);

      TestApplication[] result = applicationManager.GetRunningApplications().ToArray();

      Assert.Equal(1, result.Length);
      Assert.Contains(application, result);
    }