Inheritance: MonoBehaviour
        /// <summary> Performs framework initialization once, before any Start() is called. </summary>
        void Awake()
        {
            AppManager = ApplicationManager.Instance;
            AppManager.InitializeFramework(GetConfigBuilder(), GetBootInitAction());

            SetStartGeoCoordinate();
        }
Example #2
0
	void Start()
	{
		// Caching
		userDatamanager = UserDataManager.ins;
		if (userDatamanager == null)
		{
			Debug.LogError("No UserDataManager?!");
		}
		applicationManager = ApplicationManager.ins;
		if (applicationManager == null)
		{
			Debug.LogError("No ApplicationManager?!");
		}
		courseManager = CourseManager.ins;
		if (courseManager == null)
		{
			Debug.LogError("No CourseManager?!");
		}
		modalPanel = ModalPanel.ins;
		if (modalPanel == null)
		{
			Debug.LogError("No ModalPanel?!");
		}
		courseCompletedOKEvent = new UnityAction(_CourseCompleted);
		courseViewCompletedOKEvent = new UnityAction(_CourseViewContinue);
		courseViewCompletedCancelEvent = new UnityAction(_CourseViewStay);

		audioManager = ASAudioManager.ins;
		if (audioManager == null)
		{
			Debug.LogError("No ASAudioManager?!");
		}
	}
Example #3
0
 public HomeControllerTest()
 {
     profileRepository = new EFProfileRepository();
     apartmentRepository = new EFApartmentsRepository();            
     applicationManager = new ApplicationManager(new UserStore<ApplicationUser>(new ApplicationDbContext()));
     
 }
        protected override async void OnAppearing()
        {
            if (applicationManager == null)
            {
                applicationManager = new ApplicationManager(DependencyService.Get<ITransportResource>(), DependencyService.Get<IDtoSerializer>(), DependencyService.Get<IStorage>(), DependencyService.Get<IDeviceInfo>());
                applicationManager.ConnectionManager.ConnectionDropped += () => Navigation.PushAsync(new SplashscreenPage());
            }

            AuthenticationResponseType autenticacao;
            try
            {
                autenticacao = await applicationManager.AccountManager.ValidateAccount();
            }
            catch (System.Exception)
            {
                await DisplayAlert("Aviso!", "Serviço não disponível no momento. Tente novamente mais tarde", "Ok", null);
                return;
            }

            //Se já está autenticado, abre tela principal, senão, envia para tela de login.
            if (autenticacao == AuthenticationResponseType.Success)
                await Navigation.PushAsync(new HomePage(new HomeViewModel(applicationManager)));
            else
                await Navigation.PushAsync(new LoginPage(new LoginViewModel(applicationManager)));

            base.OnAppearing();
        }
        private void Initialize()
        {
            // wait for loading..
            //gameObject.GetComponent<Rigidbody>().constraints = RigidbodyConstraints.FreezeAll;
            var thirdPersonControll = gameObject.GetComponent<ThirdPersonController>();
            _initialGravity = thirdPersonControll.gravity;
            thirdPersonControll.gravity = 0;

            _appManager = ApplicationManager.Instance;

            _messageBus = _appManager.GetService<IMessageBus>();

            _appManager.CreateConsole(true);

            _messageBus.AsObservable<GameRunner.GameStartedMessage>()
                .Where(msg => msg.Tile.RenderMode == RenderMode.Scene)
                .Take(1)
                .Delay(TimeSpan.FromSeconds(2)) // give extra seconds..
                .ObserveOnMainThread()
                .Subscribe(_ =>
                {
                    var position = transform.position;
                    var elevation = _appManager.GetService<IElevationProvider>()
                        .GetElevation(new MapPoint(position.x, position.z));
                    transform.position = new Vector3(position.x, elevation + 90, position.z);
                    thirdPersonControll.gravity = _initialGravity;
                });

            // ASM should be started from non-UI thread
               Observable.Start(() => _appManager.RunGame(), Scheduler.ThreadPool);
        }
Example #6
0
    void Start()
    {
        if (title == null)
        {
            Debug.LogError("No title object referenced");
        }
        if (desc == null)
        {
            Debug.LogError("No desc object referenced");
        }
        if (category == null)
        {
            Debug.LogError("No category object referenced");
        }
        if (difficulty == null)
        {
            Debug.LogError("No difficulty object referenced");
        }

        courseManager = CourseManager.ins;
        if (courseManager == null)
        {
            Debug.LogError("No courseManager?");
        }
        applicationManager = ApplicationManager.ins;
        if (applicationManager == null)
        {
            Debug.LogError("Panic... No applicaitonManager found.");
        }
    }
Example #7
0
	void Start()
	{
		applicationManager = ApplicationManager.ins;
		if (applicationManager == null)
		{
			Debug.LogError("No ApplicationManager found!");
		}
	}
Example #8
0
    void Awake()
    {
        if (_instance == null) _instance = this;
        else { DestroyImmediate(this); return; }

        DontDestroyOnLoad(gameObject);
        _firstScene = Application.loadedLevelName;
    }
        public RegistrationViewModel(ApplicationManager appManager)
        {
            _appManager = appManager;
            _countriesRepository = new CountriesRepository();

            SelectedCountry = Countries.First();
            SelectedSex = Sexes.First();
            SelectedAge = Ages.First();
        }
Example #10
0
 void Awake()
 {
     if (instance != null)
         Destroy(gameObject);
     else
     {
         DontDestroyOnLoad(this.gameObject);
         instance = this;
     }
 }
