void before_each() { session = new Dictionary <string, dynamic>(); seedController = new SeedController(); seedController.DeleteAllRecords(); Users = new Users(); }
/// <summary> /// Update database values as required for the current version. Typically this is used to apply bug fixes /// that require updates to database settings (such as media and UI templates). /// </summary> /// <param name="ctx">Context to be used for updating data.</param> /// <remarks>This function detects the current app schema version as defined in the AppSetting table and applies /// all relevant updates to bring it up to the current version. By the time this method exits, the app schema version /// in the AppSetting table will match the current schema version as defined in <see cref="GalleryDb.DataSchemaVersion" />. /// </remarks> /// <exception cref="System.Exception"></exception> public static void ApplyDbUpdates(GalleryDb ctx) { if (!ctx.AppSettings.Any()) { SeedController.InsertSeedData(ctx); } var curSchema = GetCurrentSchema(ctx); while (curSchema < GalleryDb.DataSchemaVersion) { var oldSchema = curSchema; switch (curSchema) { case GalleryDataSchemaVersion.V3_0_0: UpgradeTo301(ctx); break; case GalleryDataSchemaVersion.V3_0_1: UpgradeTo302(ctx); break; case GalleryDataSchemaVersion.V3_0_2: UpgradeTo303(ctx); break; case GalleryDataSchemaVersion.V3_0_3: UpgradeTo310(ctx); break; } curSchema = GetCurrentSchema(ctx); if (curSchema == oldSchema) { throw new Exception(String.Format("The migration function for schema {0} should have incremented the data schema version in the AppSetting table, but it did not.", curSchema)); } } }
public async void CreateDefaultUsers() { #region Arrange // create the option instances required by the ApplicationDbContext var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: "HREmp") .Options; var storeOptions = Options.Create(new OperationalStoreOptions()); // create a IWebHost environment mock instance var mockEnv = new Mock <IWebHostEnvironment>().Object; // define the variables for the users we want to test ApplicationUser user_Admin = null; ApplicationUser user_User = null; ApplicationUser user_NotExisting = null; #endregion #region Act // create a ApplicationDbContext instance using the in-memory DB using (var context = new ApplicationDbContext(options, storeOptions)) { // create a RoleManager instance var roleManager = IdentityHelper.GetRoleManager( new RoleStore <IdentityRole>(context)); // create a UserManager instance var userManager = IdentityHelper.GetUserManager( new UserStore <ApplicationUser>(context)); // create a SeedController instance var controller = new SeedController( context, roleManager, userManager, mockEnv ); // execute the SeedController's CreateDefaultUsers() method // to create the default users (and roles) await controller.CreateDefaultUsers(); // retrieve the users user_Admin = await userManager.FindByEmailAsync("*****@*****.**"); user_User = await userManager.FindByEmailAsync("*****@*****.**"); user_NotExisting = await userManager.FindByEmailAsync("*****@*****.**"); } #endregion #region Assert Assert.True( user_Admin != null && user_User != null && user_NotExisting == null ); #endregion }
void before_each() { seedController = new SeedController(); seedController.PurgeDb(); seedController.All(); homeController = new HomeController(); }
public void SpawnAllSeeds(SeedController seed1, SeedController seed2) { RemoveSpawnedSeeds(); SpawnSeedsForPlayer(seed1, true); SpawnSeedsForPlayer(seed2, false); }
void Start() { inputFieldWrapper = GameObject.Find("InputField"); inputField = inputFieldWrapper.GetComponent <InputField>(); seedControllerWrapper = GameObject.Find("SeedController"); seedController = seedControllerWrapper.GetComponent <SeedController>(); }
private void Callback_OnSeedLifetimeExpired(SeedController seedController) { if (!_seedController1.CanMove && !_seedController2.CanMove) { StopGame(); } }
private void Start() { seedControllerWrapper = GameObject.Find("SeedController"); seedController = seedControllerWrapper.GetComponent <SeedController>(); Debug.Log("seedController: " + seedController.ToString()); InitRefreshMesh(); }
private static void UpgradeUiTemplates(GalleryDb ctx) { // Deactivate and rename all existing templates with "(3.2.1 version)" suffix. Then insert new ones. foreach (var uiTemplateAlbumDto in ctx.UiTemplateAlbums) { ctx.UiTemplateAlbums.Remove(uiTemplateAlbumDto); } var tmplGalleryId = ctx.Galleries.Single(g => g.IsTemplate).GalleryId; foreach (var uiTemplateDto in ctx.UiTemplates) { if (uiTemplateDto.FKGalleryId == tmplGalleryId) { // Remove all UI templates associated with the template gallery. ctx.UiTemplates.Remove(uiTemplateDto); } else { uiTemplateDto.Name += " (3.2.1 version)"; } } ctx.SaveChanges(); SeedController.InsertDefaultUiTemplates(ctx); SeedController.InsertAdditionalUiTemplates(ctx); }
private void SpawnSeed(SeedController seedController, Vector3 pos) { EnergySeed spawnedSeed = Instantiate(_seedPrefab, transform).GetComponent <EnergySeed>(); spawnedSeed.transform.position = pos; spawnedSeed.Setup(seedController.PlayerType, seedController.SeedColor); }
public void GenerateRandomAlphaNumeric() { Assert.AreEqual(SeedController.GenerateRandomAlphaNumeric(0), ""); SeedController.GenerateRandomAlphaNumeric(5); int length = new Random().Next(500); TestRandomAlphaNumeric(SeedController.GenerateRandomAlphaNumeric(length), length); }
void before_each() { seedController = new SeedController(); seedController.DeleteAllRecords(); registration = ValidRegistration(); }
void OnTriggerEnter2D(Collider2D other) { SeedController seed = other.GetComponent <SeedController>(); if (seed != null) { Destroy(seed.gameObject); } }
void before_each() { blogsController = new BlogsController(); MockRouting(blogsController); seedController = new SeedController(); seedController.PurgeDb(); seedController.All(); }
void before_each() { _Controller = new HomeController(); _Seed = new SeedController(); _Seed.PurgeDb(); _Seed.All(); }
void before_each() { controller = new GamesController(); seedController = new SeedController(); seedController.PurgeDb(); seedController.All(); }
void OnTriggerEnter2D(Collider2D other) { // When a seed enter this, destroy it, and give the player some points SeedController seed = other.GetComponent <SeedController>(); if (seed != null) { Destroy(seed.gameObject); scoreDisplay.score += pointGain; } }
/// <summary> /// Verifies the application is correctly configured based on the current license type. Specifically, it verifies that /// additional UI templates are present for Enterprise license holders. /// </summary> private void ValidateLicenseTypeConfiguration() { if (License.LicenseType == LicenseLevel.Enterprise) { SeedController.InsertEnterpriseTemplates(); HelperFunctions.RemoveCache(CacheItem.UiTemplates); // The validation will make a copy of each new UI template for every gallery. Validate(); } }
protected override void OnModelCreating(ModelBuilder builder) { base.OnModelCreating(builder); #region Rename default Identity Table Names builder.HasDefaultSchema("public"); builder.Entity <RoleClaim>(builder => { //builder.HasOne(roleClaim => roleClaim.Role).WithMany(role => role.Claims).HasForeignKey(roleClaim => roleClaim.RoleId); //builder.Property(x => x.RoleId).HasColumnName("RoleId"); //Prevent replicating same name builder.ToTable("RoleClaim", schema: IdentitySchemaName); }); builder.Entity <Role>(builder => { builder.ToTable("Role", schema: IdentitySchemaName); }); builder.Entity <UserClaim>(builder => { //builder.HasOne(userClaim => userClaim.User).WithMany(user => user.Claims).HasForeignKey(userClaim => userClaim.UserId); builder.ToTable("UserClaim", schema: IdentitySchemaName); }); builder.Entity <UserLogin>(builder => { //builder.HasOne(userLogin => userLogin.User).WithMany(user => user.Logins).HasForeignKey(userLogin => userLogin.UserId); builder.ToTable("UserLogin", schema: IdentitySchemaName); }); builder.Entity <User>(builder => { builder.ToTable("User", schema: IdentitySchemaName); }); builder.Entity <UserRole>(builder => { //builder.HasOne(userRole => userRole.Role).WithMany(role => role.Users).HasForeignKey(userRole => userRole.RoleId); //builder.HasOne(userRole => userRole.User).WithMany(user => user.Roles).HasForeignKey(userRole => userRole.UserId); builder.ToTable("UserRole", schema: IdentitySchemaName); }); builder.Entity <UserToken>(builder => { //builder.HasOne(userToken => userToken.User).WithMany(user => user.UserTokens).HasForeignKey(userToken => userToken.UserId); builder.ToTable("UserToken", schema: IdentitySchemaName); }); #endregion #region Data Seeding if (Environment.IsDevelopment()) { using (SeedController seeder = new SeedController(builder)) { seeder.Execute(); } } #endregion }
protected virtual void HitSeed(SeedController seedToHit) { // Set up the attack force based on the attack angler's orbiter and orbitee Vector2 impact = attackAngler.orbiter.position - attackAngler.orbitee.position; impact.Normalize(); impact *= force; Debug.Log("Hit " + seedToHit.name); seedToHit.rigidbody.velocity = Vector2.zero; seedToHit.rigidbody.AddForce(impact); seedToHit.Hit.Invoke(); }
void OnTriggerEnter2D(Collider2D coll) { SeedController controller = coll.GetComponent <SeedController>(); if (controller.PlayerType == _seedType) { if (OnEnergySeedGathered != null) { OnEnergySeedGathered(this); } Destroy(gameObject); } }
/// <summary> /// Verify there are gallery settings for the current gallery that match every template gallery setting, creating any /// if necessary. /// </summary> /// <returns><c>true</c> if data was changed that necessitates reloading data from the data store, <c>false</c> otherwise.</returns> private bool ConfigureGallerySettingsTable() { var foundTmplGallerySettings = false; var needToClearCache = false; using (var repo = new GallerySettingRepository()) { //repo.Load(); var gallerySettingNamesInGallery = repo.Where(gs => gs.FKGalleryId == GalleryId).Select(gs => gs.SettingName).ToList(); // Loop through each template gallery setting. foreach (var gsTmpl in repo.Where(g => g.Gallery.IsTemplate)) { foundTmplGallerySettings = true; //if (!repo.Local.Any(gs => gs.SettingName == gsTmpl.SettingName && gs.FKGalleryId == GalleryId)) //if (!repo.Where(gs => gs.SettingName == gsTmpl.SettingName && gs.FKGalleryId == GalleryId).Any()) if (!gallerySettingNamesInGallery.Contains(gsTmpl.SettingName)) { // This gallery is missing an entry for a gallery setting. Create one by copying it from the template gallery. repo.Add(new GallerySettingDto() { FKGalleryId = GalleryId, SettingName = gsTmpl.SettingName, SettingValue = gsTmpl.SettingValue }); needToClearCache = true; } } repo.Save(); } if (!foundTmplGallerySettings) { // If there weren't *any* template gallery settings, insert the seed data. Generally this won't be necessary, but it // can help recover from certain conditions, such as when a SQL Server connection is accidentally specified without // the MultipleActiveResultSets keyword (or it was false). In this situation the galleries are inserted but an error // prevents the remaining data from being inserted. Once the user corrects this and tries again, this code can run to // finish inserting the seed data. using (var ctx = new GalleryDb()) { SeedController.InsertSeedData(ctx); } Factory.ValidateGalleries(); } return(needToClearCache); }
public void Get() { // Arrange SeedController controller = new SeedController(); // Act Seed result = controller.Get(); // Assert Assert.IsNotNull(result); TestRandomAlphaNumeric(result.seed, 32); Assert.AreEqual(result.expires_at.Kind, DateTimeKind.Utc); Assert.IsTrue(result.expires_at > DateTime.UtcNow && result.expires_at < DateTime.UtcNow.AddDays(1)); }
public async Task CreateSeedOnValidInput() { SetupDbMock(); testerMock.Setup(m => m.TestCRUD(It.IsAny <string>(), It.Is <string>(s => s.Contains("seed")))).ReturnsAsync("OK"); sut = new SeedController(dbMock.Object, testerMock.Object); await sut.Create(1); await sut.Create(new SeedCreateViewModel { DiagramId = SampleDiagram.DbDiagramId, SeedQuery = "seed" }); dbMock.VerifyAll(); }
private void SpawnSeedsForPlayer(SeedController seedController, bool left) { //todo : un algo cool pour spawner de seeds Vector3 startPos = seedController.transform.position + Vector3.up; Vector3 side = left ? Vector3.left : Vector3.right; Vector3 up = Vector3.up; SpawnSeed(seedController, startPos); for (int i = 0; i < _amountSeeds; ++i) { up += Vector3.up * Random.Range(_heightBetweenSeedsMinMax.x, _heightBetweenSeedsMinMax.y); float ratio = (float)i / (float)_amountSeeds; float randomX = _spawnCurveWidth.Evaluate(ratio); Vector3 pos = startPos + up + side * (_spawnCurvePosition.Evaluate(ratio) + Random.Range(-randomX, randomX / 2f)); SpawnSeed(seedController, pos); } }
/// <summary> /// Add a new item to the inventory list. /// </summary> public void AddItem(GameObject newItem) { SeedController seedController = newItem.GetComponent <SeedController>(); item = newItem; icon.sprite = seedController.inventorySprite; seedController.invImg = icon; seedController.itemOutline = outline; seedController.waterGlow = waterGlow; icon.fillAmount = 0; icon.enabled = true; iconBack.enabled = true; //seedController.StartGrowth(); removeButton.interactable = true; }
protected virtual void HandleControls() { if (Input.GetButtonDown("MeleeAttack")) { Debug.Log("Tried to hit something!"); // See if any Seeds are within the hitbox RaycastHit2D[] hits = Physics2D.BoxCastAll(hitbox.transform.position, hitbox.bounds.size, 0, Vector2.zero); SeedController seed = null; foreach (RaycastHit2D hit in hits) { seed = hit.transform.GetComponent <SeedController>(); if (seed != null) { HitSeed(seed); } } } }
/// <summary> /// Upgrades the 3.1.0 data to the 3.2.0 data. Applies to data such as app settings, gallery settings, templates, etc. /// Does not contain data structure changes such as new columns. /// </summary> /// <param name="ctx">Context to be used for updating data.</param> private static void UpgradeTo320(GalleryDb ctx) { foreach (var uiTmpl in ctx.UiTemplates.Where(t => t.TemplateType == UiTemplateType.Album)) { // Task 669: Allow manual sorting of media objects // Step 1: Add the Custom option to the sort by dropdown var srcText = @"<li class='gsp_abm_sum_sbi_hdr'>{{:Resource.AbmSortbyTt}}</li>"; var replText = @"<li class='gsp_abm_sum_sbi_hdr'>{{:Resource.AbmSortbyTt}}</li> {{if Album.VirtualType == 1 && Album.Permissions.EditAlbum}}<li><a href='#' data-id='-2147483648'>{{:Resource.AbmSortbyCustom}}</a></li>{{/if}}"; uiTmpl.HtmlTemplate = uiTmpl.HtmlTemplate.Replace(srcText, replText); // Step 2: Convert the thumbnails into a list of <li> tags instead of <div>'s. Required for jQuery UI Sortable. srcText = @"<div class='gsp_floatcontainer'> {{for Album.GalleryItems}} <div class='thmb{{if IsAlbum}} album{{/if}}' data-id='{{:Id}}' data-it='{{:ItemType}}'> <a class='gsp_thmbLink' href='{{: ~getGalleryItemUrl(#data, !IsAlbum) }}'> <img class='gsp_thmb_img' style='width:{{:Views[ViewIndex].Width}}px;height:{{:Views[ViewIndex].Height}}px;' src='{{:Views[ViewIndex].Url}}'> </a> <p class='gsp_go_t' style='width:{{:Views[ViewIndex].Width + 40}}px;' title='{{stripHtml:Title}}'>{{stripHtmlAndTruncate:Title}}</p> </div> {{/for}} </div>"; replText = @"<ul class='gsp_floatcontainer gsp_abm_thmbs'> {{for Album.GalleryItems}} <li class='thmb{{if IsAlbum}} album{{/if}}' data-id='{{:Id}}' data-it='{{:ItemType}}' style='width:{{:Views[ViewIndex].Width + 40}}px;'> <a class='gsp_thmbLink' href='{{: ~getGalleryItemUrl(#data, !IsAlbum) }}'> <img class='gsp_thmb_img' style='width:{{:Views[ViewIndex].Width}}px;height:{{:Views[ViewIndex].Height}}px;' src='{{:Views[ViewIndex].Url}}'> </a> <p class='gsp_go_t' title='{{stripHtml:Title}}'>{{stripHtmlAndTruncate:Title}}</p> </li> {{/for}} </ul>"; uiTmpl.HtmlTemplate = uiTmpl.HtmlTemplate.Replace(srcText, replText); // Step 3: Update the JavaScript so that left pane is rendered regardless of whether the client is on a touchscreen device srcText = @"var isTouch = window.Gsp.isTouchScreen(); var renderLeftPane = !isTouch || (isTouch && ($('.gsp_tb_s_CenterPane:visible, .gsp_tb_s_RightPane:visible').length == 0)); if (renderLeftPane ) { $('#{{:Settings.LeftPaneClientId}}').html( $.render [ '{{:Settings.LeftPaneTmplName}}' ]( window.{{:Settings.ClientId}}.gspData )); "; replText = @"var $lp = $('#{{:Settings.LeftPaneClientId}}'); if ($lp.length > 0) { $lp.html( $.render [ '{{:Settings.LeftPaneTmplName}}' ]( window.{{:Settings.ClientId}}.gspData )); "; uiTmpl.ScriptTemplate = uiTmpl.ScriptTemplate.Replace(srcText, replText); // Bug 709: Link to add objects page should not appear in empty virtual albums // Add a condition to the if statement so that Add link appears only for non-virtual albums srcText = @"{{if Album.Permissions.AddMediaObject}}<a href='{{: ~getAddUrl(#data) }}'>{{:Resource.AbmAddObj}}</a>{{/if}}"; replText = @"{{if Album.VirtualType == 1 && Album.Permissions.AddMediaObject}}<a href='{{: ~getAddUrl(#data) }}'>{{:Resource.AbmAddObj}}</a>{{/if}}"; uiTmpl.HtmlTemplate = uiTmpl.HtmlTemplate.Replace(srcText, replText); // Task 722: Add RSS link to album template srcText = @" <span class='gsp_abm_sum_col1_row1_hdr'>{{:Resource.AbmPfx}}</span>" ; replText = @" {{if Album.RssUrl}} <a class='gsp_abm_sum_btn' href='{{:Album.RssUrl}}'> <img src='{{:App.SkinPath}}/images/rss-s.png' title='{{:Resource.AbmRssTt}}' alt=''> </a> {{/if}} <span class='gsp_abm_sum_col1_row1_hdr'>{{:Resource.AbmPfx}}</span>" ; uiTmpl.HtmlTemplate = uiTmpl.HtmlTemplate.Replace(srcText, replText); // Task 730: Assign owner button should not be visible for virtual albums srcText = @" {{if Album.Permissions.AdministerGallery}} <a class='gsp_abm_sum_ownr_trigger gsp_abm_sum_btn' href='#'>" ; replText = @" {{if Album.VirtualType == 1 && Album.Permissions.AdministerGallery}} <a class='gsp_abm_sum_ownr_trigger gsp_abm_sum_btn' href='#'>" ; uiTmpl.HtmlTemplate = uiTmpl.HtmlTemplate.Replace(srcText, replText); } // Task 681: Merge My account button into username in header foreach (var uiTmpl in ctx.UiTemplates.Where(t => t.TemplateType == UiTemplateType.Header)) { // Step 1: Remove the HTML for the 'My account' icon var srcText = @" {{if Settings.AllowManageOwnAccount}} <div class='gsp_useroption'> <a class='gsp_myaccountlink' href='{{:App.CurrentPageUrl}}?g=myaccount&aid={{:Album.Id}}'> <img class='gsp_myaccount-user-icon' title='{{:Resource.HdrMyAccountTt}}' alt='{{:Resource.HdrMyAccountTt}}' src='{{:App.SkinPath}}/images/user-l.png'> </a></div> {{/if}}" ; var replText = ""; uiTmpl.HtmlTemplate = uiTmpl.HtmlTemplate.Replace(srcText, replText); // Step 2: Replace the username with a hyperlinked username that takes user to 'My account' page, // except when AllowManageOwnAccount=false, in which case just display the username like before. srcText = @" <span id='{{:Settings.ClientId}}_userwelcome' class='gsp_welcome'>{{:User.UserName}}</span></div>"; replText = @"{{if Settings.AllowManageOwnAccount}} <a id='{{:Settings.ClientId}}_userwelcome' href='{{:App.CurrentPageUrl}}?g=myaccount&aid={{:Album.Id}}' class='gsp_welcome' title='{{:Resource.HdrMyAccountTt}}'>{{:User.UserName}}</a> {{else}} <span id='{{:Settings.ClientId}}_userwelcome' class='gsp_welcome'>{{:User.UserName}}</span> {{/if}} </div>" ; uiTmpl.HtmlTemplate = uiTmpl.HtmlTemplate.Replace(srcText, replText); } foreach (var uiTmpl in ctx.UiTemplates.Where(t => t.TemplateType == UiTemplateType.LeftPane)) { // Task 675: Add RECENTLY ADDED and TOP RATED links to left pane const string srcText = @"<div id='{{:Settings.ClientId}}_lptv'></div>"; const string replText = @"<div id='{{:Settings.ClientId}}_lptv' class='gsp_lpalbumtree'></div> {{if App.LatestUrl}}<p class='gsp_lplatest'><a href='{{:App.LatestUrl}}' class='jstree-anchor'><i class='jstree-icon'></i>{{:Resource.LpRecent}}</a></p>{{/if}} {{if App.TopRatedUrl}}<p class='gsp_lptoprated'><a href='{{:App.TopRatedUrl}}' class='jstree-anchor'><i class='jstree-icon'></i>{{:Resource.LpTopRated}}</a></p>{{/if}}"; uiTmpl.HtmlTemplate = uiTmpl.HtmlTemplate.Replace(srcText, replText); } // Task 727: Update jQuery 1.10.2 to 1.11.1. Update jQuery UI 1.10.3 to 1.10.4. var appSetting = ctx.AppSettings.FirstOrDefault(a => a.SettingName == "JQueryScriptPath"); if (appSetting != null && appSetting.SettingValue == "//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js") { appSetting.SettingValue = "//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"; } appSetting = ctx.AppSettings.FirstOrDefault(a => a.SettingName == "JQueryUiScriptPath"); if (appSetting != null && appSetting.SettingValue == "//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js") { appSetting.SettingValue = "//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"; } // Task 722: Now that {MediaObjectUrl} is an absolute URL, remove any instances of {HostUrl} that precede it. // Under default settings this only affects the HTML portion of two video/divx records, but we're making it more // generic to catch any customizations an admin may have done. foreach (var tmpl in ctx.MediaTemplates.Where(mt => mt.HtmlTemplate.Contains("{HostUrl}{MediaObjectUrl}") || mt.ScriptTemplate.Contains("{HostUrl}{MediaObjectUrl}"))) { tmpl.HtmlTemplate = tmpl.HtmlTemplate.Replace("{HostUrl}{MediaObjectUrl}", "{MediaObjectUrl}"); tmpl.ScriptTemplate = tmpl.ScriptTemplate.Replace("{HostUrl}{MediaObjectUrl}", "{MediaObjectUrl}"); } // Update data schema version to 3.2.0 var asDataSchema = ctx.AppSettings.First(a => a.SettingName == "DataSchemaVersion"); asDataSchema.SettingValue = "3.2.0"; ctx.SaveChanges(); // Task 674: Add/update Enterprise UI templates introduced in 3.2.0 var pkRow = ctx.AppSettings.Single(a => a.SettingName == "ProductKey"); if (pkRow.SettingValue == Constants.ProductKeyEnterprise) { SeedController.InsertEnterpriseTemplates(); } }
void OnAnySeedCreate(SeedController seed) { // Maks sure to spawn another seed when this one is gone seed.Gone.AddListener(OnSeedGone); }
public void GenerateRandomAlphaNumericLengthTooLarge() { SeedController.GenerateRandomAlphaNumeric(1000); }