public RoleValidatorTests() { context = TestingContext.Create(); validator = new RoleValidator(new UnitOfWork(TestingContext.Create())); context.Drop().Add(role = ObjectsFactory.CreateRole(0)); context.SaveChanges(); }
public void CanEdit_Profile_ToSameUsername() { ProfileEditView view = ObjectsFactory.CreateProfileEditView(account.Id + 1); view.Username = account.Username.ToUpper(); Assert.True(validator.CanEdit(view)); }
public void CanLogin_IsCaseInsensitive() { AccountLoginView view = ObjectsFactory.CreateAccountLoginView(); view.Username = view.Username?.ToUpper(); Assert.True(validator.CanLogin(view)); }
public UnitOfWorkTests() { context = TestingContext.Create(); model = ObjectsFactory.CreateRole(0); unitOfWork = new UnitOfWork(context, TestingContext.Mapper); context.Drop(); }
public void CanLogin_InvalidState_ReturnsFalse() { validator.ModelState.AddModelError("Test", "Test"); Assert.False(validator.CanLogin(ObjectsFactory.CreateAccountLoginView(0))); Assert.Single(validator.ModelState); Assert.Empty(validator.Alerts); }
public void CanEdit_Account_ToSameUsername() { AccountEditView view = ObjectsFactory.CreateAccountEditView(); view.Username = account.Username.ToUpper(); Assert.True(validator.CanEdit(view)); }
public void CanDelete_InvalidState_ReturnsFalse() { validator.ModelState.AddModelError("Test", "Test"); Assert.False(validator.CanDelete(ObjectsFactory.CreateProfileDeleteView(account.Id))); Assert.Single(validator.ModelState); Assert.Empty(validator.Alerts); }
public void CanEdit_Profile_ToSameEmail() { ProfileEditView view = ObjectsFactory.CreateProfileEditView(account.Id); view.Email = account.Email.ToUpper(); Assert.True(validator.CanEdit(view)); }
public void CanEdit_Account_ToSameEmail() { AccountEditView view = ObjectsFactory.CreateAccountEditView(); view.Email = account.Email.ToUpper(); Assert.True(validator.CanEdit(view)); }
public void Recover_NoEmail_ReturnsNull() { AccountRecoveryView view = ObjectsFactory.CreateAccountRecoveryView(); view.Email = "*****@*****.**"; Assert.Null(service.Recover(view)); }
public void CanEdit_InvalidState_ReturnsFalse() { validator.ModelState.AddModelError("Test", "Test"); Assert.False(validator.CanEdit(ObjectsFactory.CreateRoleView(role.Id + 1))); Assert.Single(validator.ModelState); Assert.Empty(validator.Alerts); }
/// <summary> /// Chargement des items /// </summary> /// <param name="item1"></param> /// <param name="item2"></param> private void LoadItem(Guid item1, Guid item2) { Cursor.Current = Cursors.WaitCursor; //Code de chargement if (item1 != new Guid()) { CurrentItem1 = GameCore.Instance.GetItemById(item1); } if (item2 != new Guid()) { CurrentItem2 = GameCore.Instance.GetItemById(item2); } if (CurrentItem1.Id != new Guid() && CurrentItem2.Id != new Guid() && CurrentItem1.Id != CurrentItem2.Id) { //Afficher les groupes grpCommands.Visible = true; //Récupération des données du script ou création si nécessaire. VO_Script script = null; VO_ItemInteraction itemInteraction = CurrentItem1.ItemInteraction.Find(p => p.AssociatedItem == CurrentItem2.Id); if (itemInteraction == null) { script = ObjectsFactory.CreateScript(true, Enums.ScriptType.ItemEvents); VO_ItemInteraction itemInteraction1 = new VO_ItemInteraction(); itemInteraction1.AssociatedItem = CurrentItem2.Id; itemInteraction1.Script = script.Id; CurrentItem1.ItemInteraction.Add(itemInteraction1); VO_ItemInteraction itemInteraction2 = new VO_ItemInteraction(); itemInteraction2.AssociatedItem = CurrentItem1.Id; itemInteraction2.Script = script.Id; CurrentItem2.ItemInteraction.Add(itemInteraction2); } else { script = GameCore.Instance.GetInteractionScriptsById(itemInteraction.Script); if (script == null) { script = ObjectsFactory.CreateScript(true, Enums.ScriptType.ItemEvents); itemInteraction.Script = script.Id; VO_ItemInteraction itemInteraction2 = CurrentItem2.ItemInteraction.Find(p => p.AssociatedItem == CurrentItem1.Id); itemInteraction2.Script = script.Id; } } //Chargement du script _LoadedScript = script; ScriptManager.LoadScript(script); } else { grpCommands.Visible = false; } Cursor.Current = DefaultCursor; }
public void StartExplosion() { ObjectsFactory generator = new ObjectsFactory(); GameObject explosion = generator.GetProjectile(WeaponType.Explosion); explosion.transform.position = //transform.position; new Vector3(transform.position.x, transform.position.y, explosion.transform.position.z); Destroy(gameObject); }
public QueryTests() { context = new TestingContext(); select = new Query <TestModel>(context.Set <TestModel>()); context.RemoveRange(context.Set <TestModel>()); context.Add(ObjectsFactory.CreateTestModel()); context.SaveChanges(); }
public AuditedUnitOfWorkTests() { context = TestingContext.Create(); model = ObjectsFactory.CreateRole(0); unitOfWork = new AuditedUnitOfWork(context, 1); context.Drop().Add(model); context.SaveChanges(); }
public AuditLoggerTests() { context = new TestingContext(); logger = new AuditLogger(context, 1); TestingContext dataContext = new TestingContext(); TestModel model = ObjectsFactory.CreateTestModel(); entry = dataContext.Entry <BaseModel>(dataContext.Add(model).Entity); dataContext.SaveChanges(); }
public AccountValidatorTests() { context = TestingContext.Create(); hasher = Substitute.For <IHasher>(); hasher.VerifyPassword(Arg.Any <String>(), Arg.Any <String>()).Returns(true); validator = new AccountValidator(new UnitOfWork(TestingContext.Create(), TestingContext.Mapper), hasher); context.Drop().Add(account = ObjectsFactory.CreateAccount(0)); context.SaveChanges(); }
public void MapRoles_RoleView_Role() { RoleView expected = ObjectsFactory.CreateRoleView(); Role actual = Mapper.Map <Role>(expected); Assert.Equal(expected.CreationDate, actual.CreationDate); Assert.Equal(expected.Title, actual.Title); Assert.Equal(expected.Id, actual.Id); Assert.Empty(actual.Permissions); }
public void CreateTableSetWithNullTableNameParameter() { CloudTableClient tableClient = ObjectsFactory.GetCloudTableClient(); TableSet <Country> context = null; // Act && Assert Assert.Throws <ArgumentNullException>(() => { context = new TableSet <Country>(tableClient, null); }); Assert.Null(context); }
/// <summary> /// Création d'un projet /// </summary> /// <param name="pProject">VO_Project</param> public void CreateProject(VO_Project project) { //Nouvelles données projet. GameCore.Instance.ResetGameCore(); GameCore.Instance.Game.Project = project; GameCore.Instance.Game.Project.ProjectFileName = project.Title; GameCore.Instance.Game.Project.Version = GlobalConstants.PROJECT_VERSION; GameCore.Instance.Game.Project.BetaVersion = GlobalConstants.BETA_VERSION; GameCore.Instance.Game.Project.RootPath = project.RootPath += "\\" + ValidationTools.NormalizeFolderName(project.Title) + "\\"; GameCore.Instance.Game.Project.MovementDirections = 4; //Création des dossiers du projet Directory.CreateDirectory(project.RootPath + GlobalConstants.PROJECT_DIR_MANUALS); Directory.CreateDirectory(project.RootPath + GlobalConstants.PROJECT_DIR_RESOURCES); Directory.CreateDirectory(project.RootPath + GlobalConstants.PROJECT_DIR_RESOURCES + "\\" + GlobalConstants.PROJECT_DIR_ANIMATIONS); Directory.CreateDirectory(project.RootPath + GlobalConstants.PROJECT_DIR_RESOURCES + "\\" + GlobalConstants.PROJECT_DIR_ANIMATIONS + "\\" + GlobalConstants.PROJECT_DIR_CHARACTERANIMATIONS); Directory.CreateDirectory(project.RootPath + GlobalConstants.PROJECT_DIR_RESOURCES + "\\" + GlobalConstants.PROJECT_DIR_ANIMATIONS + "\\" + GlobalConstants.PROJECT_DIR_CHARACTERFACES); Directory.CreateDirectory(project.RootPath + GlobalConstants.PROJECT_DIR_RESOURCES + "\\" + GlobalConstants.PROJECT_DIR_ANIMATIONS + "\\" + GlobalConstants.PROJECT_DIR_ICONS); Directory.CreateDirectory(project.RootPath + GlobalConstants.PROJECT_DIR_RESOURCES + "\\" + GlobalConstants.PROJECT_DIR_ANIMATIONS + "\\" + GlobalConstants.PROJECT_DIR_MENUS); Directory.CreateDirectory(project.RootPath + GlobalConstants.PROJECT_DIR_RESOURCES + "\\" + GlobalConstants.PROJECT_DIR_ANIMATIONS + "\\" + GlobalConstants.PROJECT_DIR_OBJECTANIMATIONS); Directory.CreateDirectory(project.RootPath + GlobalConstants.PROJECT_DIR_RESOURCES + "\\" + GlobalConstants.PROJECT_DIR_DECORS); //Directory.CreateDirectory(project.RootPath + GlobalConstants.PROJECT_DIR_RESOURCES + "\\" + GlobalConstants.PROJECT_DIR_FONTS); Directory.CreateDirectory(project.RootPath + GlobalConstants.PROJECT_DIR_RESOURCES + "\\" + GlobalConstants.PROJECT_DIR_LIFEBAR); Directory.CreateDirectory(project.RootPath + GlobalConstants.PROJECT_DIR_RESOURCES + "\\" + GlobalConstants.PROJECT_DIR_MUSICS); Directory.CreateDirectory(project.RootPath + GlobalConstants.PROJECT_DIR_RESOURCES + "\\" + GlobalConstants.PROJECT_DIR_SOUNDS); Directory.CreateDirectory(project.RootPath + GlobalConstants.PROJECT_DIR_RESOURCES + "\\" + GlobalConstants.PROJECT_DIR_SOUNDS + "\\" + GlobalConstants.PROJECT_DIR_VOICES); Directory.CreateDirectory(project.RootPath + GlobalConstants.PROJECT_DIR_RESOURCES + "\\" + GlobalConstants.PROJECT_DIR_SOUNDS + "\\" + GlobalConstants.PROJECT_DIR_EFFECTS); Directory.CreateDirectory(project.RootPath + GlobalConstants.PROJECT_DIR_RESOURCES + "\\" + GlobalConstants.PROJECT_DIR_GUIS); project.GameOverMusic = new VO_Music(); project.MainMenuMusic = new VO_Music(); project.GameOver = ObjectsFactory.CreateScript(Enums.ScriptType.GameOverEvent); //Création de Map de base. EditorHelper.Instance.LastOrdinalLayer = 0; project.GameOver = ObjectsFactory.CreateScript(Enums.ScriptType.GameOverEvent); //Création de l'action "Aller" VO_Action go = ObjectsFactory.CreateAction(new Guid(GlobalConstants.ACTION_GO_ID)); go.Title = GlobalConstants.ACTION_GO; go.GoAction = true; //Création de l'action "Utiliser" VO_Action use = ObjectsFactory.CreateAction(new Guid(GlobalConstants.ACTION_USE_ID)); use.Title = GlobalConstants.ACTION_USE; use.UseAction = true; //Création des menus ObjectsFactory.CreateMenu(); //Terminology ObjectsFactory.CreateTerminology(); }
public void Seed_LeafsWithId() { RoleView view = ObjectsFactory.CreateRoleView(role.Id + 1); service.Seed(view.Permissions); IEnumerable <MvcTreeNode> actual = GetLeafNodes(view.Permissions.Nodes); Assert.Empty(actual.Where(leaf => leaf.Id == null)); Assert.Equal(4, actual.Count()); }
public RolesTests() { role = ObjectsFactory.CreateRoleView(0); service = Substitute.For <IRoleService>(); validator = Substitute.For <IRoleValidator>(); controller = Substitute.ForPartsOf <Roles>(validator, service); controller.ControllerContext.HttpContext = new DefaultHttpContext(); controller.Authorization.Returns(Substitute.For <IAuthorization>()); controller.ControllerContext.RouteData = new RouteData(); }
public void MapRoles_Role_RoleView() { Role expected = ObjectsFactory.CreateRole(0); RoleView actual = Mapper.Map <RoleView>(expected); Assert.Equal(expected.CreationDate, actual.CreationDate); Assert.Empty(actual.Permissions.SelectedIds); Assert.Equal(expected.Title, actual.Title); Assert.Empty(actual.Permissions.Nodes); Assert.Equal(expected.Id, actual.Id); }
public LoggableEntityTests() { using (context = TestingContext.Create()) { context.Drop().Add(model = ObjectsFactory.CreateRole(0)); context.SaveChanges(); } context = TestingContext.Create(); entry = context.Entry<AModel>(model); }
public AccountServiceTests() { context = TestingContext.Create(); hasher = Substitute.For <IHasher>(); httpContext = new DefaultHttpContext(); service = new AccountService(new UnitOfWork(TestingContext.Create(), TestingContext.Mapper), hasher); hasher.HashPassword(Arg.Any <String>()).Returns(info => $"{info.Arg<String>()}Hashed"); context.Drop().Add(account = ObjectsFactory.CreateAccount(0)); context.SaveChanges(); }
public LoggableEntityTests() { using (context = new TestingContext()) { context.Add(model = ObjectsFactory.CreateTestModel()); context.SaveChanges(); } context = new TestingContext(context); entry = context.Entry <BaseModel>(model); }
public void Seed_BranchesWithoutId() { RoleView view = ObjectsFactory.CreateRoleView(role.Id + 1); service.Seed(view.Permissions); IEnumerable <MvcTreeNode> nodes = view.Permissions.Nodes; IEnumerable <MvcTreeNode> branches = GetBranchNodes(nodes); Assert.Empty(branches.Where(branch => branch.Id != null)); }
public void Seed_LeafsWithId() { RoleView view = ObjectsFactory.CreateRoleView(role.Id + 1); service.Seed(view.Permissions); IEnumerable <MvcTreeNode> nodes = view.Permissions.Nodes; IEnumerable <MvcTreeNode> leafs = GetLeafNodes(nodes); Assert.Empty(leafs.Where(leaf => leaf.Id == null)); }
public void Create_Role() { RoleView view = ObjectsFactory.CreateRoleView(role.Id + 1); service.Create(view); Role actual = Assert.Single(context.Set <Role>(), model => model.Id != role.Id); RoleView expected = view; Assert.Equal(expected.CreationDate, actual.CreationDate); Assert.Equal(expected.Title, actual.Title); }
public void DeleteRange_Models() { IEnumerable <Role> models = new[] { ObjectsFactory.CreateRole(2), ObjectsFactory.CreateRole(3) }; context.AddRange(models); context.SaveChanges(); unitOfWork.DeleteRange(models); unitOfWork.Commit(); Assert.Empty(context.Set <Role>()); }