Example #11
0
        void Start()
        {
            CameraScene.enabled = true;
            _appManager = ApplicationManager.Instance;

            OverviewButton.gameObject.SetActive(true);
            SceneButton.gameObject.SetActive(false);

            OverviewButton.onClick.AsObservable().Subscribe(_ => SwitchSceneMode(true));
            SceneButton.onClick.AsObservable().Subscribe(_ => SwitchSceneMode(false));
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="FormService"/> class.
 /// </summary>
 public FormService()
 {
     this.applicationManager = Global.DependencyInjectionContainer.Resolve<ApplicationManager>();
     this.organisationManager = Global.DependencyInjectionContainer.Resolve<OrganisationManager>();
     this.securityGateway = Global.DependencyInjectionContainer.Resolve<ISecurityService>();
     if (Global.DependencyInjectionContainer.IsRegistered<IApplicationManagerEventHandler>())
     {
         Global.DependencyInjectionContainer.Resolve<IApplicationManagerEventHandler>()
             .Register(this.applicationManager);
     }
 }
        public void TestInitialize()
        {
            JsonConvert.DefaultSettings = () => new JsonSerializerSettings
            {
                Formatting = Formatting.None,
                Converters = new JsonConverter[] { new JsonKnownTypeConverter() }
            };

            var container = new UnityContainer().LoadConfiguration();
            container.RegisterInstance<ISymmetricCrypto>(new RijndaelSymmetricCrypto("password", "rgb init vector.", 8, 8, 256, "verysalty", 3));
            this.ApplicationManager = container.Resolve<ApplicationManager>();
        }
Example #14
0
 public ApplicationForm(
     ApplicationManager applicationManager,
     AppFormContainer mainForm,
     System.Windows.Forms.MenuStrip menuStrip
     )
 {
     m_appFormContainer = mainForm;
     m_applicationMainForm = new ApplicationMainForm(this, mainForm);
     string ext = applicationManager.APP_DATA.SETTINGS.getProjectFileExtension();
     m_projectMenuStrip = new ProjectMenuStrip(this, mainForm, menuStrip, ext);
     m_progressBar = new Forms.ProgressBarDialog();
     m_applicationManager = applicationManager;
 }
            public void EnsureDependencies()
            {
                EnsureConfigurationFilesAreAvailableDuringTest();

                AppManager = new ApplicationManager();
                AppInit    = new ApplicationInitializer();

                Dirs = DirHandler.Instance;
                Dirs.CurrentDirectory = Environment.CurrentDirectory;

                ProxisHome = ProxyHome.Instance;
                ProxisHome.StatisticsProxy = AppInit.InitializeStatisticsComponent(AppManager);
            }
Example #16
0
        static void Main(string[] args)
        {
            //-- An alternative method for catching unhandled exceptions (also rather flakey)..
            //AppDomain.CurrentDomain.UnhandledException += new System.UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
            //Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Control.CheckForIllegalCrossThreadCalls = true;
            Application.DoEvents();

            ApplicationManager applicationManager = new ApplicationManager();
            applicationManager.Run(args);
        }
 // GET: Default
 public async Task<ActionResult> Index()
 {
     if (User.Identity.IsAuthenticated)
     {
         using (ApplicationDBContext db = new ApplicationDBContext())
         {
             var UM = new ApplicationManager(new UserStore<ApplicationUser>(db));
             var user = await  UM.FindByNameAsync(User.Identity.Name);
             ViewBag.Age = user?.Year;
             ViewBag.Sex = user?.Sex;
         }
     }
     return View();
 }
Example #18
0
	void Awake()
	{
		if (_ins == null)
		{
			// Populate with first instance
			_ins = this;
			DontDestroyOnLoad(this);
		}
		else
		{
			// Another instance exists, destroy
			if (this != _ins)
				Destroy(this.gameObject);
		}
	}
        static void Main(string[] args)
        {
            var settings = new ApplicationManagerSettings
            {
                AppDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Versions"),
                ApplicationName = "DemoApp",
                CompanyName = "Griffin",
                PickupPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Pickup")
            };
            var appManager = new ApplicationManager<MyApplicationInit>(settings);
            appManager.Start();


            Console.ReadLine();
            appManager.Stop();
        }
        public AppSettingsProvider(string keySet)
        {
            if (string.IsNullOrEmpty(keySet))
                throw new ArgumentException("Missing KeySet", "keySet");

            this.keySet = keySet;

            appSettingsMan = new AppSettingsManager2();

            appCache = new ApplicationManager<string>(APPCACHE_PREFIX + this.KeySet);

            fakeModule = new PigeonCms.Module();
            fakeModule.UseLog = Utility.TristateBool.True;
            fakeModule.ModuleNamespace = "PigeonCms.Core";
            fakeModule.ModuleName = "AppSettingsProvider";
        }
        public void Initialize_with_command_arg_should_return_null()
        {
            /* Arrange */
            var mocks = new TestAssistant().MockAll();
            var mgr = new ApplicationManager(mocks.ActionsManager);

            A.CallTo(() => mocks.ActionsManager.ExecuteCommandLine(A<string[]>.Ignored)).Returns(true);

            /* Act */
            var a = mgr.Initialize(mocks.Container, new string[] { "MustHaveAtleastOneArg" });

            /* Assert */
            a.Should().BeNull();

            A.CallTo(() => mocks.ActionsManager.BuildActions(A<IEnumerable<IProvideActions>>.Ignored)).MustNotHaveHappened();
            A.CallTo(() => mocks.ActionsManager.ExecuteCommandLine(A<string[]>.Ignored)).MustHaveHappened(Repeated.Exactly.Once);
        }
Example #22
0
	void Start()
	{
		achievementManager = AchievementManager.ins;
		if (achievementManager == null)
		{
			Debug.LogError("No AchievementManager found!");
		}
		applicationManager = ApplicationManager.ins;
		if (applicationManager == null)
		{
			Debug.LogError("No ApplicationManager found!");
		}

		if (Application.loadedLevelName == "CourseView")
		{
			SetupCourseView();
		}
		
	}
        public void Initialize_with_file_arg_should_go_to_request_display_of_config()
        {
            /* Arrange */
            var mocks = new TestAssistant().MockAll();
            var mgr = new ApplicationManager(mocks.ActionsManager);
            ConfigRequest msg = null;

            A.CallTo(() => mocks.Messenger.Publish(A<object>.Ignored)).Invokes(c => msg = c.Arguments[0] as ConfigRequest);

            /* Act */
            var a = mgr.Initialize(mocks.Container, new string[] { "SomeFileName" });

            a();

            /* Assert */
            msg.Should().NotBeNull();
            msg.RequestedAction.Should().Be(ConfigRequest.Action.Open);
            msg.Source.Provider.As<FileConfigProvider>().ConfigFileName.Should().Be("SomeFileName");

            A.CallTo(() => mocks.ActionsManager.BuildActions(A<IEnumerable<IProvideActions>>.Ignored)).MustHaveHappened(Repeated.Exactly.Once);
            A.CallTo(() => mocks.ActionsManager.ExecuteCommandLine(A<string[]>.Ignored)).MustHaveHappened(Repeated.Exactly.Once);
        }
 public async Task<ActionResult> Details([Bind(Include = "Text")]Reply reply, int? id)
 {
     var url = Request.UrlReferrer.AbsolutePath;
     reply.Date = DateTime.Now;
     if (id == null)
     {
         return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
     }
     Message message = db.Messages.Find(id);
     if (message == null)
     {
         return HttpNotFound();
     }
     if (ModelState.IsValid)
     {
         reply.Message = message;
         var UM = new ApplicationManager(new UserStore<ApplicationUser>(db));
         if (User.Identity.IsAuthenticated) reply.Avtor = await UM.FindByNameAsync(User.Identity.Name);
         db.Replys.Add(reply);
         db.SaveChanges();
     }
     return View(reply.Message);
 }
        public void Initialize_with_an_existing_plugin_should_find_it_and_load_it()
        {
            /* Arrange */
            var mocks = new TestAssistant().MockAll();
            var mgr = new ApplicationManager(mocks.ActionsManager);

            PluginConfig.Instance.PluginFolder = "Addins";

            /* Act */
            var preInit = mocks.Container.TryGet<IProvideConfigSource>();

            mgr.Initialize(mocks.Container, new string[0]);

            var postInit = mocks.Container.TryGet<IProvideConfigSource>();

            /* Assert */
            AssemblySource.Instance.Should().ContainSingle(asm => asm.GetAssemblyName() == "SampleEditorPlugin");
            A.CallTo(mocks.Logger).MustNotHaveHappened();

            //Faking the IKernel doesn't work so instead we check the actual container
            preInit.Should().BeNull();
            postInit.Should().NotBeNull();
        }
Example #26
0
    void Awake()
    {
        m_Instance = this;

        DontDestroyOnLoad (gameObject);

        //We don't want to destroy manager ever, but if we have to, keep this list for later
        List<ManagerInitializer> listScriptManager = new List<ManagerInitializer>();

        foreach (GameObject manager in m_ListManager) {
            ManagerInitializer managerScript = CreateNewManager(manager);
            if(managerScript != null)
            {
                listScriptManager.Add(managerScript);
            }
        }

        foreach (ManagerInitializer managerScript in listScriptManager) {
            managerScript.PostInit();
        }

        m_IsInitialized = true;
        OnManagersInitialized ();
    }
Example #27
0
        static void Main(string[] args)
        {
            var appManager = new ApplicationManager();

            var suffixes = ApplicationManager.TopLevelDomainSuffixes;

            var suffixWords = new List<WordsEndingIn>();

            foreach (var suffix in suffixes)
            {
                var words = appManager.GetWordsThatEndWith(new string[] {suffix});

                var output = new StringBuilder(string.Format("\"{0}\", ", suffix));
                words.ForEach(s => output.AppendFormat("\"{0}\", ", s.Replace("\"", "\"\"")));

                suffixWords.Add(new WordsEndingIn
                                        {
                                            WordsEndIn = suffix,
                                            Words = words
                                        });

                System.Console.WriteLine(output.ToString(0, output.Length - 2));
            }
        }
Example #28
0
 public bool RestarServer()
 {
     ApplicationManager.Load().Restart();
     return(true);
 }
Example #29
0
        [InlineData("https://api.nuget.org/v3/index.json", "bootstrap")] // v3 endpoint
        public async Task SiteExtensionInstallUninstallAsyncTest(string feedEndpoint, string testPackageId)
        {
            TestTracer.Trace("Testing against feed: '{0}'", feedEndpoint);

            const string appName = "SiteExtensionInstallUninstallAsyncTest";

            await ApplicationManager.RunAsync(appName, async appManager =>
            {
                var manager = appManager.SiteExtensionManager;
                await CleanSiteExtensions(manager);

                // Get the latest package, make sure that call will return right away when we try to update
                TestTracer.Trace("Get latest package '{0}' from '{1}'", testPackageId, feedEndpoint);
                SiteExtensionInfo latestPackage = await(await manager.GetRemoteExtension(testPackageId, feedUrl: feedEndpoint)).Content.ReadAsAsync <SiteExtensionInfo>();
                Assert.Equal(testPackageId, latestPackage.Id);

                // install from non-default endpoint
                UpdateHeaderIfGoingToBeArmRequest(manager.Client, true);
                TestTracer.Trace("Install package '{0}'-'{1}' fresh from '{2}' async", testPackageId, latestPackage.Version, feedEndpoint);
                HttpResponseMessage responseMessage    = await manager.InstallExtension(id: testPackageId, version: latestPackage.Version, feedUrl: feedEndpoint);
                ArmEntry <SiteExtensionInfo> armResult = await responseMessage.Content.ReadAsAsync <ArmEntry <SiteExtensionInfo> >();
                Assert.Equal(string.Empty, armResult.Location);   // test "x-ms-geo-location" header is empty, same value should be assign to "Location"
                Assert.Equal(HttpStatusCode.Created, responseMessage.StatusCode);
                Assert.True(responseMessage.Headers.Contains(Constants.RequestIdHeader));

                TestTracer.Trace("Poll for status. Expecting 200 response eventually with site operation header.");
                responseMessage = await PollAndVerifyAfterArmInstallation(manager, testPackageId);
                armResult       = await responseMessage.Content.ReadAsAsync <ArmEntry <SiteExtensionInfo> >();
                // after successfully installed, should return SiteOperationHeader to notify GEO to restart website
                Assert.True(responseMessage.Headers.Contains(Constants.SiteOperationHeaderKey));
                Assert.Equal(feedEndpoint, armResult.Properties.FeedUrl);
                Assert.Equal(latestPackage.Version, armResult.Properties.Version);
                Assert.Equal(HttpStatusCode.OK, responseMessage.StatusCode);
                Assert.True(responseMessage.Headers.Contains(Constants.RequestIdHeader));

                TestTracer.Trace("Get '{0}' again. Expecting 200 response without site operation header", testPackageId);
                responseMessage = await manager.GetLocalExtension(testPackageId);
                armResult       = await responseMessage.Content.ReadAsAsync <ArmEntry <SiteExtensionInfo> >();
                // get again shouldn`t see SiteOperationHeader anymore
                Assert.False(responseMessage.Headers.Contains(Constants.SiteOperationHeaderKey));
                Assert.Equal(feedEndpoint, armResult.Properties.FeedUrl);
                Assert.Equal(latestPackage.Version, armResult.Properties.Version);
                Assert.Equal(HttpStatusCode.OK, responseMessage.StatusCode);
                Assert.True(responseMessage.Headers.Contains(Constants.RequestIdHeader));

                TestTracer.Trace("Try to update package '{0}' without given a feed", testPackageId);
                // Not passing feed endpoint will default to feed endpoint from installed package
                // Update should return right away, expecting code to look up from feed that store in local package
                // since we had installed the latest package, there is nothing to update.
                // We shouldn`t see any site operation header value
                // And there is no polling, since it finsihed within 15 seconds
                responseMessage = await manager.InstallExtension(testPackageId);
                armResult       = await responseMessage.Content.ReadAsAsync <ArmEntry <SiteExtensionInfo> >();
                Assert.Equal(string.Empty, armResult.Location);   // test "x-ms-geo-location" header is empty, same value should be assign to "Location"
                Assert.Equal(latestPackage.Id, armResult.Properties.Id);
                Assert.Equal(feedEndpoint, armResult.Properties.FeedUrl);
                Assert.Equal(HttpStatusCode.OK, responseMessage.StatusCode);
                Assert.True(responseMessage.Headers.Contains(Constants.RequestIdHeader));
                // no installation operation happened, shouldn`t see SiteOperationHeader return
                Assert.False(responseMessage.Headers.Contains(Constants.SiteOperationHeaderKey));

                TestTracer.Trace("Uninstall '{0}' async", testPackageId);
                responseMessage = await manager.UninstallExtension(testPackageId);
                armResult       = await responseMessage.Content.ReadAsAsync <ArmEntry <SiteExtensionInfo> >();
                Assert.Null(armResult);
                Assert.Equal(HttpStatusCode.OK, responseMessage.StatusCode);
                Assert.True(responseMessage.Headers.Contains(Constants.RequestIdHeader));

                TestTracer.Trace("Get '{0}' again. Expecting 404.", testPackageId);
                var ex = await KuduAssert.ThrowsUnwrappedAsync <HttpUnsuccessfulRequestException>(async() =>
                {
                    await manager.GetLocalExtension(testPackageId);
                });
                Assert.Equal(HttpStatusCode.NotFound, ex.ResponseMessage.StatusCode);
            });
        }
Example #30
0
        private void Save()
        {
            string message = "";

            try
            {
                var deviceController = this.ToCoreModel();

                var validator = NinjectBinder.GetValidator <DeviceValidator>();
                var results   = validator.Validate(deviceController);
                if (!results.IsValid)
                {
                    message = string.Join("\n", results.Errors);
                    SendMessage(message);
                    return;
                }

                var doorCodes           = deviceController.DeviceDoors.Select(x => x.Code);
                var duplicatedDoorCodes = doorCodes.GroupBy(x => x).Where(grp => grp.Count() > 1).Select(grp => grp.Key);
                if (duplicatedDoorCodes.Any())
                {
                    message += string.Format("设备中存在重复的门编号:{0}\n", string.Join(",", duplicatedDoorCodes));
                }

                var readingCodes           = deviceController.DeviceHeadReadings.Select(x => x.Code);
                var duplicatedReadingCodes = readingCodes.GroupBy(x => x).Where(grp => grp.Count() > 1).Select(grp => grp.Key);
                if (duplicatedReadingCodes.Any())
                {
                    message += string.Format("设备中存在重复的读头编号:{0}\n", string.Join(",", duplicatedReadingCodes));
                }

                if (!string.IsNullOrWhiteSpace(message))
                {
                    SendMessage(message);
                    return;
                }

                if (Id == 0)
                {
                    deviceController.Status       = GeneralStatus.Enabled;
                    deviceController.CreateUserID = ApplicationManager.GetInstance().CurrentOperatorInfo.OperatorID;
                    deviceController.CreateDate   = DateTime.Now;

                    deviceController = _deviceControllerRepo.Insert(deviceController);
                    Id = deviceController.DeviceID;
                    var newViewModel = deviceController.ToViewModel();
                    DeviceExtensionViewModel = newViewModel.DeviceExtensionViewModel;
                    DoorViewModels           = newViewModel.DoorViewModels;
                    HeadReadingViewModels    = newViewModel.HeadReadingViewModels;
                    Status       = newViewModel.Status;
                    CreateUserID = newViewModel.CreateUserID;
                    CreateDate   = newViewModel.CreateDate;

                    message = "增加设备成功!";
                }
                else
                {
                    deviceController.UpdateUserID = ApplicationManager.GetInstance().CurrentOperatorInfo.OperatorID;
                    deviceController.UpdateDate   = DateTime.Now;

                    _deviceControllerRepo.Update(deviceController);
                    var cacheableRepo = _deviceControllerRepo as CacheableRepository <DeviceController, int>;
                    deviceController = cacheableRepo.Refresh(deviceController.DeviceID);

                    //deviceController = _deviceControllerRepo.GetByKey();

                    message = "修改设备成功!";
                }

                ViewModelAttachment.CoreModel            = deviceController;
                ViewModelAttachment.LastOperationSuccess = true;
            }
            catch (BusinessException ex)
            {
                Log.Error("Update device fails.", ex);
                SendMessage(ex.Message);
                return;
            }
            catch (Exception ex)
            {
                Log.Error("Update device fails.", ex);
                message = "保存设备失败";
                SendMessage(message);
                return;
            }

            RaisePropertyChanged(null);
            Close(message);
        }
Example #31
0
        private void ActivatePlugin()
        {
            ModuleProxy.GetInstance().Module = this;

            _applicationManager = ApplicationManager.GetInstance();
            _applicationStorage = ApplicationStorage.GetInstance();

            _applicationManager.RegisterOptionsPageFactory(
                delegate { return(new BuildToolOptionsPage()); });

            if (!_applicationManager.ClientProfile.HaveFlag(
                    ClientFlags.BuildToolsDisableBuildSettingsPage))
            {
                _applicationManager.RegisterOptionsPageFactory(
                    delegate { return(new BuildSettingsOptionsPage()); });
            }

            _applicationManager.DocumentFilterHandlers.Add(
                GetSourceFilesFilter);

            #region UI Elements

            bool disableCompilerUI = _applicationManager.ClientProfile.
                                     HaveFlag(ClientFlags.BuildToolsDisableCompilerUI);

            _output = _applicationManager.GetDockedForm(
                QuickSharp.Output.Constants.DOCKED_FORM_KEY)
                      as OutputForm;

            /* Menu items */

            _toolsMenuCompile = MenuTools.CreateMenuItem(
                Constants.UI_TOOLS_MENU_COMPILE,
                Resources.MainToolsMenuCompile,
                Resources.Compile,
                Keys.Shift | Keys.F5, null, UI_TOOLS_MENU_COMPILE_Click);

            _toolsMenuCompileAll = MenuTools.CreateMenuItem(
                Constants.UI_TOOLS_MENU_COMPILE_ALL,
                Resources.MainToolsMenuCompileAll,
                null,
                Keys.F6, null, UI_TOOLS_MENU_COMPILE_ALL_Click,
                true);

            _toolsMenuRun = MenuTools.CreateMenuItem(
                Constants.UI_TOOLS_MENU_RUN,
                Resources.MainToolsMenuRun,
                Resources.Run,
                Keys.Control | Keys.F5, null, UI_TOOLS_MENU_RUN_Click);

            if (disableCompilerUI)
            {
                _toolsMenuRun.Tag = new ToolStripItemTag {
                    IncludeSeparator = true
                }
            }
            ;

            ToolStripMenuItem toolsMenu = _mainForm.GetMenuItemByName(
                QuickSharp.Core.Constants.UI_TOOLS_MENU);

            if (!disableCompilerUI)
            {
                toolsMenu.DropDownItems.Insert(0, _toolsMenuCompileAll);
                toolsMenu.DropDownItems.Insert(0, _toolsMenuCompile);
            }

            toolsMenu.DropDownItems.Insert(0, _toolsMenuRun);
            toolsMenu.DropDownOpening +=
                new EventHandler(ToolsMenu_DropDownOpening);

            /* Toolbar */

            _toolbarCompile = MenuTools.CreateToolbarButton(
                Constants.UI_TOOLBAR_COMPILE,
                Resources.ToolbarCompile,
                Resources.Compile, UI_TOOLBAR_COMPILE_Click,
                true);
            _toolbarCompile.Enabled = false;
            _toolbarCompileSelect   = MenuTools.CreateToolbarDropDownButton(
                Constants.UI_TOOLBAR_COMPILE_SELECT,
                UI_TOOLBAR_COMPILE_SELECT_Click);
            _toolbarCompileSelect.Enabled          = false;
            _toolbarCompileSelect.DropDownOpening +=
                new EventHandler(ToolbarCompileSelect_DropDownOpening);

            _toolbarRun = MenuTools.CreateToolbarButton(
                Constants.UI_TOOLBAR_RUN,
                Resources.ToolbarRun,
                Resources.Run, UI_TOOLBAR_RUN_Click);

            if (disableCompilerUI)
            {
                _toolbarRun.Tag = new ToolStripItemTag {
                    IncludeSeparator = true
                }
            }
            ;

            _toolbarRun.Enabled = false;
            _toolbarRunSelect   = MenuTools.CreateToolbarDropDownButton(
                Constants.UI_TOOLBAR_RUN_SELECT,
                UI_TOOLBAR_RUN_SELECT_Click);
            _toolbarRunSelect.Enabled          = false;
            _toolbarRunSelect.DropDownOpening +=
                new EventHandler(ToolbarRunSelect_DropDownOpening);

            _toolbarPin = MenuTools.CreateToolbarButton(
                Constants.UI_TOOLBAR_PIN,
                Resources.ToolbarPinFile,
                Resources.Pin, UI_TOOLBAR_PIN_Click,
                true);
            _toolbarPin.Enabled = false;
            _toolbarPinSelect   = MenuTools.CreateToolbarDropDownButton(
                Constants.UI_TOOLBAR_PIN_SELECT,
                UI_TOOLBAR_PIN_SELECT_Click);
            _toolbarPinSelect.Enabled = false;

            if (!disableCompilerUI)
            {
                _mainForm.MainToolbar.Items.Add(_toolbarCompile);
                _mainForm.MainToolbar.Items.Add(_toolbarCompileSelect);
            }

            _mainForm.MainToolbar.Items.Add(_toolbarRun);
            _mainForm.MainToolbar.Items.Add(_toolbarRunSelect);
            _mainForm.MainToolbar.Items.Add(_toolbarPin);
            _mainForm.MainToolbar.Items.Add(_toolbarPinSelect);

            #endregion

            _mainForm.ClientWindow.ActiveDocumentChanged +=
                new EventHandler(MainForm_ActiveDocumentChanged);

            _buildToolManager = BuildToolManager.GetInstance();
            _buildToolManager.LoadSettings();
            _buildToolManager.LoadTools();
            _buildToolManager.BuildTools.SortTools();
            _buildToolManager.LoadPinnedFiles();

            _mainForm.FormClosed +=
                new FormClosedEventHandler(MainForm_FormClosed);

            _applicationManager.FileSystemChange +=
                new MessageHandler(UpdatePinFileStatus);

            PluginManager.GetInstance().PluginPostActivate +=
                new MessageHandler(PostActivationHandler);
        }
Example #32
0
 public void SetupApp()
 {
     app = ApplicationManager.GetInstance();
 }
Example #33
0
 public DbHelper(ApplicationManager manager, string connectionString)
 {
     applicationManager = manager;
     ConnectionString   = connectionString;
 }
Example #34
0
        public async Task ProcessApiTests()
        {
            string appName = "ProcessApiTests";

            await ApplicationManager.RunAsync(appName, async appManager =>
            {
                // Test current process
                var process        = await appManager.ProcessManager.GetCurrentProcessAsync();
                int currentId      = process.Id;
                DateTime startTime = process.StartTime;
                Assert.NotNull(process);
                Assert.Contains("w3wp", process.Name);
                Assert.Contains("/diagnostics/processes/" + currentId, process.Href.AbsoluteUri);

                // Test get process by id
                process = await appManager.ProcessManager.GetProcessAsync(currentId);
                Assert.NotNull(process);
                Assert.Contains("w3wp", process.Name);
                Assert.Contains("/diagnostics/processes/" + currentId, process.Href.AbsoluteUri);

                // Test get not running process id
                var notfound = await KuduAssert.ThrowsUnwrappedAsync <HttpUnsuccessfulRequestException>(() => appManager.ProcessManager.GetProcessAsync(99999));
                Assert.Equal(HttpStatusCode.NotFound, notfound.ResponseMessage.StatusCode);
                Assert.Contains("is not running", notfound.ResponseMessage.ExceptionMessage);

                // Test process list
                var processes = await appManager.ProcessManager.GetProcessesAsync();
                Assert.True(processes.Count() >= 1);
                Assert.True(processes.Any(p => p.Id == currentId));

                // Test process dumps
                foreach (var format in new[] { "raw", "zip", "diagsession" })
                {
                    if (format != "diagsession")
                    {
                        TestTracer.Trace("Test minidump format={0}", format);
                        using (var stream = new MemoryStream())
                        {
                            using (var minidump = await appManager.ProcessManager.MiniDump(format: format))
                            {
                                Assert.NotNull(minidump);
                                await minidump.CopyToAsync(stream);
                            }
                            TestTracer.Trace("Test minidump lenth={0}", stream.Length);
                            Assert.True(stream.Length > 0);
                        }
                    }

                    if (ProcessExtensions.SupportGCDump)
                    {
                        TestTracer.Trace("Test gcdump format={0}", format);
                        using (var stream = new MemoryStream())
                        {
                            using (var gcdump = await appManager.ProcessManager.GCDump(format: format))
                            {
                                Assert.NotNull(gcdump);
                                await gcdump.CopyToAsync(stream);
                            }
                            TestTracer.Trace("Test gcdump lenth={0}", stream.Length);
                            Assert.True(stream.Length > 0);
                        }
                    }
                }

                //Test Handles
                process = await appManager.ProcessManager.GetCurrentProcessAsync();
                Assert.NotNull(process);
                Assert.True(
                    process.OpenFileHandles.Any(
                        h => h.IndexOf("kudu.core.dll", StringComparison.InvariantCultureIgnoreCase) != -1));

                //Test Modules
                process = await appManager.ProcessManager.GetCurrentProcessAsync();
                Assert.NotNull(process);
                Assert.True(
                    process.Modules.Any(h => h.FileName.Equals("ntdll.dll", StringComparison.InvariantCultureIgnoreCase)));

                // Test kill process
                await KuduAssert.ThrowsUnwrappedAsync <HttpRequestException>(() => appManager.ProcessManager.KillProcessAsync(currentId));
                HttpUtils.WaitForSite(appManager.SiteUrl, delayBeforeRetry: 10000);
                process = await appManager.ProcessManager.GetCurrentProcessAsync();
                Assert.NotEqual(startTime, process.StartTime);
            });
        }
Example #35
0
 public Action(ApplicationManager A)
 {
     AP = A;
 }
Example #36
0
 private void Initialize(InputManager inputManager, ApplicationManager applicationManager)
 {
     _inputManager       = inputManager;
     _applicationManager = applicationManager;
 }
Example #37
0
 public RdevHelper(ApplicationManager manager, string baseURL)
     : base(manager)
 {
     this.baseURL = baseURL;
 }
Example #38
0
 public ApplicationManagerUT()
 {
     am = new ApplicationManager();
 }
Example #39
0
 public void InitApplicationManager()
 {
     //ApplicationManager app = ApplicationManager.GetInstance();
     ApplicationManager.GetInstance().Auth.Login(new AccountData("admin", "secret"));
 }
Example #40
0
        private static void VerifyDeployedArtifact(ApplicationManager appManager, string originalFileContent, string filePath)
        {
            var observerdFileContent = appManager.VfsManager.ReadAllText(filePath);

            Assert.Equal(originalFileContent, observerdFileContent);
        }
Example #41
0
        public Task TestInvalidPaths()
        {
            return(ApplicationManager.RunAsync("TestInvalidPaths", async appManager =>
            {
                var files = DeploymentTestHelper.CreateRandomFilesForZip(10);

                //
                // NOTE: For each type, run a successful scenario to validate that all is good and then
                // begin with the tests for invalid paths where we expect the test to fail
                //

                // Legacy war - relative paths
                {
                    await DeployZippedArtifact(appManager, appManager.OneDeployManager, files, "war", "webapps/ROOT", isAsync: false, isClean: false, expectedSuccess: true);
                    await DeployZippedArtifact(appManager, appManager.OneDeployManager, files, "war", "webapps/ROOT/", isAsync: false, isClean: false, expectedSuccess: false);
                    await DeployZippedArtifact(appManager, appManager.OneDeployManager, files, "war", "invalid", isAsync: false, isClean: false, expectedSuccess: false);
                    await DeployZippedArtifact(appManager, appManager.OneDeployManager, files, "war", "webapps/app/foo", isAsync: false, isClean: false, expectedSuccess: false);
                    await DeployZippedArtifact(appManager, appManager.OneDeployManager, files, "war", "webapps2/app", isAsync: false, isClean: false, expectedSuccess: false);
                    await DeployZippedArtifact(appManager, appManager.OneDeployManager, files, "war", "webapps", isAsync: false, isClean: false, expectedSuccess: false);
                }

                // Legacy war - absolute paths
                {
                    await DeployZippedArtifact(appManager, appManager.OneDeployManager, files, "war", "/home/site/wwwroot/webapps/app", isAsync: false, isClean: false, expectedSuccess: true);
                    await DeployZippedArtifact(appManager, appManager.OneDeployManager, files, "war", "/home/site/wwwroot/webapps/app/", isAsync: false, isClean: false, expectedSuccess: false);
                    await DeployZippedArtifact(appManager, appManager.OneDeployManager, files, "war", "/home/site/wwwroot/webapps/app/foo", isAsync: false, isClean: false, expectedSuccess: false);
                    await DeployZippedArtifact(appManager, appManager.OneDeployManager, files, "war", "/home/site/wwwroot/webapps/", isAsync: false, isClean: false, expectedSuccess: false);
                    await DeployZippedArtifact(appManager, appManager.OneDeployManager, files, "war", "/home/site/wwwroot/webapps", isAsync: false, isClean: false, expectedSuccess: false);
                    await DeployZippedArtifact(appManager, appManager.OneDeployManager, files, "war", "/home/site/wwwroot/webapps2/app", isAsync: false, isClean: false, expectedSuccess: false);
                    await DeployZippedArtifact(appManager, appManager.OneDeployManager, files, "war", "/home/site/wwwroot/", isAsync: false, isClean: false, expectedSuccess: false);
                }

                // lib - absolute paths
                {
                    await DeployZippedArtifact(appManager, appManager.OneDeployManager, files, "lib", "/home/site/libs/file.jar", isAsync: false, isClean: false, expectedSuccess: true);
                    await DeployZippedArtifact(appManager, appManager.OneDeployManager, files, "lib", "/home/site/libs/file.jar/", isAsync: false, isClean: false, expectedSuccess: false);
                    await DeployZippedArtifact(appManager, appManager.OneDeployManager, files, "lib", "/home/site/libs/", isAsync: false, isClean: false, expectedSuccess: false);
                    await DeployZippedArtifact(appManager, appManager.OneDeployManager, files, "lib", "/home/site/libs", isAsync: false, isClean: false, expectedSuccess: false);
                    await DeployZippedArtifact(appManager, appManager.OneDeployManager, files, "lib", "/home/site/libsfile.jar", isAsync: false, isClean: false, expectedSuccess: false);
                    await DeployZippedArtifact(appManager, appManager.OneDeployManager, files, "lib", "/home/site/lib2/file.jar", isAsync: false, isClean: false, expectedSuccess: false);
                }

                // script - absolute paths
                {
                    await DeployZippedArtifact(appManager, appManager.OneDeployManager, files, "script", "/home/site/scripts/file.bat", isAsync: false, isClean: false, expectedSuccess: true);
                    await DeployZippedArtifact(appManager, appManager.OneDeployManager, files, "script", "/home/site/scripts/file.bat/", isAsync: false, isClean: false, expectedSuccess: false);
                    await DeployZippedArtifact(appManager, appManager.OneDeployManager, files, "script", "/home/site/scripts/", isAsync: false, isClean: false, expectedSuccess: false);
                    await DeployZippedArtifact(appManager, appManager.OneDeployManager, files, "script", "/home/site/scripts", isAsync: false, isClean: false, expectedSuccess: false);
                    await DeployZippedArtifact(appManager, appManager.OneDeployManager, files, "script", "/home/site/scriptsfile.bat", isAsync: false, isClean: false, expectedSuccess: false);
                    await DeployZippedArtifact(appManager, appManager.OneDeployManager, files, "script", "/home/site/scripts2/file.bat", isAsync: false, isClean: false, expectedSuccess: false);
                }

                // Static - absolute paths
                {
                    await DeployZippedArtifact(appManager, appManager.OneDeployManager, files, "static", "/home/site/wwwroot/file.bat", isAsync: false, isClean: false, expectedSuccess: true);
                    await DeployZippedArtifact(appManager, appManager.OneDeployManager, files, "static", "/home/site/wwwroot/file.bat/", isAsync: false, isClean: false, expectedSuccess: false);
                    await DeployZippedArtifact(appManager, appManager.OneDeployManager, files, "static", "/home/site/wwwroot/", isAsync: false, isClean: false, expectedSuccess: false);
                    await DeployZippedArtifact(appManager, appManager.OneDeployManager, files, "static", "/home/site/wwwroot", isAsync: false, isClean: false, expectedSuccess: false);
                    await DeployZippedArtifact(appManager, appManager.OneDeployManager, files, "static", "/home/site/wwwrootfile.bat", isAsync: false, isClean: false, expectedSuccess: false);
                    await DeployZippedArtifact(appManager, appManager.OneDeployManager, files, "static", "/home/site/wwwroot2/file.bat", isAsync: false, isClean: false, expectedSuccess: false);
                }
            }));
        }
 public MainWindow()
 {
     applicationManager = new ApplicationManager();
     character          = new Character();
     InitializeComponent();
 }
Example #43
0
        public async Task SiteExtensionBasicTests()
        {
            const string appName = "SiteExtensionBasicTests";

            await ApplicationManager.RunAsync(appName, async appManager =>
            {
                var manager = appManager.SiteExtensionManager;
                await CleanSiteExtensions(manager);

                // list
                List <SiteExtensionInfo> results = await(await manager.GetRemoteExtensions()).Content.ReadAsAsync <List <SiteExtensionInfo> >();
                Assert.True(results.Any(), "GetRemoteExtensions expects results > 0");

                // pick site extension
                var expectedId = _galleryInstalledExtensions.Keys.ToArray()[new Random().Next(_galleryInstalledExtensions.Count)];
                var expected   = results.Find(ext => String.Equals(ext.Id, expectedId, StringComparison.OrdinalIgnoreCase));
                TestTracer.Trace("Testing Against Site Extension '{0}' - '{1}'", expectedId, expected.Version);

                // get
                TestTracer.Trace("Perform GetRemoteExtension with id '{0}' only", expectedId);
                HttpResponseMessage responseMessage = await manager.GetRemoteExtension(expectedId);
                SiteExtensionInfo result            = await responseMessage.Content.ReadAsAsync <SiteExtensionInfo>();
                Assert.Equal(expected.Id, result.Id);
                Assert.True(responseMessage.Headers.Contains(Constants.RequestIdHeader));

                // clear local extensions
                TestTracer.Trace("Clear all installed extensions.");
                results = await(await manager.GetLocalExtensions()).Content.ReadAsAsync <List <SiteExtensionInfo> >();
                HttpResponseMessage deleteResponseMessage = null;
                foreach (var ext in results)
                {
                    deleteResponseMessage = await manager.UninstallExtension(ext.Id);
                    Assert.True(await deleteResponseMessage.Content.ReadAsAsync <bool>(), "Delete must return true");
                    Assert.True(deleteResponseMessage.Headers.Contains(Constants.RequestIdHeader));
                }

                // install/update
                TestTracer.Trace("Perform InstallExtension with id '{0}' only", expectedId);
                responseMessage = await manager.InstallExtension(expected.Id);
                result          = await responseMessage.Content.ReadAsAsync <SiteExtensionInfo>();
                Assert.Equal(expected.Id, result.Id);
                Assert.Equal(expected.Version, result.Version);
                Assert.True(responseMessage.Headers.Contains(Constants.RequestIdHeader));

                // list
                TestTracer.Trace("Perform GetLocalExtensions with no parameter");
                results = await(await manager.GetLocalExtensions()).Content.ReadAsAsync <List <SiteExtensionInfo> >();
                Assert.True(results.Any(), "GetLocalExtensions expects results > 0");

                // get
                TestTracer.Trace("Perform GetLocalExtension with id '{0}' only.", expectedId);
                responseMessage = await manager.GetLocalExtension(expected.Id);
                result          = await responseMessage.Content.ReadAsAsync <SiteExtensionInfo>();
                Assert.Equal(expected.Id, result.Id);
                Assert.True(responseMessage.Headers.Contains(Constants.RequestIdHeader));

                // delete
                TestTracer.Trace("Perform UninstallExtension with id '{0}' only.", expectedId);
                responseMessage   = await manager.UninstallExtension(expected.Id);
                bool deleteResult = await responseMessage.Content.ReadAsAsync <bool>();
                Assert.True(deleteResult, "Delete must return true");
                Assert.True(responseMessage.Headers.Contains(Constants.RequestIdHeader));

                // list installed
                TestTracer.Trace("Verify only '{0}' is installed", expectedId);
                results = await(await manager.GetLocalExtensions()).Content.ReadAsAsync <List <SiteExtensionInfo> >();
                Assert.False(results.Exists(ext => ext.Id == expected.Id), "After deletion extension " + expected.Id + " should not exist.");

                // install from non-default endpoint
                responseMessage = await manager.InstallExtension("bootstrap", version: "3.0.0", feedUrl: "https://www.nuget.org/api/v2/");
                result          = await responseMessage.Content.ReadAsAsync <SiteExtensionInfo>();
                Assert.Equal("bootstrap", result.Id);
                Assert.Equal("3.0.0", result.Version);
                Assert.Equal("https://www.nuget.org/api/v2/", result.FeedUrl);
                Assert.True(responseMessage.Headers.Contains(Constants.RequestIdHeader));

                // update site extension installed from non-default endpoint
                responseMessage = await manager.InstallExtension("bootstrap");
                result          = await responseMessage.Content.ReadAsAsync <SiteExtensionInfo>();
                Assert.Equal("bootstrap", result.Id);
                Assert.Equal("https://www.nuget.org/api/v2/", result.FeedUrl);
                Assert.True(responseMessage.Headers.Contains(Constants.RequestIdHeader));
            });
        }
Example #44
0
        public async Task SiteExtensionShouldNotSeeButAbleToInstallUnlistedPackage()
        {
            const string appName             = "SiteExtensionShouldNotSeeUnlistPackage";
            const string externalPackageId   = "SimpleSite";
            const string unlistedVersion     = "3.0.0";
            const string latestListedVersion = "2.0.0";
            const string externalFeed        = "https://www.myget.org/F/simplesvc/";

            await ApplicationManager.RunAsync(appName, async appManager =>
            {
                var manager = appManager.SiteExtensionManager;
                await CleanSiteExtensions(manager);

                HttpResponseMessage response = await manager.GetRemoteExtension(externalPackageId, feedUrl: externalFeed);
                SiteExtensionInfo info       = await response.Content.ReadAsAsync <SiteExtensionInfo>();
                Assert.NotEqual(unlistedVersion, info.Version);

                response = await manager.GetRemoteExtension(externalPackageId, version: unlistedVersion, feedUrl: externalFeed);
                info     = await response.Content.ReadAsAsync <SiteExtensionInfo>();
                Assert.Equal(unlistedVersion, info.Version);

                response = await manager.GetRemoteExtensions(externalPackageId, allowPrereleaseVersions: true, feedUrl: externalFeed);
                List <SiteExtensionInfo> infos = await response.Content.ReadAsAsync <List <SiteExtensionInfo> >();
                Assert.NotEmpty(infos);
                foreach (var item in infos)
                {
                    Assert.NotEqual(unlistedVersion, item.Version);
                }

                response = await manager.InstallExtension(externalPackageId, feedUrl: externalFeed);
                info     = await response.Content.ReadAsAsync <SiteExtensionInfo>();
                Assert.Equal(externalPackageId, info.Id);
                Assert.Equal(latestListedVersion, info.Version);
                Assert.Equal(externalFeed, info.FeedUrl);

                TestTracer.Trace("Should able to installed unlisted package if specify version");
                response = await manager.InstallExtension(externalPackageId, version: unlistedVersion, feedUrl: externalFeed);
                info     = await response.Content.ReadAsAsync <SiteExtensionInfo>();
                Assert.Equal(externalPackageId, info.Id);
                Assert.Equal(unlistedVersion, info.Version);
                Assert.Equal(externalFeed, info.FeedUrl);

                UpdateHeaderIfGoingToBeArmRequest(manager.Client, isArmRequest: true);
                response = await manager.GetRemoteExtension(externalPackageId, feedUrl: externalFeed);
                ArmEntry <SiteExtensionInfo> armInfo = await response.Content.ReadAsAsync <ArmEntry <SiteExtensionInfo> >();
                Assert.NotEqual(unlistedVersion, armInfo.Properties.Version);

                response = await manager.GetRemoteExtensions(externalPackageId, allowPrereleaseVersions: true, feedUrl: externalFeed);
                ArmListEntry <SiteExtensionInfo> armInfos = await response.Content.ReadAsAsync <ArmListEntry <SiteExtensionInfo> >();
                Assert.NotEmpty(armInfos.Value);
                foreach (var item in armInfos.Value)
                {
                    Assert.NotEqual(unlistedVersion, item.Properties.Version);
                }

                response = await manager.InstallExtension(externalPackageId, feedUrl: externalFeed);
                Assert.Equal(HttpStatusCode.Created, response.StatusCode);
                await PollAndVerifyAfterArmInstallation(manager, externalPackageId);
                response = await manager.GetLocalExtension(externalPackageId);
                armInfo  = await response.Content.ReadAsAsync <ArmEntry <SiteExtensionInfo> >();
                Assert.Equal(externalPackageId, armInfo.Properties.Id);
                Assert.Equal(latestListedVersion, armInfo.Properties.Version);
                Assert.Equal(externalFeed, armInfo.Properties.FeedUrl);

                response = await manager.InstallExtension(externalPackageId, version: unlistedVersion, feedUrl: externalFeed);
                Assert.Equal(HttpStatusCode.Created, response.StatusCode);
                await PollAndVerifyAfterArmInstallation(manager, externalPackageId);
                response = await manager.GetLocalExtension(externalPackageId);
                armInfo  = await response.Content.ReadAsAsync <ArmEntry <SiteExtensionInfo> >();
                Assert.Equal(externalPackageId, armInfo.Properties.Id);
                Assert.Equal(unlistedVersion, armInfo.Properties.Version);
                Assert.Equal(externalFeed, armInfo.Properties.FeedUrl);
            });
        }
Example #45
0
        static void Run(string[] args)
        {
            bool   showHelp   = false;
            string testName   = null;
            string outputName = null;
            bool   verbose    = false;

            var options = new OptionSet()
            {
                { "?|h|help", "Show short usage screen.", v => showHelp = true },
                { "t=|test=", "Run this test only (full type name)", (string s) => testName = s },
                { "o=|output=", "Output test results to the console and to the indicated file", (string s) => outputName = s },
                { "v|verbose", "Print the running test name", v => verbose = true }
            };

            List <string> extra      = options.Parse(args);
            int           extraCount = extra.Count;

            if (showHelp || extraCount < 1)
            {
                Usage(showHelp ? 0 : 1, options);
            }

            testsAssembly = extra [0];

            if (!File.Exists(testsAssembly))
            {
                Die("Tests assembly '{0}' does not exist.", testsAssembly);
            }

            Assembly asm   = Assembly.LoadFrom(testsAssembly);
            var      tests = new List <StandaloneTest> ();

            LoadTestsFromAssembly(asm, tests);
            if (tests.Count == 0)
            {
                Die("No tests present in the '{0}' assembly. Tests must be public types decorated with the TestCase attribute and implementing the ITestCase interface.", testsAssembly);
            }

            ApplicationManager appMan = ApplicationManager.GetApplicationManager();
            int runCounter            = 0;
            int failedCounter         = 0;
            var reports = new List <string> ();

            Console.WriteLine("Running tests:");
            DateTime start = DateTime.Now;

            foreach (StandaloneTest test in tests)
            {
                if (test.Info.Disabled)
                {
                    continue;
                }

                if (!String.IsNullOrEmpty(testName))
                {
                    if (String.Compare(test.TestType.FullName, testName) != 0)
                    {
                        continue;
                    }
                }

                test.Run(appMan, verbose);
                runCounter++;
                if (!test.Success)
                {
                    failedCounter++;
                    reports.Add(FormatReport(test));
                }
            }

            DateTime end = DateTime.Now;

            Console.WriteLine();
            StreamWriter writer;

            if (!String.IsNullOrEmpty(outputName))
            {
                writer = new StreamWriter(outputName);
            }
            else
            {
                writer = null;
            }

            try
            {
                string report;
                if (reports.Count > 0)
                {
                    int    repCounter = 0;
                    int    numWidth   = reports.Count.ToString().Length;
                    string indent     = String.Empty.PadLeft(numWidth + 2);
                    string numFormat  = "{0," + numWidth + "}) ";

                    foreach (string r in reports)
                    {
                        repCounter++;
                        Console.Write(numFormat, repCounter);
                        report = FormatLines(indent, r, Environment.NewLine, true);
                        Console.WriteLine(report);
                        if (writer != null)
                        {
                            writer.Write(numFormat, repCounter);
                            writer.WriteLine(report);
                        }
                    }
                }
                else
                {
                    Console.WriteLine();
                }

                report = String.Format("Tests run: {0}; Total tests: {1}; Failed: {2}; Not run: {3}; Time taken: {4}",
                                       runCounter, tests.Count, failedCounter, tests.Count - runCounter, end - start);
                Console.WriteLine(report);
                if (writer != null)
                {
                    writer.WriteLine(report);
                }
            }
            finally
            {
                if (writer != null)
                {
                    writer.Close();
                    writer.Dispose();
                }
            }
        }
Example #46
0
        public async Task SiteExtensionGetArmTest()
        {
            const string appName           = "SiteExtensionGetAsyncTest";
            const string externalPackageId = "bootstrap";
            const string externalFeed      = "https://api.nuget.org/v3/index.json";

            await ApplicationManager.RunAsync(appName, async appManager =>
            {
                var manager = appManager.SiteExtensionManager;
                await CleanSiteExtensions(manager);

                UpdateHeaderIfGoingToBeArmRequest(manager.Client, true);
                TestTracer.Trace("GetRemoteExtensions with Arm header, expecting site extension info will be wrap inside Arm envelop");
                HttpResponseMessage responseMessage            = await manager.GetRemoteExtensions(externalPackageId, true, externalFeed);
                ArmListEntry <SiteExtensionInfo> armResultList = await responseMessage.Content.ReadAsAsync <ArmListEntry <SiteExtensionInfo> >();
                Assert.Equal(HttpStatusCode.OK, responseMessage.StatusCode);
                Assert.NotNull(armResultList);
                Assert.NotEmpty(armResultList.Value);
                Assert.NotNull(armResultList.Value.Where(item => string.Equals(externalPackageId, item.Properties.Id, StringComparison.OrdinalIgnoreCase)));
                Assert.True(responseMessage.Headers.Contains(Constants.RequestIdHeader));

                TestTracer.Trace("GetRemoteExtension with Arm header, expecting site extension info will be wrap inside Arm envelop");
                responseMessage = await manager.GetRemoteExtension(externalPackageId, feedUrl: externalFeed);
                ArmEntry <SiteExtensionInfo> armResult = await responseMessage.Content.ReadAsAsync <ArmEntry <SiteExtensionInfo> >();
                Assert.Equal(HttpStatusCode.OK, responseMessage.StatusCode);
                Assert.NotNull(armResult);
                Assert.Equal(externalPackageId, armResult.Properties.Id);
                Assert.True(responseMessage.Headers.Contains(Constants.RequestIdHeader));

                UpdateHeaderIfGoingToBeArmRequest(manager.Client, false);
                responseMessage = await manager.InstallExtension(externalPackageId, feedUrl: externalFeed);
                SiteExtensionInfo syncResult = await responseMessage.Content.ReadAsAsync <SiteExtensionInfo>();
                Assert.Equal(externalPackageId, syncResult.Id);
                Assert.True(responseMessage.Headers.Contains(Constants.RequestIdHeader));

                UpdateHeaderIfGoingToBeArmRequest(manager.Client, true);
                TestTracer.Trace("GetLocalExtensions (no filter) with Arm header, expecting site extension info will be wrap inside Arm envelop");
                responseMessage = await manager.GetLocalExtensions();
                armResultList   = await responseMessage.Content.ReadAsAsync <ArmListEntry <SiteExtensionInfo> >();
                Assert.Equal(HttpStatusCode.OK, responseMessage.StatusCode);
                Assert.NotNull(armResultList);
                Assert.NotEmpty(armResultList.Value);
                Assert.NotNull(armResultList.Value.Where(item => string.Equals(externalPackageId, item.Properties.Id, StringComparison.OrdinalIgnoreCase)));
                Assert.Equal(Constants.SiteExtensionProvisioningStateSucceeded, armResultList.Value.First <ArmEntry <SiteExtensionInfo> >().Properties.ProvisioningState);
                Assert.True(responseMessage.Headers.Contains(Constants.RequestIdHeader));
                foreach (var item in armResultList.Value)
                {
                    Assert.Equal(Constants.SiteExtensionProvisioningStateSucceeded, item.Properties.ProvisioningState);
                }

                TestTracer.Trace("GetLocalExtensions (with filter) with Arm header, expecting site extension info will be wrap inside Arm envelop");
                responseMessage = await manager.GetLocalExtensions(externalPackageId);
                armResultList   = await responseMessage.Content.ReadAsAsync <ArmListEntry <SiteExtensionInfo> >();
                Assert.Equal(HttpStatusCode.OK, responseMessage.StatusCode);
                Assert.NotNull(armResultList);
                Assert.NotEmpty(armResultList.Value);
                Assert.NotNull(armResultList.Value.Where(item => string.Equals(externalPackageId, item.Properties.Id, StringComparison.OrdinalIgnoreCase)));
                Assert.True(responseMessage.Headers.Contains(Constants.RequestIdHeader));
                foreach (var item in armResultList.Value)
                {
                    Assert.Equal(Constants.SiteExtensionProvisioningStateSucceeded, item.Properties.ProvisioningState);
                }
            });
        }
Example #47
0
        public ObjectBrowserForm(ToolStrip toolbar)
        {
            _includeWorkspace =
                ApplicationManager.GetInstance().ClientProfile.HaveFlag(
                    ClientFlags.CodeAssistObjectBrowserIncludeWorkspace);

            InitializeComponent();

            #region Initialize UI

            _mainForm = ApplicationManager.GetInstance().MainForm;

            if (toolbar == null)
            {
                _useMainToolbar = true;
                _toolbar        = _mainForm.MainToolbar;
            }
            else
            {
                _toolbar        = toolbar;
                _useMainToolbar = false;
            }

            _hideNonPublicMembers = true;
            _hideSpecialNames     = true;
            _hideInheritedMembers = true;
            _hidePropertyGrid     = true;

            // Make the readonly items nearly black (black will be ignored!)
            propertyGrid.ViewForeColor = Color.FromArgb(0, 0, 1);

            Text = Resources.OBDocumentTitle;
            listView.Columns[0].Width = listView.Width;

            PopulateToolbar();

            /*
             * Apply theme if available.
             */

            ThemeFlags flags = ApplicationManager.GetInstance().
                               ClientProfile.ThemeFlags;

            if (flags != null)
            {
                if (flags.ViewAltBackColor != Color.Empty)
                {
                    treeView.BackColor         = flags.ViewAltBackColor;
                    listView.BackColor         = flags.ViewAltBackColor;
                    propertyGrid.ViewBackColor = flags.ViewAltBackColor;
                }

                if (flags.ViewAltForeColor != Color.Empty)
                {
                    treeView.ForeColor = flags.ViewAltForeColor;
                    listView.ForeColor = flags.ViewAltForeColor;

                    // Don't set to black (shows up as silver).
                    if (flags.ViewAltForeColor != Color.Black)
                    {
                        propertyGrid.ViewForeColor = flags.ViewAltForeColor;
                    }
                }

                if (flags.MainBackColor != Color.Empty)
                {
                    _splitter.BackColor       = flags.MainBackColor;
                    _splitContainer.BackColor = flags.MainBackColor;
                }

                if (flags.ViewShowBorder == false)
                {
                    treeView.BorderStyle = BorderStyle.None;
                    listView.BorderStyle = BorderStyle.None;
                }
            }

            #endregion

            #region ActionState Handlers

            RegisterActionStateHandler(
                Constants.UI_TOOLBAR_VIEW_MODULES, ToolbarButtonState);
            RegisterActionStateHandler(
                Constants.UI_TOOLBAR_VIEW_NAMESPACES, ToolbarButtonState);

            if (_includeWorkspace)
            {
                RegisterActionStateHandler(
                    Constants.UI_TOOLBAR_SHOW_WORKSPACE_ONLY, ToolbarButtonState);
            }

            RegisterActionStateHandler(
                Constants.UI_TOOLBAR_SHOW_NONPUBLIC, ToolbarButtonState);
            RegisterActionStateHandler(
                Constants.UI_TOOLBAR_SHOW_HIDDEN, ToolbarButtonState);
            RegisterActionStateHandler(
                Constants.UI_TOOLBAR_SHOW_INHERITED, ToolbarButtonState);
            RegisterActionStateHandler(
                Constants.UI_TOOLBAR_REFRESH_VIEW, ToolbarButtonState);
            RegisterActionStateHandler(
                Constants.UI_TOOLBAR_SHOW_PROPERTIES, ToolbarButtonState);

            _mainForm.ClientWindow.ActiveDocumentChanged +=
                new EventHandler(_mainForm_ActiveDocumentChanged);

            FormClosed +=
                new FormClosedEventHandler(ObjectBrowserForm_FormClosed);

            #endregion

            _referenceManager = ReferenceManager.GetInstance();
            _modules          = new Dictionary <string, ModuleData>();

            LoadModules();
            EnableModuleView(false);
            UpdateTreeView();

            /*
             * Allow client applications to modify the form.
             */

            ObjectBrowserFormProxy.GetInstance().
            UpdateFormControls(Controls);
        }
Example #48
0
 protected ApiHelperTemplate(ApplicationManager app)
     : base(app)
 {
 }
Example #49
0
        public async Task SiteExtensionInstallPackageToWebRootAsyncTests()
        {
            const string appName                = "SiteExtensionInstallPackageToWebRootAsyncTests";
            const string externalPackageId      = "SimpleSvc";
            const string externalPackageVersion = "1.0.0";
            const string externalFeed           = "https://www.myget.org/F/simplesvc/";

            // site extension 'webrootxdttest' search for xdt files under site extension 'webrootxdttest' folder, and print out xdt content onto page
            const string externalPackageWithXdtId = "webrootxdttest";

            await ApplicationManager.RunAsync(appName, async appManager =>
            {
                var manager = appManager.SiteExtensionManager;
                await CleanSiteExtensions(manager);

                // install/update
                TestTracer.Trace("Perform InstallExtension with id '{0}', version '{1}' from '{2}'", externalPackageId, externalPackageVersion, externalFeed);
                UpdateHeaderIfGoingToBeArmRequest(manager.Client, true);
                HttpResponseMessage responseMessage    = await manager.InstallExtension(externalPackageId, externalPackageVersion, externalFeed, SiteExtensionInfo.SiteExtensionType.WebRoot);
                ArmEntry <SiteExtensionInfo> armResult = null;
                if (responseMessage.StatusCode == HttpStatusCode.OK)
                {
                    TestTracer.Trace("Installation done within 15 seconds, no polling needed.");
                    armResult = await responseMessage.Content.ReadAsAsync <ArmEntry <SiteExtensionInfo> >();
                }
                else
                {
                    Assert.Equal(HttpStatusCode.Created, responseMessage.StatusCode);
                    responseMessage = await PollAndVerifyAfterArmInstallation(manager, externalPackageId);
                    armResult       = await responseMessage.Content.ReadAsAsync <ArmEntry <SiteExtensionInfo> >();
                }

                // shouldn`t see restart header since package doesn`t come with XDT
                Assert.False(responseMessage.Headers.Contains(Constants.SiteOperationHeaderKey), "Must not contain restart header");
                Assert.Equal(externalFeed, armResult.Properties.FeedUrl);
                Assert.Equal(externalPackageVersion, armResult.Properties.Version);
                Assert.Equal(HttpStatusCode.OK, responseMessage.StatusCode);

                TestTracer.Trace("GET request to verify package content has been copied to wwwroot");
                HttpClient client      = new HttpClient();
                responseMessage        = await client.GetAsync(appManager.SiteUrl);
                string responseContent = await responseMessage.Content.ReadAsStringAsync();
                Assert.NotNull(responseContent);
                Assert.True(responseContent.Contains(@"<h3>Site for testing</h3>"));

                TestTracer.Trace("GetLocalExtension should return WebRoot type SiteExtensionInfo");
                responseMessage = await manager.GetLocalExtension(externalPackageId);
                armResult       = await responseMessage.Content.ReadAsAsync <ArmEntry <SiteExtensionInfo> >();
                Assert.Equal(SiteExtensionInfo.SiteExtensionType.WebRoot, armResult.Properties.Type);

                responseMessage = await manager.GetLocalExtensions(externalPackageId);
                var results     = await responseMessage.Content.ReadAsAsync <ArmListEntry <SiteExtensionInfo> >();
                foreach (var item in results.Value)
                {
                    if (string.Equals(externalPackageId, item.Properties.Id, StringComparison.OrdinalIgnoreCase))
                    {
                        Assert.Equal(SiteExtensionInfo.SiteExtensionType.WebRoot, item.Properties.Type);
                    }
                }

                // delete
                TestTracer.Trace("Perform UninstallExtension with id '{0}' only.", externalPackageId);
                responseMessage = await manager.UninstallExtension(externalPackageId);
                armResult       = await responseMessage.Content.ReadAsAsync <ArmEntry <SiteExtensionInfo> >();
                Assert.Null(armResult);
                Assert.Equal(HttpStatusCode.OK, responseMessage.StatusCode);

                TestTracer.Trace("GET request to verify package content has been removed wwwroot");
                responseMessage = await client.GetAsync(appManager.SiteUrl);
                Assert.Equal(HttpStatusCode.Forbidden, responseMessage.StatusCode);

                // install package that with xdt file
                TestTracer.Trace("Perform InstallExtension with id '{0}' from '{1}'", externalPackageWithXdtId, externalFeed);
                responseMessage = await manager.InstallExtension(externalPackageWithXdtId, feedUrl: externalFeed, type: SiteExtensionInfo.SiteExtensionType.WebRoot);
                Assert.Equal(HttpStatusCode.Created, responseMessage.StatusCode);
                Assert.True(responseMessage.Headers.Contains(Constants.RequestIdHeader));
                // package come with XDT, which would require site restart
                TestTracer.Trace("Poll for status. Expecting 200 response eventually with site operation header.");
                responseMessage = await PollAndVerifyAfterArmInstallation(manager, externalPackageWithXdtId);
                armResult       = await responseMessage.Content.ReadAsAsync <ArmEntry <SiteExtensionInfo> >();
                // after successfully installed, should return SiteOperationHeader to notify GEO to restart website
                Assert.True(responseMessage.Headers.Contains(Constants.SiteOperationHeaderKey));
                Assert.Equal(externalFeed, armResult.Properties.FeedUrl);
                Assert.Equal(HttpStatusCode.OK, responseMessage.StatusCode);

                TestTracer.Trace("GET request to verify package content has been copied to wwwroot");
                responseMessage = await client.GetAsync(appManager.SiteUrl);
                responseContent = await responseMessage.Content.ReadAsStringAsync();
                Assert.NotNull(responseContent);
                Assert.True(responseContent.Contains(@"1 files"));
                Assert.True(responseContent.Contains(@"site\path\shall\not\be\found")); // xdt content
            });
        }
        public void OnClick(Window mainWindow, Instance instance)
        {
            Assert.ArgumentNotNull(mainWindow, nameof(mainWindow));

            CoreApp.RunApp(ApplicationManager.GetEmbeddedFile(@"MongoDb.WindowsService.Installer.zip", "SIM.Tool.Windows", @"MongoDb.WindowsService.Installer.exe"));
        }
 private static HttpClient CreateClient(ApplicationManager appManager)
 {
     HttpClientHandler handler = HttpClientHelper.CreateClientHandler(appManager.ServiceUrl, appManager.DeploymentManager.Credentials);
     return new HttpClient(handler)
     {
         BaseAddress = new Uri(appManager.ServiceUrl),
         Timeout = TimeSpan.FromMinutes(5)
     };
 }
Example #52
0
    IEnumerator waitAndCheckForReload()
    {
        yield return(new WaitForSeconds(0.3f));

        ApplicationManager.GameOver();
    }
Example #53
0
 public void StopApplicationManager()
 {
     ApplicationManager.GetInstance().Stop();
 }
Example #54
0
        public async Task SiteExtensionInstallPackageToWebRootTests()
        {
            const string appName                = "SiteExtensionInstallPackageToWebRootTests";
            const string externalPackageId      = "SimpleSvc";
            const string externalPackageVersion = "1.0.0";
            const string externalFeed           = "https://www.myget.org/F/simplesvc/";

            // site extension 'webrootxdttest' search for xdt files under site extension 'webrootxdttest' folder, and print out xdt content onto page
            const string externalPackageWithXdtId = "webrootxdttest";

            await ApplicationManager.RunAsync(appName, async appManager =>
            {
                var manager = appManager.SiteExtensionManager;
                await CleanSiteExtensions(manager);

                // install/update
                TestTracer.Trace("Perform InstallExtension with id '{0}', version '{1}' from '{2}'", externalPackageId, externalPackageVersion, externalFeed);
                HttpResponseMessage responseMessage = await manager.InstallExtension(externalPackageId, externalPackageVersion, externalFeed, SiteExtensionInfo.SiteExtensionType.WebRoot);
                SiteExtensionInfo result            = await responseMessage.Content.ReadAsAsync <SiteExtensionInfo>();
                Assert.Equal(externalPackageId, result.Id);
                Assert.Equal(externalPackageVersion, result.Version);
                Assert.Equal(externalFeed, result.FeedUrl);

                TestTracer.Trace("GET request to verify package content has been copied to wwwroot");
                HttpClient client      = new HttpClient();
                responseMessage        = await client.GetAsync(appManager.SiteUrl);
                string responseContent = await responseMessage.Content.ReadAsStringAsync();
                Assert.NotNull(responseContent);
                Assert.True(responseContent.Contains(@"<h3>Site for testing</h3>"));

                TestTracer.Trace("GetLocalExtension should return WebRoot type SiteExtensionInfo");
                responseMessage = await manager.GetLocalExtension(externalPackageId);
                result          = await responseMessage.Content.ReadAsAsync <SiteExtensionInfo>();
                Assert.Equal(SiteExtensionInfo.SiteExtensionType.WebRoot, result.Type);

                responseMessage = await manager.GetLocalExtensions(externalPackageId);
                var results     = await responseMessage.Content.ReadAsAsync <List <SiteExtensionInfo> >();
                foreach (var item in results)
                {
                    if (string.Equals(externalPackageId, item.Id, StringComparison.OrdinalIgnoreCase))
                    {
                        Assert.Equal(SiteExtensionInfo.SiteExtensionType.WebRoot, item.Type);
                    }
                }

                // delete
                TestTracer.Trace("Perform UninstallExtension with id '{0}' only.", externalPackageId);
                responseMessage   = await manager.UninstallExtension(externalPackageId);
                bool deleteResult = await responseMessage.Content.ReadAsAsync <bool>();
                Assert.True(deleteResult, "Delete must return true");

                TestTracer.Trace("GET request to verify package content has been removed wwwroot");
                responseMessage = await client.GetAsync(appManager.SiteUrl);
                Assert.Equal(HttpStatusCode.Forbidden, responseMessage.StatusCode);

                // install package that with xdt file
                TestTracer.Trace("Perform InstallExtension with id '{0}' from '{1}'", externalPackageWithXdtId, externalFeed);
                responseMessage = await manager.InstallExtension(externalPackageWithXdtId, feedUrl: externalFeed, type: SiteExtensionInfo.SiteExtensionType.WebRoot);
                result          = await responseMessage.Content.ReadAsAsync <SiteExtensionInfo>();
                Assert.Equal(externalPackageWithXdtId, result.Id);
                Assert.Equal(externalFeed, result.FeedUrl);

                TestTracer.Trace("GET request to verify package content has been copied to wwwroot");
                responseMessage = await client.GetAsync(appManager.SiteUrl);
                responseContent = await responseMessage.Content.ReadAsStringAsync();
                Assert.NotNull(responseContent);
                Assert.True(responseContent.Contains(@"1 files"));
                Assert.True(responseContent.Contains(@"site\path\shall\not\be\found")); // xdt content
            });
        }
Example #55
0
 public void Awake()
 {
     instance = this;
     AppLaunch();
 }
Example #56
0
 private void OnEnable()
 {
     instance = this;
     Debug.Log(this.name + " : OnEnable");
 }
Example #57
0
 void Start()
 {
     applicationManager = FindObjectOfType<ApplicationManager>();
     gameController = FindObjectOfType<GameController>();
 }
 public UiOrdersMainHelper(ApplicationManager app)
     : base(app)
 {
 }
 private static void DoClone(string repositoryName, ApplicationManager appManager)
 {
     using (var repo = Git.Clone(repositoryName, appManager.GitUrl))
     {
         Assert.False(repo.FileExists("index.html"));
     }
 }
Example #60
0
    IEnumerator NextLevelLoad()
    {
        yield return(new WaitForSeconds(1));

        ApplicationManager.LoadNextGamePlayScene();
    }