public async Task Download_ShouldRedirectToUrl_GivenValidInput() { // Arrange var userManager = UserManagerMock.GetMock; userManager.GetUserId(TestUserId); var resourceService = ResourceServiceMock.GetMock; resourceService .CanBeDownloadedByUser(true) .GetDownloadUrlAsync(FileUrl); var controller = new ResourcesController( userManager.Object, cloudinaryService: null, courseService: null, resourceService.Object, trainerService: null); using (controller) { // Act var result = await controller.Download(TestResourceId); // Assert var redirectResult = Assert.IsType <RedirectResult>(result); Assert.Equal(FileUrl, redirectResult.Url); userManager.Verify(); resourceService.Verify(); } }
public IEnumerator ShowPanel() { yield return(new WaitForEndOfFrame()); if (levelsController.cur_level_conf.tutors.Count > 0) { if (levelsController.cur_level_conf.tutors[0].type == Tutor.TutorType.INFO) { tutorController.ShowTutor2(levelsController.cur_level_conf.tutors[0]); } } foreach (var goal in levelsController.cur_level_conf.non_product_goals) { var go = Instantiate(ResourcesController.get_instance().prefabs_resources.GoalItemView, goals_conteiner); var view = go.GetComponent <GoalItemView>(); view.Init(GoalType.NON_PRODUCTS, goal.value, Product.ProductType.NONE, goal.goal); } foreach (var goal in levelsController.cur_level_conf.quantitative_goals) { var go = Instantiate(ResourcesController.get_instance().prefabs_resources.GoalItemView, goals_conteiner); GoalItemView view = go.GetComponent <GoalItemView>(); view.Init(GoalType.PRODUCTS, goal.amount, goal.product, NonProductsGoal.NON); } header.text = "Level " + (levelsController.cur_level_conf.id + 1); goals_panel.SetActive(true); }
public async Task Create_ShouldRedirectToTrainersIndex_GivenMismatchingCourseAndModel() { // Arrange var testModel = GetResourceCreateModel(); var courseService = CourseServiceMock.GetMock; var controller = new ResourcesController( userManager: null, cloudinaryService: null, courseService.Object, resourceService: null, trainerService: null) { TempData = TempDataMock.GetMock }; using (controller) { // Act var result = await controller.Create(TestCourseId + 1, testModel); // Assert controller.TempData.AssertErrorMsg(WebConstants.CourseInvalidMsg); this.AssertRedirectToTrainersIndex(result); courseService.Verify(); } }
public async Task Download_ShouldRedirectToCourseIndex_GivenUserIsNotTrainerOrEnrolledStudent() { // Arrange var userManager = UserManagerMock.GetMock; userManager.GetUserId(TestUserId); var resourceService = ResourceServiceMock.GetMock; resourceService.CanBeDownloadedByUser(false); var controller = new ResourcesController( userManager.Object, cloudinaryService: null, courseService: null, resourceService.Object, trainerService: null) { TempData = TempDataMock.GetMock }; using (controller) { // Act var result = await controller.Download(TestResourceId); // Assert controller.TempData.AssertErrorMsg(WebConstants.ResourceDownloadUnauthorizedMsg); this.AssertRedirectToCoursesIndex(result); userManager.Verify(); resourceService.Verify(); } }
public async Task Download_ShouldRedirectToCourseIndex_GivenInvalidUser() { // Arrange var userManager = UserManagerMock.GetMock; userManager.GetUserId(null); var controller = new ResourcesController( userManager.Object, cloudinaryService: null, courseService: null, resourceService: null, trainerService: null) { TempData = TempDataMock.GetMock }; using (controller) { // Act var result = await controller.Download(TestResourceId); // Assert controller.TempData.AssertErrorMsg(WebConstants.InvalidUserMsg); this.AssertRedirectToCoursesIndex(result); userManager.Verify(); } }
public void init(Message msg) { var param = Yaga.Helpers.CastHelper.Cast <CustomerAPI.InitCustParams>(msg.parametrs); bool start_coroutine = customers.Count == 0; int i = 0; foreach (var conf in param.configs) { var go = Instantiate(ResourcesController.get_instance().prefabs_resources.Customer, ResourcesController.get_instance().CustomersConteiner.transform); var customer = go.GetComponent <Customer>(); customer.Init(conf.need_product, conf.wait_time, conf.cash, param.successable); customers.Add(go.GetComponent <Customer>()); ++i; } sim_customers_amount = param.sim_customers_amount; min_time_wait = param.min_time_wait; max_time_wait = param.max_time_wait; randomize = param.randomize; if (start_coroutine) { StartCoroutine(shadule_customers()); } }
public TranslationsController() { if (instance != null) { return; } instance = this; textTranslations = new Dictionary <string, string> (); var text = (ResourcesController.LoadOnce("Translations") as TextAsset).text; var splitted = text.Split('☻'); var languages = splitted [0].Split('☺'); string [] currentList; for (int i = 1; i < splitted.Length; i++) { currentList = splitted [i].Split('☺'); if (currentList.Length < languages.Length) { continue; } for (int q = 0; q < languages.Length; q++) { textTranslations.Add(currentList [0] + "_" + languages [q], currentList [q + 1]); } } }
public async Task CreateStaticPublicIPAddressTest() { // SET PARAMETERS var location = Environment.GetEnvironmentVariable("AZURE_LOCATION"); var baseUriString = Environment.GetEnvironmentVariable("AZURE_BASE_URL"); var resourceGroupName = Environment.GetEnvironmentVariable("AZURE_RESOURCEGROUP"); var servicePrincipalId = Environment.GetEnvironmentVariable("AZURE_CLIENT_ID"); var servicePrincipalSecret = Environment.GetEnvironmentVariable("AZURE_CLIENT_SECRET"); var azureResourceId = Environment.GetEnvironmentVariable("AZURE_RESOURCE_ID"); var tenantId = Environment.GetEnvironmentVariable("AZURE_TENANT_ID"); var subscriptionId = Environment.GetEnvironmentVariable("AZURE_SUBSCRIPTION_ID"); var ipName = Environment.GetEnvironmentVariable("AZURE_IP_NAME"); var credentials = new CustomLoginCredentials(servicePrincipalId, servicePrincipalSecret, azureResourceId, tenantId); // SET CONTROLLER var resourceController = new ResourcesController(new Uri(baseUriString), credentials, subscriptionId); var networkController = new NetworkController(new Uri(baseUriString), credentials, subscriptionId); // CREATE RESOURCE GROUP var resourceGroup = await resourceController.CreateResourceGroup(resourceGroupName, location); // CREATE RESOURCE GROUP VALIDATION Assert.Equal("OK", resourceGroup.Response.ReasonPhrase, ignoreCase: true); Assert.NotNull(resourceGroup.Body); // CREATE IP var ip = await networkController.CreatePublicIpAddress(ipName, resourceGroupName, location, "Static"); // VALIDATION Assert.Equal("OK", ip.Response.ReasonPhrase, ignoreCase: true); Assert.NotNull(ip.Body); Assert.NotEmpty(ip.Body.Id); }
public void Update() { timer -= Time.deltaTime; timer_view.TickDown(customer.wait_time, Time.deltaTime); if (timer < 1 / 3.0f * customer.def_wait_time && customer.cat_success_state == 2) { customer.cat_success_state = 3; customer.entity.customer_sprite.sprite = ResourcesController.get_instance().product_resources.get_customer_sprite(customer.type, customer.cat_success_state - 1); } else if (timer < 2 / 3.0f * customer.def_wait_time && customer.cat_success_state == 1) { customer.cat_success_state = 2; customer.entity.customer_sprite.sprite = ResourcesController.get_instance().product_resources.get_customer_sprite(customer.type, customer.cat_success_state - 1); } if (timer <= 0 && !customer.successable) { customer.LeaveBad(); } }
public async Task RegisterResourceProviderTest() { // SET PARAMETERS var location = Environment.GetEnvironmentVariable("AZURE_LOCATION"); var baseUriString = Environment.GetEnvironmentVariable("AZURE_BASE_URL"); var resourceGroupName = Environment.GetEnvironmentVariable("AZURE_RESOURCEGROUP"); var servicePrincipalId = Environment.GetEnvironmentVariable("AZURE_CLIENT_ID"); var servicePrincipalSecret = Environment.GetEnvironmentVariable("AZURE_CLIENT_SECRET"); var azureResourceId = Environment.GetEnvironmentVariable("AZURE_RESOURCE_ID"); var tenantId = Environment.GetEnvironmentVariable("AZURE_TENANT_ID"); var subscriptionId = Environment.GetEnvironmentVariable("AZURE_SUBSCRIPTION_ID"); var resourceProvidersName = Environment.GetEnvironmentVariable("AZURE_RESOURCEPROVIDERS"); var credentials = new CustomLoginCredentials(servicePrincipalId, servicePrincipalSecret, azureResourceId, tenantId); // SET CONTROLLER var resourceController = new ResourcesController(new Uri(baseUriString), credentials, subscriptionId); // REGISTER RESOURCE PROVIDER var providers = resourceProvidersName.Split(';'); foreach (var resourceProviderName in providers) { var resourceProvider = await resourceController.RegisterResourceProvider(resourceProviderName); // VALIDATION Assert.Equal("OK", resourceProvider.Response.ReasonPhrase, ignoreCase: true); Assert.NotNull(resourceProvider.Body); Assert.Equal("registered", resourceProvider.Body.RegistrationState, ignoreCase: true); } }
public async Task CreateDataDiskTest() { // SET PARAMETERS var location = Environment.GetEnvironmentVariable("AZURE_LOCATION"); var baseUriString = Environment.GetEnvironmentVariable("AZURE_BASE_URL"); var resourceGroupName = Environment.GetEnvironmentVariable("AZURE_RESOURCEGROUP"); var servicePrincipalId = Environment.GetEnvironmentVariable("AZURE_CLIENT_ID"); var servicePrincipalSecret = Environment.GetEnvironmentVariable("AZURE_CLIENT_SECRET"); var azureResourceId = Environment.GetEnvironmentVariable("AZURE_RESOURCE_ID"); var tenantId = Environment.GetEnvironmentVariable("AZURE_TENANT_ID"); var subscriptionId = Environment.GetEnvironmentVariable("AZURE_SUBSCRIPTION_ID"); var diskName = Environment.GetEnvironmentVariable("AZURE_DISK_NAME"); var credentials = new CustomLoginCredentials(servicePrincipalId, servicePrincipalSecret, azureResourceId, tenantId); // SET CONTROLLER var resourceController = new ResourcesController(new Uri(baseUriString), credentials, subscriptionId); var computerController = new ComputeController(new Uri(baseUriString), credentials, subscriptionId); // CREATE RESOURCE GROUP var resourceGroup = await resourceController.CreateResourceGroup(resourceGroupName, location); // CREATE RESOURCE GROUP VALIDATION Assert.Equal("OK", resourceGroup.Response.ReasonPhrase, ignoreCase: true); Assert.NotNull(resourceGroup.Body); // CREATE DISK var disk = await computerController.CreateDisk(resourceGroupName, diskName, 1, location); // CREATE DISK VALIDATION Assert.Equal("OK", disk.Response.ReasonPhrase, ignoreCase: true); Assert.NotNull(disk.Body); Assert.Equal("Succeeded", disk.Body.ProvisioningState.ToString(), ignoreCase: true); }
private void UpdatePopup() { float wellsBonus = 1f + AppConstants.WellSingleBonusValue * WellsController.instance.wells.FindAll(x => Vector3.Distance(x.wellData.position, automation.automationData.position) < AppConstants.WellsBonusDistance).Count; wellsBonus = wellsBonus > AppConstants.WellsBonusMinValue ? wellsBonus : AppConstants.WellsBonusMinValue; wellsBonus = wellsBonus < AppConstants.WellsBonusMaxValue ? wellsBonus : AppConstants.WellsBonusMaxValue; int ts = (int)(System.DateTime.UtcNow - new System.DateTime(1970, 1, 1, 0, 0, 0, System.DateTimeKind.Utc)).TotalSeconds; float gadgets = wellsBonus * Mathf.Abs(automation.automationData.ownerGadgetsConsumptionTimestamp - ts) * AppConstants.AutomationGadgetsProductionConstant; gadgets = gadgets < AppConstants.AutomationSingleResourceCapacity ? gadgets : AppConstants.AutomationSingleResourceCapacity; gadgetsAmount.text = ResourcesController.FormatNumber(gadgets) + (automation.TerritoryBoosted > 1 ? " (<color=lime>x" + automation.TerritoryBoosted + "</color>)" : ""); gadgetsButton.GetComponent <Button>().onClick.RemoveAllListeners(); gadgetsButton.GetComponent <Button>().onClick.AddListener(() => { CollectGadgets(gadgets); }); biomassAmount.text = ResourcesController.FormatNumber(automation.automationData.convertedBiomassAmount) + (automation.TerritoryBoosted > 1 ? " (<color=lime>x" + automation.TerritoryBoosted + "</color>)" : ""); biomassButton.GetComponent <Button>().onClick.RemoveAllListeners(); biomassButton.GetComponent <Button>().onClick.AddListener(() => { CollectBiomass(automation.automationData.convertedBiomassAmount); }); energyAmount.text = ResourcesController.FormatNumber(automation.automationData.convertedEnergyAmount) + (automation.TerritoryBoosted > 1 ? " (<color=lime>x" + automation.TerritoryBoosted + "</color>)" : ""); energyButton.GetComponent <Button>().onClick.RemoveAllListeners(); energyButton.GetComponent <Button>().onClick.AddListener(() => { CollectEnergy(automation.automationData.convertedEnergyAmount); }); fuelAmount.text = ResourcesController.FormatNumber(automation.automationData.convertedFuelAmount) + (automation.TerritoryBoosted > 1 ? " (<color=lime>x" + automation.TerritoryBoosted + "</color>)" : ""); fuelButton.GetComponent <Button>().onClick.RemoveAllListeners(); fuelButton.GetComponent <Button>().onClick.AddListener(() => { CollectFuel(automation.automationData.convertedFuelAmount); }); ownerConversionFrom.sprite = automation.automationData.convertedResourceType == (int)AppConstants.ResourceType.ENERGY ? energySprite : automation.automationData.convertedResourceType == (int)AppConstants.ResourceType.BIOMASS ? biomassSprite : automation.automationData.convertedResourceType == (int)AppConstants.ResourceType.GADGETS ? gadgetsSprite : fuelSprite; commonConversionFrom.sprite = automation.automationData.convertedResourceType == (int)AppConstants.ResourceType.ENERGY ? energySprite : automation.automationData.convertedResourceType == (int)AppConstants.ResourceType.BIOMASS ? biomassSprite : automation.automationData.convertedResourceType == (int)AppConstants.ResourceType.GADGETS ? gadgetsSprite : fuelSprite; conversionButton.GetComponent <Button>().onClick.RemoveAllListeners(); conversionButton.GetComponent <Button>().onClick.AddListener(() => { ChangeConversion(); }); commonNick.text = automation.automationData.nick; }
public async Task Create_ShouldRedirectToTrainersResources_GivenInvalidFormModel() { // Arrange var controller = new ResourcesController( userManager: null, cloudinaryService: null, courseService: null, resourceService: null, trainerService: null) { TempData = TempDataMock.GetMock }; using (controller) { controller.ModelState.AddModelError(string.Empty, "Error"); // Act var result = await controller.Create(TestCourseId, null); // Assert controller.TempData.AssertErrorMsg(WebConstants.FileInvalidMsg); this.AssertRedirectToTrainersResourcesWithRouteId(result); } }
public async Task ResourceGroupExistanceCheckTest() { // SET PARAMETERS var location = Environment.GetEnvironmentVariable("AZURE_LOCATION"); var baseUriString = Environment.GetEnvironmentVariable("AZURE_BASE_URL"); var resourceGroupName = Environment.GetEnvironmentVariable("AZURE_RESOURCEGROUP"); var servicePrincipalId = Environment.GetEnvironmentVariable("AZURE_CLIENT_ID"); var servicePrincipalSecret = Environment.GetEnvironmentVariable("AZURE_CLIENT_SECRET"); var azureResourceId = Environment.GetEnvironmentVariable("AZURE_RESOURCE_ID"); var tenantId = Environment.GetEnvironmentVariable("AZURE_TENANT_ID"); var subscriptionId = Environment.GetEnvironmentVariable("AZURE_SUBSCRIPTION_ID"); var credentials = new CustomLoginCredentials(servicePrincipalId, servicePrincipalSecret, azureResourceId, tenantId); // SET CONTROLLER var resourceController = new ResourcesController(new Uri(baseUriString), credentials, subscriptionId); // CREATE RESOURCE GROUP var resourceGroup = await resourceController.CreateResourceGroup(resourceGroupName, location); // CREATE RESOURCE GROUP VALIDATION Assert.Equal("OK", resourceGroup.Response.ReasonPhrase, ignoreCase: true); Assert.NotNull(resourceGroup.Body); // CHECK RESOURCE GROUP var resourceGroupExistance = await resourceController.CheckResourceGroupExistance(resourceGroupName); // CHECK RESOURCE GROUP VALIDATION Assert.Equal("OK", resourceGroupExistance.Response.ReasonPhrase, ignoreCase: true); Assert.True(resourceGroupExistance.Body); }
public async Task CreateStorageAccountTest() { // SET PARAMETERS var location = Environment.GetEnvironmentVariable("AZURE_LOCATION"); var baseUriString = Environment.GetEnvironmentVariable("AZURE_BASE_URL"); var resourceGroupName = Environment.GetEnvironmentVariable("AZURE_RESOURCEGROUP"); var servicePrincipalId = Environment.GetEnvironmentVariable("AZURE_CLIENT_ID"); var servicePrincipalSecret = Environment.GetEnvironmentVariable("AZURE_CLIENT_SECRET"); var azureResourceId = Environment.GetEnvironmentVariable("AZURE_RESOURCE_ID"); var tenantId = Environment.GetEnvironmentVariable("AZURE_TENANT_ID"); var subscriptionId = Environment.GetEnvironmentVariable("AZURE_SUBSCRIPTION_ID"); var storageNamePrefix = Environment.GetEnvironmentVariable("AZURE_STORAGENAME_PREFIX"); var storageAccountName = string.Format("{0}{1}", storageNamePrefix, new Random().Next(0, 99)); var storageAccountSku = Profile2018Storage.Models.SkuName.StandardLRS; var credentials = new CustomLoginCredentials(servicePrincipalId, servicePrincipalSecret, azureResourceId, tenantId); // SET CONTROLLER var resourceController = new ResourcesController(new Uri(baseUriString), credentials, subscriptionId); var storageController = new StorageController(new Uri(baseUriString), credentials, subscriptionId); // CREATE RESOURCE GROUP var resourceGroup = await resourceController.CreateResourceGroup(resourceGroupName, location); // CREATE RESOURCE GROUP VALIDATION Assert.Equal("OK", resourceGroup.Response.ReasonPhrase, ignoreCase: true); Assert.NotNull(resourceGroup.Body); // CREATE STORAGE ACCOUNT var storageAccount = await storageController.CreateStorageAccount(storageAccountName, resourceGroupName, location, storageAccountSku); // VALIDATION Assert.Equal("OK", storageAccount.Response.ReasonPhrase, ignoreCase: true); Assert.NotNull(storageAccount.Body); Assert.Equal("Succeeded", storageAccount.Body.ProvisioningState.ToString(), ignoreCase: true); }
public void Initialise() { _controller = new ResourcesController( _mockResources.Object, _mockLoggingService.Object); _controller.Request = new HttpRequestMessage(); }
public LanguageController() { if (instance != null) { return; } instance = this; languages = new List <string> (); languagesSelfNames = new List <string> (); languageLetters = new List <List <char> > (); languageLetterChances = new List <List <int> > (); languageGameLetters = new List <List <string> > (); languageFontLetters = new List <string> (); var init = (ResourcesController.LoadOnce("Languages") as TextAsset).text.Split('\n'); for (int i = 0; i + 4 < init.Length; i += 5) { var languageNames = init [i + 0].Split(' '); languages.Add(languageNames [0]); languagesSelfNames.Add(languageNames [0]); var letters = init [i + 1].Split(' '); List <char> resultLetters = new List <char> (); for (int q = 0; q < letters.Length; q++) { resultLetters.Add(letters [q] [0]); } languageLetters.Add(resultLetters); var chances = init [i + 2].Split(' '); List <int> resultChances = new List <int> (); for (int q = 0; q < chances.Length; q++) { resultChances.Add(int.Parse(chances [q])); } languageLetterChances.Add(resultChances); var gameLetters = init [i + 3].Split(' '); //Debug.Log (gameLetters [gameLetters.Length - 1]); languageGameLetters.Add(new List <string> (gameLetters)); languageFontLetters.Add(init [i + 4]); } if (languages.Count == 0) { Debug.LogError("No languages"); } }
private void Start() { color = Color.white; renderer = GetComponent <SpriteRenderer>(); resourcesController = FindObjectOfType <ResourcesController>(); hideFlags = HideFlags.HideInHierarchy; Invoke("OnBecameInvisible", TimeToDisappear); }
public void Init(ProductType type, float t) { product_type = type; product_icon.sprite = ResourcesController.get_instance().product_resources.get_provider_by_type(type); time = t; }
public void StartState() { unit.timer.SetActive(true); unit.product_icon.SetActive(true); unit.product_icon.GetComponent <SpriteRenderer>().sprite = ResourcesController.get_instance().product_resources.get_lock_by_type(unit.cur_type); }
public ChatController(PulseContext pulseContext, UserManager <Account> userManager) { _pulseContext = pulseContext; _userManager = userManager; _model = new ChatViewModel(); _coachIndex = new ChatIndexViewModel(); _adminIndex = new ChatAdminViewModel(); _resourcesController = new ResourcesController(); }
public App() { InitializeComponent(); ResourcesController.LoadAll(); DependencyService.Register <WebDataStorage>(); MainPage = new MainPage(); }
public LightningController() { boltPrefab = ResourcesController.Load("Prefabs/Bolt") as GameObject; linePrefab = ResourcesController.Load("Prefabs/Line") as GameObject; activeBoltsObj = new List <GameObject> (); inactiveBoltsObj = new List <GameObject> (); attacks = new List <ToAttack> (); }
public void Init(List <ProductType> rcp, ProductType res_product, float p_time) { recipe = rcp; def_recipe = new List <ProductType>(rcp); result_product = res_product; process_time = p_time; unit_sprite.GetComponent <SpriteRenderer>().sprite = ResourcesController.get_instance().product_resources.get_production_unit_sprite_by_type(res_product); }
public void StartState() { unit.ready_icon.SetActive(true); unit.product_icon.SetActive(true); unit.product_icon.GetComponent <SpriteRenderer>().sprite = ResourcesController.get_instance().product_resources.get_big_by_type(unit.result_product); unit.timer.SetActive(false); }
public void OnLanguageChange() { if (isTranslatable) { text = translatingText; } gameObject.GetComponent <TextMesh> ().font = ResourcesController.Load("Fonts/TextFont" + Settings.language) as Font; }
public TowersSettings() { instance = this; attackPosition = new Dictionary <string, Vector2> (); towerPlacePosition = new Dictionary <string, Vector2> (); buffs = new Dictionary <string, List <string> > (); upgrades = new Dictionary <string, List <string> > (); startTowers = new List <string> (); var text = (ResourcesController.LoadOnce("Towers") as TextAsset).text; var towers = text.Split('\n'); foreach (var s in towers) { if (s == "") { continue; } var res = s.Split('|'); var name = res [0]; if (name == "") { continue; } var ups = res [1].Split('☺'); upgrades.Add(name, new List <string> ()); for (int i = 1; i < ups.Length; i++) { upgrades [name].Add(ups [i]); } var bfs = res [2].Split('☺'); buffs.Add(name, new List <string> ()); for (int i = 1; i < bfs.Length; i++) { buffs [name].Add(bfs [i]); } if (res [3] == "True") { startTowers.Add(name); } attackPosition.Add(name, new Vector2(float.Parse(res [4].Split('☺') [0]), float.Parse(res [4].Split('☺') [1]))); towerPlacePosition.Add(name, new Vector2(float.Parse(res [5].Split('☺') [0]), float.Parse(res [5].Split('☺') [1]))); } }
public void StartState() { unit.timer.SetActive(false); unit.product_icon.GetComponent <SpriteRenderer>().sprite = ResourcesController.get_instance().product_resources.get_big_by_type(unit.cur_type); MessageBus.Instance.SendMessage(new Message(ProductionFieldAPI.Messages.READY, new ProductionFieldAPI.ReadyParams(unit.cur_type))); }
public static void Destroy() { if (instance == null) { return; } instance.resources.Clear(); instance = null; }
public ResourcesController() { if (instance != null) { return; } instance = this; resources = new Dictionary <string, Object> (); }
// Safe references void Awake() { if (resourcesController == null) resourcesController = GameObject.FindObjectOfType<ResourcesController>(); }