public void AliasNewTest(string scope, AvailableStates affectedState) { AliasInfo info = createAlias("test"); localState.Alias.New(info, scope); Assert.AreEqual(info, states[affectedState].Alias.Get(info.Name)); }
/// <summary> /// Refreshes this instance. /// </summary> public void Refresh() { var configService = ServiceLocator.Current.GetInstance <IConfigurationService>(); ReferenceExists = !IsInitialMapping; CurrentMappingBasis = configService.HospitalRegion; if (SelectedStates != null) { SelectedStates.OfType <SelectListItem>().ToList().ForEach(OnRemoveStateCommand); } RaisePropertyChanged(() => SelectedStates); CurrentMappingBasis.DefaultStates .OfType <string>() .ToList() .ForEach(ab => { var toAdd = AvailableStates.OfType <SelectListItem>().FirstOrDefault(kvp => kvp.Value != null && kvp.Value.ToString().EqualsIgnoreCase(ab)); if (toAdd != null) { AddStateToContext(toAdd); } }); RaisePropertyChanged(() => AvailableStates); SelectedRegionType = CurrentMappingBasis.SelectedRegionType ?? typeof(object); RaisePropertyChanged(() => SelectedRegionType); }
public void DriveNewTest(string scope, AvailableStates affectedState) { PSDriveInfo info = createDrive("test"); localState.Drive.New(info, scope); Assert.AreEqual(info, states[affectedState].Drive.Get(info.Name)); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id is null) { return(NotFound()); } BookCopy = await _context.BookCopies.FirstOrDefaultAsync(m => m.Id == id); if (BookCopy is null) { return(NotFound()); } var tempStates = BookStates.GetBookStates().Where(s => !_context.BookCopies.Any(x => x.BookId == BookCopy.BookId && x.State == s) || s == BookCopy.State).ToList(); foreach (var item in tempStates) { AvailableStates.Add(new SelectListItem { Value = item, Text = item }); } return(Page()); }
private void DetermineAvailableCombatStates(OTGCombatSMC _selectedCombatant) { AvailableStates.Add((OTGCombatState)SObj_InitialState.targetObject); SerializedProperty transitions = SObj_InitialState.FindProperty("m_stateTransitions"); GetStatesFromTransition(transitions); }
/// <summary> /// Adds the state to context. /// </summary> /// <param name="stateKvp">The state KVP.</param> private void AddStateToContext(SelectListItem stateKvp) { SelectedStates.AddNewItem(stateKvp); AvailableStates.Remove(stateKvp); AvailableStates.MoveCurrentToFirst(); SelectedStates.CommitNew(); ApplyContextCommand.RaiseCanExecuteChanged(); }
public void TestExposingStates() { List <string> variables = ExposedVariableManager.GetExposableMembersFor(mEntitySave, false).Select(m => m.Member).ToList(); if (!variables.Contains("CurrentState")) { throw new Exception("ExposedVariableManager is not properly returning the CurrentState as an exposable variable"); } if (!variables.Contains("CurrentStateCategoryState")) { throw new Exception("ExposedVariableManager is not properly returning categorized states as exposable variables"); } // Let's remove uncategorized state to make sure the categorized state is still recognized: StateSave stateSave = mEntitySave.States[0]; mEntitySave.States.RemoveAt(0); variables = ExposedVariableManager.GetExposableMembersFor(mEntitySave, false).Select(m => m.Member).ToList(); if (!variables.Contains("CurrentStateCategoryState")) { throw new Exception("ExposedVariableManager is not properly returning categorized states when there are no uncategorized states."); } // Add it back in case it's needed for other tests. mEntitySave.States.Add(stateSave); variables = ExposedVariableManager.GetExposableMembersFor(mEntityWithCategorizedThatShareVariables, false).Select(m => m.Member).ToList(); if (!variables.Contains("CurrentState")) { throw new Exception("Entities that only have states in categories, but those categories share variables with other categories, are not exposing CurrentState and they should!"); } List <string> listOfStates = new List <string>(); AvailableStates availableStates = new AvailableStates(null, mContainerDerivedEntity, mContainerDerivedEntity.CustomVariables[0], null); availableStates.GetListOfStates(listOfStates, "TunneledStateVariable"); if (listOfStates.Count == 0 || !listOfStates.Contains("StateInCategory1")) { throw new Exception("SetByDerived variables that tunnel in to categorized states do not properly return their list through GetListOfStates"); } ScreenSave screenSave = new ScreenSave(); StateSaveCategory category = new StateSaveCategory(); category.Name = "Whatever"; screenSave.StateCategoryList.Add(category); StateSave stateInScreen = new StateSave(); stateInScreen.Name = "First"; category.States.Add(stateInScreen); variables = ExposedVariableManager.GetExposableMembersFor(screenSave, false).Select(item => item.Member).ToList(); if (variables.Contains("CurrentState") == false) { throw new NotImplementedException("Screens with states that are in categories that share variables are not properly returning the CurrentState as a possible variable"); } }
//setup private void InstantiateStates() { AvailableStates.Add(typeof(UpAndActive), new UpAndActive(this)); AvailableStates.Add(typeof(AirBorne), new AirBorne(this)); AvailableStates.Add(typeof(Tripping), new Tripping(this, GetComponent <Collider2D>())); AvailableStates.Add(typeof(StateClasses.Ratbag.GameplayStates.Floored), new StateClasses.Ratbag.GameplayStates.Floored(this)); AvailableStates.Add(typeof(GettingUp), new GettingUp(this)); AvailableStates.Add(typeof(Spawning), new Spawning(this)); }
public void Cleanup() { SObj_InitialState = null; SProp_InitialState = null; SelectedAnimationClip = null; AvailableStates.Clear(); AvailableStates = null; }
[TestCase(AvailableStates.Local, "s", false)] //makes sure private setting works public void FunctionSetObjectTest(AvailableStates sessionState, object value, bool initLocal = true) { functionState.Function.Set("private:x", null, "f"); localState.Function.Set("global:x", null, "g"); localState.Function.Set("script:x", null, "s"); if (initLocal) { localState.Function.Set("local:x", null, "l"); } Assert.AreEqual(value, states[sessionState].Function.Get("x").Description); }
public void SetViewData(OTGCombatSMC _selectedCombatant, CombatantAnimationView _animView) { AvailableStates.Clear(); DetermineCombatStateObj(_selectedCombatant); DetermineAvailableCombatStates(_selectedCombatant); DetermineSelectedAnimationClip(); _animView.OnSelectionMade(this); }
public void RemoveFilteredState(string state) { if (state == null) { return; } AvailableStates.Add(state); FilteredStates.Remove(state); _statesRepository.SetFilteredStates(FilteredStates.ToArray()); }
public void RemoveResetState(string state) { if (state == null) { return; } AvailableStates.Add(state); ResetStates.Remove(state); _statesRepository.SetResetStates(ResetStates.ToArray()); }
[TestCase(AvailableStates.Local, "s", false)] //makes sure private setting works public void VariableSetTest(AvailableStates sessionState, object value, bool initLocal = true) { functionState.PSVariable.Set("private:x", "f"); localState.PSVariable.Set("global:x", "g"); localState.PSVariable.Set("script:x", "s"); if (initLocal) { localState.PSVariable.Set("local:x", "l"); } Assert.AreEqual(value, states[sessionState].PSVariable.GetValue("x")); }
public override Theme.Controls.Wizard.Helpers.RouteModifier OnNext() { MonahrqContext.CheckIfConnectedToInternet(); var abbvStates = AvailableStates.Where(x => x.IsSelected).Select(x => ((EntityViewModel <State, int>)x.Model).Data).Distinct(); //if (!HospitalRegion.Default.IsDefined) // HospitalRegion.Default.SelectedRegionType = typeof(CustomRegion); // HospitalRegion.Default.DefaultStates = new StringCollection(); //var contextStates = HospitalRegion.Default.SelectedStates.ToList(); var selectedStates = abbvStates as List <State> ?? abbvStates.ToList(); //selectedStates.ForEach(s => // { // //if (contextStates.All(s1 => s1.Abbreviation != s.Abbreviation)) // //{ // // contextStates.Add(s); // //} // }); //HospitalRegion.Default.DefaultStates.AddRange(selectedStates.Select(x => x.Abbreviation).ToArray()); //HospitalRegion.Default.SelectedStates = contextStates.ToList(); //HospitalRegion.Default.Save(); DataContextObject.DatasetItem.File = Title; DataContextObject.DatasetItem.DateImported = DateTime.Now; if (DataContextObject.DatasetItem.IsPersisted) { DataContextObject.DatasetItem.IsFinished = true; } DataContextObject.DatasetItem.ProviderStates = string.Join(",", selectedStates.Select(x => x.Abbreviation).ToArray()); DataContextObject.DatasetItem.UseRealtimeData = PhysicianManagementOption[1] == SelectedManagement; // TODO: we might not need to call Save until the Wizard finishes, but if not, we'll need to set ContentType and CurrentContentItem anyway. DataContextObject.SaveImportEntry(DataContextObject.DatasetItem); DataContextObject.File = new FileProgress { FileName = SelectedFile, LinesDone = 0, PercentComplete = 0, TotalLines = 0, }; DataContextObject.SelectedStates = AvailableStates.Where(x => x.IsSelected).Select(x => x.Value.ToString()).ToList(); DataContextObject.IsPhysicianManagedInMONAHRQ = PhysicianManagementOption[0] == SelectedManagement; return(base.OnNext()); }
private void OnNewAddAdress(MedicalPractice obj) { if (Model == null) { return; } IsEditingAddress = false; SelectedAddress = new MedicalPracticeAddress(); SelectedAddress.State = AvailableStates.Select(state => state).FirstOrDefault(); SelectedAddress.PropertyChanged += (o, e) => SelectedAddress.Validate(); ShowAddressPopup = Visibility.Visible; }
public async Task ReloadStates() { AvailableStates.Clear(); FilteredStates.Clear(); ResetStates.Clear(); var allStates = await GetAllStates(); var filteredStates = _statesRepository.GetFilteredStates(); var resetStates = _statesRepository.GetResetStates(); AvailableStates.AddRange(allStates.Except(filteredStates).Except(resetStates)); FilteredStates.AddRange(filteredStates); ResetStates.AddRange(resetStates); }
public override bool IsValid() { if (string.IsNullOrEmpty(Title) || AvailableStates.All(x => !x.IsSelected) || Title.Length >= 200) { return(false); } if (!MonahrqContext.CheckIfConnectedToInternet()) { return(false); } //if (!SelectedManagement.EqualsIgnoreCase(RealTimeManagement)) return false; return(true); }
public void TestCategories() { List <string> listToFill = new List <string>(); AvailableStates availableStates = new AvailableStates( null, mEntitySave, mExposedStateVariable, null); listToFill.Clear(); availableStates.GetListOfStates(listToFill, mDerivedEntitySave.CustomVariables[0].Name); if (listToFill.Contains("SharedStateSave") == false) { throw new Exception("GetListOfStates is not returnign states that are categorized but that share variables with others."); } }
private void GetStatesFromTransition(SerializedProperty _currentTransitions) { if (_currentTransitions == null || _currentTransitions.arraySize == 0) { return; } int amountOfTransitions = _currentTransitions.arraySize; for (int i = 0; i < amountOfTransitions; i++) { SerializedProperty nextStateProp = _currentTransitions.GetArrayElementAtIndex(i).FindPropertyRelative("m_nextState"); OTGCombatState nextState = (OTGCombatState)nextStateProp.objectReferenceValue; if (nextState != null && !AvailableStates.Contains(nextState)) { SerializedObject stateSOBJ = new SerializedObject(nextState); GetStatesFromTransition(stateSOBJ.FindProperty("m_stateTransitions")); AvailableStates.Add(nextState); } } }
public void AliasRemoveTest(string scope, AvailableStates affectedState) { Dictionary <AvailableStates, AliasInfo> aliasInfos = new Dictionary <AvailableStates, AliasInfo>(); foreach (var curState in states) { var info = createAlias(curState.Key.ToString()); curState.Value.Alias.New(info, "local"); aliasInfos[curState.Key] = info; } localState.Alias.Remove(aliasInfos[affectedState].Name, scope); foreach (var curState in states) { if (curState.Key == affectedState) { Assert.AreEqual(0, curState.Value.Alias.GetAllLocal().Count); } else { Assert.AreEqual(aliasInfos[curState.Key], curState.Value.Alias.Get(aliasInfos[curState.Key].Name)); } } }
[TestCase("x", AvailableStates.Function, false)] //looks in parent scopes and removes the variable public void FunctionRemoveTest(string variable, AvailableStates affectedState, bool initLocal) { globalState.Function.Set("x", null, "g"); scriptState.Function.Set("x", null, "s"); functionState.Function.Set("x", null, "f"); if (initLocal) { localState.Function.Set("x", null, "l"); } localState.Function.Remove(variable); foreach (KeyValuePair <AvailableStates, SessionState> curState in states) { if (curState.Key == affectedState || (curState.Key == AvailableStates.Local && !initLocal)) { Assert.IsNull(curState.Value.Function.Get("local:x")); } else { Assert.IsNotNull(curState.Value.Function.Get("local:x")); } } }
public void DriveRemoveTest(string scope, AvailableStates affectedState) { Dictionary <AvailableStates, PSDriveInfo> driveInfos = new Dictionary <AvailableStates, PSDriveInfo>(); foreach (var curState in states) { var info = createDrive(curState.Key.ToString()); curState.Value.Drive.New(info, "local"); driveInfos[curState.Key] = info; } localState.Drive.Remove(driveInfos[affectedState].Name, true, scope); foreach (var curState in states) { if (curState.Key == affectedState) { Assert.AreEqual(0, curState.Value.Drive.GetAllAtScope("local").Count); } else { Assert.AreEqual(driveInfos[curState.Key], curState.Value.Drive.Get(driveInfos[curState.Key].Name)); } } }
public void DriveRemoveTest(string scope, AvailableStates affectedState) { Dictionary<AvailableStates, PSDriveInfo> driveInfos = new Dictionary<AvailableStates, PSDriveInfo>(); foreach (var curState in states) { var info = createDrive(curState.Key.ToString()); curState.Value.Drive.New(info, "local"); driveInfos[curState.Key] = info; } localState.Drive.Remove(driveInfos[affectedState].Name, true, scope); foreach (var curState in states) { if (curState.Key == affectedState) { Assert.AreEqual(0, curState.Value.Drive.GetAllAtScope("local").Count); } else { Assert.AreEqual(driveInfos[curState.Key], curState.Value.Drive.Get(driveInfos[curState.Key].Name)); } } }
public static TypeConverter GetTypeConverter(this CustomVariable customVariable, IElement containingElement, StateSave stateSave, FlatRedBall.Glue.Plugins.ExportedInterfaces.IGlueState glueState) { TypeConverter typeConverter = null; if (customVariable.GetIsVariableState()) { typeConverter = new AvailableStates( FacadeContainer.Self.GlueState.CurrentNamedObjectSave, FacadeContainer.Self.GlueState.CurrentElement, FacadeContainer.Self.GlueState.CurrentCustomVariable, FacadeContainer.Self.GlueState.CurrentStateSave ); } else { Type runtimeType = customVariable.GetRuntimeType(); if (runtimeType != null) { if (runtimeType.IsEnum) { typeConverter = new EnumConverter(runtimeType); } else if (runtimeType == typeof(Color)) { return(new AvailableColorTypeConverter()); } else if ((runtimeType == typeof(string) || runtimeType == typeof(AnimationChainList)) && customVariable.SourceObjectProperty == "CurrentChainName") { typeConverter = new AvailableAnimationChainsStringConverter(customVariable, stateSave); } else if (customVariable.GetIsFile()) { AvailableFileStringConverter converter = new AvailableFileStringConverter(containingElement); converter.QualifiedRuntimeTypeName = runtimeType.FullName; converter.ShowNewFileOption = false; converter.RemovePathAndExtension = true; typeConverter = converter; } } else if (customVariable.GetIsCsv()) { if (FacadeContainer.Self.ProjectValues == null) { throw new NullReferenceException("The ProjectValues property in FAcadeContainer.Self.ProjectValues must be set before trying to get the CSV type converter for the variable " + customVariable.ToString()); } ReferencedFileSave rfs = ObjectFinder.Self.GetAllReferencedFiles().FirstOrDefault(item => item.IsCsvOrTreatedAsCsv && item.GetTypeForCsvFile() == customVariable.Type); AvailableSpreadsheetValueTypeConverter converter = null; if (rfs != null) { converter = new AvailableSpreadsheetValueTypeConverter( FacadeContainer.Self.ProjectValues.ContentDirectory + rfs.Name, containingElement); } else { converter = new AvailableSpreadsheetValueTypeConverter( FacadeContainer.Self.ProjectValues.ContentDirectory + customVariable.Type, containingElement); } converter.ShouldAppendFileName = true; typeConverter = converter; } else if (customVariable.GetIsFile()) { // If we got here, that means that the // CustomVariable is a file, but it doesn't // have a System.Type, so it only knows its runtime // type; AvailableFileStringConverter converter = new AvailableFileStringConverter(containingElement); converter.UnqualifiedRuntimeTypeName = customVariable.Type; converter.ShowNewFileOption = false; converter.RemovePathAndExtension = true; typeConverter = converter; } } return(typeConverter); }
[TestCase(AvailableStates.Local, true)] //can see the non-private public void AliasExistsTest(AvailableStates affectedState, bool exists) { globalState.Alias.New(createAlias("test", "", ScopedItemOptions.Private), "local"); functionState.Alias.New(createAlias("test", ""), "local"); Assert.AreEqual(exists, states[affectedState].Alias.Exists("test")); }
/// <summary> /// Called when [imports satisfied]. /// </summary> public override void OnImportsSatisfied() { base.OnImportsSatisfied(); CurrentMappingBasis = ConfigurationService.HospitalRegion; ReferenceExists = !IsInitialMapping; AddStateToContextCommand = new DelegateCommand(OnAddState, CanAddState); RemoveStateFromContextCommand = new DelegateCommand <SelectListItem>(OnRemoveStateCommand, CanRemoveState); ApplyContextCommand = new DelegateCommand(OnApplyContextCommand, CanApplyContextCommand); NavigateBackCommand = new DelegateCommand(OnNavigateBackCommand); SelectedStates = CollectionHelper.EmptyListCollectionView <SelectListItem>(); var crit = PredicateBuilder.True <State>(); ListExtensions.ForEach(CurrentMappingBasis.DefaultStates.OfType <string>().ToList(), ab => crit = crit.And(st => st.Abbreviation != ab)); var availStates = new List <SelectListItem>(); availStates.Add(SELECT_STATE); var allStates = HospitalRegistryService.GetStates(null).ToList(); availStates.AddRange(allStates.AsQueryable() .Where(crit) .Select(state => new SelectListItem { Model = state, Text = state.Abbreviation, Value = state.Abbreviation }) //.Concat(new[] { SELECT_STATE }) .OrderBy(item => item.Text).ToList()); AvailableStates = availStates.ToListCollectionView(); crit = PredicateBuilder.False <State>(); ListExtensions.ForEach(CurrentMappingBasis.DefaultStates .OfType <string>(), ab => crit = crit.Or(st => st.Abbreviation == ab)); var selectedStates = allStates.AsQueryable().Where(crit).Select(st => new SelectListItem { Text = st.Abbreviation, Value = st.Abbreviation, Model = st }).ToList(); // Setting the Selected Reporting States for Global use. //if (!MonahrqContext.ReportingStatesContext.Any(s => selectedStates.Any(s1 => s.In(s1)) )) // MonahrqContext.ReportingStatesContext.AddRange(selectedStates); MonahrqContext.ReportingStatesContext.AddRange(selectedStates.Select(s => s.Text).ToList()); SelectedStates = selectedStates.ToListCollectionView(); SelectedStates.CommitNew(); AvailableStates.CommitEdit(); AvailableStates.MoveCurrentToFirst(); SelectedState = SELECT_STATE; // Regions for combo box, Object type return "SELECT" on display, and NULL on return using RegionTypes = (new[] { typeof(object), typeof(CustomRegion), typeof(HealthReferralRegion), typeof(HospitalServiceArea) }).ToListCollectionView(); SelectedRegionType = CurrentMappingBasis.SelectedRegionType; }
[TestCase(AvailableStates.Local, "s", false)] //makes sure private setting works public void VariableSetTest(AvailableStates sessionState, object value, bool initLocal=true) { functionState.PSVariable.Set("private:x", "f"); localState.PSVariable.Set("global:x", "g"); localState.PSVariable.Set("script:x", "s"); if (initLocal) { localState.PSVariable.Set ("local:x", "l"); } Assert.AreEqual(value, states[sessionState].PSVariable.GetValue("x")); }
/// <summary> /// Determines whether this instance [can add state]. /// </summary> /// <returns> /// <c>true</c> if this instance [can add state]; otherwise, <c>false</c>. /// </returns> private bool CanAddState() { var selectStateBlank = AvailableStates.GetItemAt(0); return(SelectedState != null && selectStateBlank != null && !SelectedState.Equals(selectStateBlank)); }
[TestCase(AvailableStates.Local, "s", false)] //makes sure private setting works public void FunctionSetObjectTest(AvailableStates sessionState, object value, bool initLocal=true) { functionState.Function.Set("private:x", null, "f"); localState.Function.Set("global:x", null, "g"); localState.Function.Set("script:x", null, "s"); if (initLocal) { localState.Function.Set ("local:x", null, "l"); } Assert.AreEqual(value, states[sessionState].Function.Get("x").Description); }
public void DriveNewTest(string scope, AvailableStates affectedState) { PSDriveInfo info = createDrive("test"); localState.Drive.New (info, scope); Assert.AreEqual(info, states[affectedState].Drive.Get(info.Name)); }
public void Test() { AvailableStates availableStates = new AvailableStates( null, mEntitySave, mExposedStateInCategoryVariable, null); List <string> listToFill = new List <string>(); availableStates.CurrentCustomVariable = mExposedStateVariable; listToFill.Clear(); availableStates.GetListOfStates(listToFill, null); if (listToFill.Count != NumberOfUncategorizedAndSharedStates(mEntitySave) + 1 || listToFill[1] != "Uncategorized") { throw new Exception("GetListOfStates isn't properly filtering out categorized states"); } listToFill.Clear(); availableStates.CurrentCustomVariable = mExposedStateInCategoryVariable; availableStates.GetListOfStates(listToFill, null); if (listToFill.Count != 2 || listToFill[1] != "StateInCategory1") { throw new Exception("GetListOfStates isn't properly filtering out uncategorized states"); } // Test getting states for variables that don't use the "CurrentWhatever" naming in categories listToFill.Clear(); availableStates.CurrentElement = mContainerEntitySave; availableStates.CurrentNamedObject = mEntitySaveInstance; availableStates.CurrentCustomVariable = null; availableStates.GetListOfStates(listToFill, mRenamedExposedCategorizedStateVariable.Name); if (listToFill.Contains("StateInCategory1") == false) { throw new Exception("GetListOfStates doesn't work properly on states that are categorized and have variables that don't follow the typical CurrentWhatever naming."); } // Test getting states for variables that don't use the "CurrentWhatever" naming in categories, and are accessed through inheritance listToFill.Clear(); availableStates.CurrentElement = mContainerEntitySave; availableStates.CurrentNamedObject = mDerivedSaveInstance; availableStates.CurrentCustomVariable = null; availableStates.GetListOfStates(listToFill, mRenamedExposedUncategorizedStateVariable.Name); if (listToFill.Count != mEntitySave.States.Count + 1) { throw new Exception("GetListOfStates on NOS's that are derived doesn't seem to work properly"); } listToFill.Clear(); availableStates.CurrentElement = mContainerEntitySave; availableStates.CurrentCustomVariable = null; availableStates.CurrentNamedObject = mEntitySaveInstance; availableStates.GetListOfStates(listToFill, "CurrentState"); if (listToFill.Count != NumberOfUncategorizedAndSharedStates(mEntitySave) + 1 || listToFill[1] != "Uncategorized") // will include "<NONE>" { throw new Exception("GetListOfStates isn't properly filtering out categorized states"); } // Test getting states for a variable that doesn't use the typical "CurrentWhatever" naming on uncategorized listToFill.Clear(); availableStates.CurrentElement = mContainerEntitySave; availableStates.CurrentCustomVariable = null; availableStates.CurrentNamedObject = mEntitySaveInstance; availableStates.GetListOfStates(listToFill, mRenamedExposedUncategorizedStateVariable.Name); if (listToFill.Count != NumberOfUncategorizedAndSharedStates(mEntitySave) + 1 || listToFill[1] != "Uncategorized") // will include "<NONE>" { throw new Exception("GetListOfStates isn't properly filtering out categorized states"); } // Test getting states for a tunneled variable that doesn't use the typical "CurrentWhatever" naming on uncategorized listToFill.Clear(); availableStates.CurrentElement = mContainerEntitySave; availableStates.CurrentCustomVariable = mTunneledUncategorizedStateInContainer; availableStates.CurrentNamedObject = null; availableStates.GetListOfStates(listToFill, mRenamedExposedUncategorizedStateVariable.Name); if (listToFill.Count != NumberOfUncategorizedAndSharedStates(mEntitySave) + 1 || listToFill[1] != "Uncategorized") // will include "<NONE>" { throw new Exception("GetListOfStates isn't properly filtering out categorized states"); } listToFill.Clear(); availableStates.CurrentElement = mContainerEntitySave; availableStates.CurrentNamedObject = mEntitySaveInstance; availableStates.CurrentCustomVariable = null; availableStates.GetListOfStates(listToFill, "CurrentStateCategoryState"); if (listToFill.Count != 2 || listToFill[1] != "StateInCategory1") { throw new Exception("GetListOfStates isn't properly filtering out uncategorized states"); } string whyItIsntValid; if (NameVerifier.IsStateNameValid("Color", null, null, null, out whyItIsntValid)) { throw new Exception("The state name Color should not be a valid name, but Glue allows it"); } listToFill.Clear(); availableStates.CurrentElement = mDerivedEntitySave; availableStates.CurrentCustomVariable = mDerivedEntitySave.CustomVariables[0]; availableStates.CurrentNamedObject = null; availableStates.GetListOfStates(listToFill, mDerivedEntitySave.CustomVariables[0].Name); if (listToFill.Count == 0 || listToFill[1] != "Uncategorized") { throw new Exception("GetListOfStates is not properly finding uncategorized states defined in a base type"); } listToFill.Clear(); availableStates.CurrentElement = mDerivedEntitySave; availableStates.CurrentCustomVariable = mDerivedEntitySave.CustomVariables[1]; availableStates.CurrentNamedObject = null; availableStates.GetListOfStates(listToFill, mDerivedEntitySave.CustomVariables[1].Name); if (listToFill.Count == 0 || listToFill[1] != "StateInCategory1") { throw new Exception("GetListOfStates is not properly finding categorized states defined in a base type"); } // Test CurrentState variable tate in the Container listToFill.Clear(); availableStates.CurrentElement = mContainerEntitySave; availableStates.CurrentCustomVariable = null; availableStates.CurrentStateSave = null; availableStates.CurrentNamedObject = mDerivedSaveInstance; availableStates.GetListOfStates(listToFill, "CurrentState"); if (listToFill.Count != mEntitySave.States.Count + 1) { throw new Exception("Getting state on NamedObject that is of a derived type that gets its state from the base type is not working properly"); } ////Test adding same name with shared category //Test shared vs shared var sharedCategoryElement = new EntitySave(); string outString; sharedCategoryElement.StateCategoryList.Add(new StateSaveCategory { Name = "First", SharesVariablesWithOtherCategories = true }); sharedCategoryElement.StateCategoryList[0].States.Add(new StateSave { Name = "State1" }); sharedCategoryElement.StateCategoryList.Add(new StateSaveCategory { Name = "Second", SharesVariablesWithOtherCategories = true }); if (NameVerifier.IsStateNameValid("State1", sharedCategoryElement, sharedCategoryElement.StateCategoryList[1], null, out outString)) { throw new Exception("Should not allow adding same state name between shared categories."); } //Test shared vs main sharedCategoryElement = new EntitySave(); sharedCategoryElement.StateCategoryList.Add(new StateSaveCategory { Name = "First", SharesVariablesWithOtherCategories = true }); sharedCategoryElement.StateCategoryList[0].States.Add(new StateSave { Name = "State1" }); if (NameVerifier.IsStateNameValid("State1", sharedCategoryElement, null, null, out outString)) { throw new Exception("Should not allow adding same state name in main when exists in shared categories."); } //Test main vs shared sharedCategoryElement = new EntitySave(); sharedCategoryElement.States.Add(new StateSave { Name = "State1" }); sharedCategoryElement.StateCategoryList.Add(new StateSaveCategory { Name = "First", SharesVariablesWithOtherCategories = true }); if (NameVerifier.IsStateNameValid("State1", sharedCategoryElement, sharedCategoryElement.StateCategoryList[0], null, out outString)) { throw new Exception("Should not allow adding same state name in shared category when exists in main states."); } }
[TestCase("x", AvailableStates.Function, false)] //looks in parent scopes and removes the variable public void FunctionRemoveTest(string variable, AvailableStates affectedState, bool initLocal) { globalState.Function.Set("x", null, "g"); scriptState.Function.Set("x", null, "s"); functionState.Function.Set("x", null, "f"); if (initLocal) { localState.Function.Set("x", null, "l"); } localState.Function.Remove(variable); foreach (KeyValuePair<AvailableStates, SessionState> curState in states) { if (curState.Key == affectedState || (curState.Key == AvailableStates.Local && !initLocal)) { Assert.IsNull(curState.Value.Function.Get("local:x")); } else { Assert.IsNotNull(curState.Value.Function.Get("local:x")); } } }
public void AliasRemoveTest(string scope, AvailableStates affectedState) { Dictionary<AvailableStates, AliasInfo> aliasInfos = new Dictionary<AvailableStates, AliasInfo>(); foreach (var curState in states) { var info = createAlias(curState.Key.ToString()); curState.Value.Alias.New(info, "local"); aliasInfos[curState.Key] = info; } localState.Alias.Remove(aliasInfos[affectedState].Name, scope); foreach (var curState in states) { if (curState.Key == affectedState) { Assert.AreEqual(0, curState.Value.Alias.GetAllLocal().Count); } else { Assert.AreEqual(aliasInfos[curState.Key], curState.Value.Alias.Get(aliasInfos[curState.Key].Name)); } } }