public void ManyValues(LightDictionary<int, string> sut) { for (int i = 0; i < 100000; i++) sut[i] = i.ToString(); for (int i = 0; i < 100000; i++) Assert.Equal(i.ToString(), sut[i]); }
public void LightDictionary_Generic_Constructor_IDictionary(int count) { IDictionary <TKey, TValue> source = GenericIDictionaryFactory(count); IDictionary <TKey, TValue> copied = new LightDictionary <TKey, TValue>(source); Assert.Equal(source, copied); }
public static FormMain CreateForm(IDatabaseCoordinator coordinator, ByteHolder holder, OrdinaryDifferentialEquations.IDifferentialEquationSolver ordSolver, DataPerformer.Portable.DifferentialEquationProcessors.DifferentialEquationProcessor diffProcessor, DataPerformer.Portable.Interfaces.IDataRuntimeFactory strategy, IApplicationInitializer[] initializers, IUIFactory[] factories, bool throwsRepeatException, LightDictionary <string, ButtonWrapper[]> buttons, Icon icon, string filename, Dictionary <string, object>[] resources, string text, string ext, string fileFilter, TextWriter logWriter, TestCategory.Interfaces.ITestInterface testInterface) { EngineeringUIFactory factory = new EngineeringUIFactory(factories, true, ext); StaticExtensionDiagramUIFactory.UIFactory = factory; IDatabaseCoordinator c = coordinator; if (c == null) { c = AssemblyService.StaticExtensionAssemblyService.GetFirstInterfaceObjectFromBaseDirectory <IDatabaseCoordinator>(); } EngineeringInitializer initializer = new EngineeringInitializer(c, ordSolver, diffProcessor, strategy, initializers, throwsRepeatException, resources, logWriter); DefaultApplicationCreator creator = new DefaultApplicationCreator(c, buttons, icon, factory, holder, filename, factory.Start, resources, text, ext, fileFilter, initializer, logWriter, testInterface); return(CreateForm(creator)); }
/// <summary> /// Creates application form without 3D shapes /// </summary> /// <param name="coordinator">Database coordinator</param> /// <param name="holder">byte holder for editor of proprerties</param> /// <param name="ordSolver">Ordinary differential equations solver</param> /// <param name="diffProcessor">Ordinary differential equations processor</param> /// <param name="initializers">Array of initializers</param> /// <param name="factories">UI Factotries</param> /// <param name="throwsRepeatException">The "throw exception for repeat" sign</param> /// <param name="buttons">Palette buttons</param> /// <param name="icon">Form icon</param> /// <param name="filename">File name</param> /// <param name="resources">Localization resourses</param> /// <param name="text">Caption text</param> /// <param name="ext">File extesion</param> /// <returns>The Application form</returns> /// <returns></returns> public static FormMain CreateForm(IDatabaseCoordinator coordinator, ByteHolder holder, OrdinaryDifferentialEquations.IDifferentialEquationSolver ordSolver, DataPerformer.Portable.DifferentialEquationProcessors.DifferentialEquationProcessor diffProcessor, IApplicationInitializer[] initializers, IUIFactory[] factories, bool throwsRepeatException, LightDictionary <string, ButtonWrapper[]> buttons, Icon icon, string filename, Dictionary <string, object>[] resources, string text, string ext, string fileFilter, TextWriter logWriter, TestCategory.Interfaces.ITestInterface testInterface) { return(CreateForm(coordinator, holder, ordSolver, diffProcessor, initializers, factories, throwsRepeatException, buttons, icon, null, filename, resources, text, ext, fileFilter, logWriter, testInterface)); }
public void CantAcceptDuplicateKeysFromSourceDictionary() { LightDictionary <string, int> source = new LightDictionary <string, int> { { "a", 1 }, { "A", 1 } }; Assert.Throws <ArgumentException>(null, () => new LightDictionary <string, int>(source, StringComparer.OrdinalIgnoreCase)); }
public void LightDictionary_Generic_RemoveKey_ValidKeyNotContainedInDictionary(int count) { LightDictionary <TKey, TValue> dictionary = (LightDictionary <TKey, TValue>)GenericIDictionaryFactory(count); TKey missingKey = GetNewKey(dictionary); Assert.False(dictionary.Remove(missingKey)); Assert.Equal(count, dictionary.Count); }
public void IDictionary_NonGeneric_Contains_KeyOfWrongType(int count) { if (!IsReadOnly) { IDictionary dictionary = new LightDictionary <string, int>(); Assert.False(dictionary.Contains(1)); } }
public void LightDictionary_Generic_Constructor_int_IEqualityComparer(int count) { IEqualityComparer <TKey> comparer = GetKeyIEqualityComparer(); LightDictionary <TKey, TValue> dictionary = new LightDictionary <TKey, TValue>(count, comparer); Assert.Equal(0, dictionary.Count); Assert.Equal(comparer, dictionary.Comparer); }
/// <summary> /// Adds buttons /// </summary> /// <param name="keys">Keys</param> /// <param name="buttons">Buttons</param> /// <param name="tab">Tab control</param> /// <param name="tools">Tools</param> /// <param name="size">Size</param> /// <param name="resources">Resources</param> /// <param name="translate">Translate sign</param> public static void Add(string[] keys, ButtonWrapper[][] buttons, TabControl tab, ToolsDiagram tools, Size size, Dictionary <string, object>[] resources, bool translate) { LightDictionary <string, ButtonWrapper[]> d = new LightDictionary <string, ButtonWrapper[]>(); d.Add(keys, buttons); Add(d, tab, tools, size, resources, translate); }
public void IDictionary_NonGeneric_ItemSet_KeyOfWrongType(int count) { if (!IsReadOnly) { IDictionary dictionary = new LightDictionary <string, string>(); Assert.Throws <ArgumentException>("key", () => dictionary[23] = CreateTValue(12345)); Assert.Empty(dictionary); } }
public void LightDictionary_Generic_Constructor_IEqualityComparer(int count) { IEqualityComparer <TKey> comparer = GetKeyIEqualityComparer(); IDictionary <TKey, TValue> source = GenericIDictionaryFactory(count); LightDictionary <TKey, TValue> copied = new LightDictionary <TKey, TValue>(source, comparer); Assert.Equal(source, copied); Assert.Equal(comparer, copied.Comparer); }
private static IDictionary <T, T> CreateLightDictionary <T>(int size, Func <int, T> keyValueSelector, IEqualityComparer <T> comparer = null) { Dictionary <T, T> dict = Enumerable.Range(0, size + 1).ToDictionary(keyValueSelector, keyValueSelector, comparer); // Remove first item to reduce Count to size and alter the contiguity of the dictionary dict.Remove(keyValueSelector(0)); LightDictionary <T, T> lightDict = new LightDictionary <T, T>(dict); return(lightDict); }
public void IDictionary_NonGeneric_Add_KeyOfWrongType(int count) { if (!IsReadOnly) { IDictionary dictionary = new LightDictionary <string, string>(); object missingKey = 23; Assert.Throws <ArgumentException>("key", () => dictionary.Add(missingKey, CreateTValue(12345))); Assert.Empty(dictionary); } }
public void IDictionary_NonGeneric_Add_ValueOfWrongType(int count) { if (!IsReadOnly) { IDictionary dictionary = new LightDictionary <string, string>(); object missingKey = GetNewKey(dictionary); Assert.Throws <ArgumentException>("value", () => dictionary.Add(missingKey, 324)); Assert.Empty(dictionary); } }
public void LightDictionary_Generic_RemoveKey_ValidKeyContainedInDictionary(int count) { LightDictionary <TKey, TValue> dictionary = (LightDictionary <TKey, TValue>)GenericIDictionaryFactory(count); TKey missingKey = GetNewKey(dictionary); TValue inValue = CreateTValue(count); dictionary.Add(missingKey, inValue); Assert.True(dictionary.Remove(missingKey)); Assert.Equal(count, dictionary.Count); }
public void IDictionary_NonGeneric_Add_NullValueWhenDefaultTValueIsNonNull(int count) { if (!IsReadOnly) { IDictionary dictionary = new LightDictionary <string, int>(); object missingKey = GetNewKey(dictionary); Assert.Throws <ArgumentNullException>(() => dictionary.Add(missingKey, null)); Assert.Empty(dictionary); } }
/// <summary> /// Adds buttons to Tab control /// </summary> /// <param name="tab">The tab</param> /// <param name="buttons">Buttons</param> /// <param name="tools">Tools</param> /// <param name="size">Size</param> /// <param name="resources">Resources</param> /// <param name="translate">The "translate" sign</param> public static void Add(LightDictionary <string, ButtonWrapper[]> buttons, TabControl tab, ToolsDiagram tools, Size size, Dictionary <string, object>[] resources, bool translate) { IList <string> keys = buttons.Keys; foreach (string key in keys) { Add(key, buttons[key], tab, tools, size, resources, translate); } }
static CommonService.LightDictionary <string, ButtonWrapper[]> GetButtons(Motion6D.Interfaces.IPositionObjectFactory factory) { Motion6D.Interfaces.IPositionObjectFactory f = factory; if (f == null) { f = Motion6D.PositionObjectFactory.BaseFactory; } string[] tabs = new string[] { "General", "Statistics", "Database", "6D Motion", "Image", "Events", "Arrows" }; ButtonWrapper[][] but = new ButtonWrapper[tabs.Length][]; int i = 0; List <ButtonWrapper> gen = new List <ButtonWrapper>(); gen.AddRange(DataPerformer.UI.Factory.StaticFactory.GeneralObjectsButtons); gen.AddRange(ControlSystems.Data.UI.Factory.ControlSystemsFactory.ObjectButtons); gen.AddRange(Simulink.Proxy.UI.Factory.SimulinkProxyFactory.ObjectButtons); gen.AddRange(SoundService.UI.Factory.SoundUIFactrory.ObjectButtons); but[i] = gen.ToArray(); ++i; but[i] = EngineeringUIFactory.StatisticalObjectsButtons; ++i; but[i] = Database.UI.Factory.DatabaseFactory.ObjectButtons; ++i; List <ButtonWrapper> geom = new List <ButtonWrapper>(); geom.AddRange(Motion6D.UI.Factory.MotionFactory.ObjectButtons); geom.AddRange(Motion6D.UI.Factory.VisibleFactory.GetVisualObjectButtons(f)); but[i] = geom.ToArray(); ++i; List <ButtonWrapper> image = new List <ButtonWrapper>(); image.AddRange(ImageTransformations.Factory.ImageTransformationFactory.ObjectButtons); image.AddRange(ImageNavigation.Factory.ImageNavigationFactory.ObjectButtons); but[i] = image.ToArray(); ++i; List <ButtonWrapper> events = new List <ButtonWrapper>(); events.AddRange(Event.UI.Factory.UIFactory.ObjectButtons); but[i] = events.ToArray(); ++i; List <ButtonWrapper> arr = new List <ButtonWrapper>(); arr.AddRange(EngineeringUIFactory.ArrowButtons); arr.Add(EngineeringUIFactory.DataExchangeArrowButtons[0]); arr.AddRange(Database.UI.Factory.DatabaseFactory.ArrowButtons); arr.AddRange(Motion6D.UI.Factory.MotionFactory.ArrowButtons); arr.AddRange(Motion6D.UI.Factory.VisibleFactory.VisualArrowButtons); arr.AddRange(ImageTransformations.Factory.ImageTransformationFactory.ArrowButtons); arr.AddRange(ImageNavigation.Factory.ImageNavigationFactory.ArrowButtons); arr.AddRange(Event.UI.Factory.UIFactory.ArrowButtons); but[i] = arr.ToArray(); LightDictionary <string, ButtonWrapper[]> buttons = new LightDictionary <string, ButtonWrapper[]>(); buttons.Add(tabs, but); return(buttons); }
public void LightDictionary_Generic_ValueCollection_GetEnumerator(int count) { LightDictionary <string, string> dictionary = new LightDictionary <string, string>(); int seed = 13453; while (dictionary.Count < count) { dictionary.Add(CreateT(seed++), CreateT(seed++)); } dictionary.Values.GetEnumerator(); }
protected override ICollection NonGenericICollectionFactory(int count) { LightDictionary <string, string> list = new LightDictionary <string, string>(); int seed = 13453; for (int i = 0; i < count; i++) { list.Add(CreateT(seed++), CreateT(seed++)); } return(list.Values); }
public void ManyValues(LightDictionary <int, string> sut) { for (int i = 0; i < 100000; i++) { sut[i] = i.ToString(); } for (int i = 0; i < 100000; i++) { Assert.Equal(i.ToString(), sut[i]); } }
public void LightDictionary_Generic_ContainsValue_NotPresent(int count) { LightDictionary <TKey, TValue> dictionary = (LightDictionary <TKey, TValue>)GenericIDictionaryFactory(count); int seed = 4315; TValue notPresent = CreateTValue(seed++); while (dictionary.Values.Contains(notPresent)) { notPresent = CreateTValue(seed++); } Assert.False(dictionary.ContainsValue(notPresent)); }
public ASPxMenuNavigationControl() { _asPxMenuControl = RenderHelper.CreateASPxMenu(); _asPxMenuControl.AllowSelectItem = true; _asPxMenuControl.Border.BorderStyle = BorderStyle.None; _asPxMenuControl.ID = "NB"; _asPxMenuControl.ItemClick += ASPxMenuControl_ItemClick; _asPxMenuControl.Load += ASPxMenuControl_Load; _actionItemToMenuItemMap = new Dictionary <ChoiceActionItem, MenuItem>(); _actionItemToMenuGroupMap = new LightDictionary <ChoiceActionItem, MenuItem>(); _menuItemToWrapperMap = new Dictionary <MenuItem, ASPxMenuItemChoiceActionItem>(); _groupWrappers = new List <ASPxMenuGroupChoiceActionItem>(); }
public void LightDictionary_Generic_ContainsValue_DefaultValuePresent(int count) { LightDictionary <TKey, TValue> dictionary = (LightDictionary <TKey, TValue>)GenericIDictionaryFactory(count); int seed = 4315; TKey notPresent = CreateTKey(seed++); while (dictionary.ContainsKey(notPresent)) { notPresent = CreateTKey(seed++); } dictionary.Add(notPresent, default(TValue)); Assert.True(dictionary.ContainsValue(default(TValue))); }
public void LightDictionary_Generic_ContainsValue_Present(int count) { LightDictionary <TKey, TValue> dictionary = (LightDictionary <TKey, TValue>)GenericIDictionaryFactory(count); int seed = 4315; KeyValuePair <TKey, TValue> notPresent = CreateT(seed++); while (dictionary.Contains(notPresent)) { notPresent = CreateT(seed++); } dictionary.Add(notPresent.Key, notPresent.Value); Assert.True(dictionary.ContainsValue(notPresent.Value)); }
public ASPxMenuNavigationControl() { ASPxMenuControl = RenderHelper.CreateASPxMenu(); ASPxMenuControl.AllowSelectItem = true; ASPxMenuControl.Border.BorderStyle = BorderStyle.None; ASPxMenuControl.ID = "NB"; ASPxMenuControl.ItemClick += ASPxMenuControl_ItemClick; ASPxMenuControl.Load += ASPxMenuControl_Load; ActionItemToMenuItemMap = new Dictionary <ChoiceActionItem, DevExpress.Web.MenuItem>(); ActionItemToMenuGroupMap = new LightDictionary <ChoiceActionItem, DevExpress.Web.MenuItem>(); MenuItemToWrapperMap = new Dictionary <DevExpress.Web.MenuItem, ASPxMenuItemChoiceActionItem>(); GroupWrappers = new List <ASPxMenuGroupChoiceActionItem>(); }
public void LightDictionary_Generic_RemoveKey_DefaultKeyNotContainedInDictionary(int count) { LightDictionary <TKey, TValue> dictionary = (LightDictionary <TKey, TValue>)GenericIDictionaryFactory(count); if (DefaultValueAllowed) { TKey missingKey = default(TKey); while (dictionary.ContainsKey(missingKey)) { dictionary.Remove(missingKey); } Assert.False(dictionary.Remove(missingKey)); } }
public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value) { string[] tabs = new string[] { "General", "6D Motion", "Arrows" }; ButtonWrapper[][] but = new ButtonWrapper[tabs.Length][]; int i = 0; List <ButtonWrapper> gen = new List <ButtonWrapper>(); gen.AddRange(DataPerformer.UI.Factory.StaticFactory.GeneralObjectsButtons); // gen.AddRange(ControlSystems.Data.UI.Factory.ControlSystemsFactory.ObjectButtons); but[i] = gen.ToArray(); ++i; List <ButtonWrapper> geom = new List <ButtonWrapper>(); //geom.AddRange(Motion6D.UI.Factory.MotionFactory.ObjectButtons); // geom.AddRange(Motion6D.UI.Factory.VisibleFactory.GetVisualObjectButtons(factory)); but[i] = geom.ToArray(); ++i; List <ButtonWrapper> arr = new List <ButtonWrapper>(); arr.AddRange(EngineeringUIFactory.ArrowButtons); arr.AddRange(Motion6D.UI.Factory.MotionFactory.ArrowButtons); arr.AddRange(Motion6D.UI.Factory.VisibleFactory.VisualArrowButtons); but[i] = arr.ToArray(); LightDictionary <string, ButtonWrapper[]> buttons = new LightDictionary <string, ButtonWrapper[]>(); buttons.Add(tabs, but); IUIFactory[] factories = new IUIFactory[] { // ControlSystems.Data.UI.Factory.ControlSystemsFactory.Object, }; IApplicationInitializer[] init = new IApplicationInitializer[] { }; Dictionary <string, object>[] d = Motion6D.UI.Utils.ControlUtilites.Resources; ByteHolder holder = value as ByteHolder; FormMain m = MotionApplicationCreator.CreateForm(null, holder, OrdinaryDifferentialEquations.Runge4Solver.Singleton, DataPerformer.Portable.DifferentialEquationProcessors.RungeProcessor.Processor, init, factories, true, buttons, Properties.Resources.Aviation, null, null, Motion6D.UI.Utils.ControlUtilites.Resources, "Astronomy + OpenGL", ".cfa", "Astronomy configuration files |*.cfa", null, null); m.ShowDialog(); return(m.Creator.Holder); }
public async Task LightDictionaryConcurrentAccessDetection_ValueTypeKey(Type comparerType) { IEqualityComparer <int> customComparer = null; LightDictionary <int, int> dic = comparerType == null ? new LightDictionary <int, int>() : new LightDictionary <int, int>((customComparer = (IEqualityComparer <int>)Activator.CreateInstance(comparerType))); dic.Add(1, 1); await LightDictionaryConcurrentAccessDetection(dic, typeof(int).IsValueType, customComparer, d => d.Add(1, 1), d => { var v = d[1]; }, d => d.Remove(1)); }
/// <summary> /// Creates application form /// </summary> /// <param name="coordinator">Database coordinator</param> /// <param name="holder">byte holder for editor of proprerties</param> /// <param name="ordSolver">Ordinary differential equations solver</param> /// <param name="diffProcessor">Ordinary differential equations processor</param> /// <param name="initializers">Array of initializers</param> /// <param name="factories">UI Factotries</param> /// <param name="throwsRepeatException">The "throw exception for repeat" sign</param> /// <param name="buttons">Palette buttons</param> /// <param name="icon">Form icon</param> /// <param name="positionFactory">Position factory</param> /// <param name="filename">File name</param> /// <param name="resources">Localization resourses</param> /// <param name="text">Caption text</param> /// <param name="ext">File extesion</param> /// <param name="fileFilter">Filter for file dialog</param> /// <param name="logWriter">Log writer</param> /// <param name="testInterface">Test Interface</param> /// <returns>The Application form</returns> public static FormMain CreateForm(IDatabaseCoordinator coordinator, ByteHolder holder, OrdinaryDifferentialEquations.IDifferentialEquationSolver ordSolver, DataPerformer.Portable.DifferentialEquationProcessors.DifferentialEquationProcessor diffProcessor, IApplicationInitializer[] initializers, IUIFactory[] factories, bool throwsRepeatException, LightDictionary <string, ButtonWrapper[]> buttons, Icon icon, IPositionObjectFactory positionFactory, string filename, Dictionary <string, object>[] resources, string text, string ext, string fileFilter, TextWriter logWriter, TestCategory.Interfaces.ITestInterface testInterface) { Motion6D.PositionFactory.Factory = Motion6D.Drawing.Factory.ColoredPositionFactory.Object; Motion6D.UI.UserControls.SimpleChooser.Chooser = Motion6D.UI.UserControls.ColoredChooser.Object; List <IUIFactory> fact = null; if (factories == null) { fact = new List <IUIFactory>(); } else { fact = new List <IUIFactory>(factories); } fact.Add(MotionFactory.Object); if (positionFactory != null) { VisibleFactory vf = new VisibleFactory(positionFactory); fact.Add(vf); } List <IApplicationInitializer> apps = new List <IApplicationInitializer>(initializers); apps.Add(Motion6D.ApplicationInitializer.Object); FormMain form = DefaultApplicationCreator.CreateForm(coordinator, holder, ordSolver, diffProcessor, Motion6D.Runtime.DataRuntimeFactory.Object, apps.ToArray(), fact.ToArray(), throwsRepeatException, buttons, icon, filename, resources, text, ext, fileFilter, logWriter, testInterface); StaticExtensionMotion6D.Animation = form; return(form); }
public static FormMain CreateForm(IDatabaseCoordinator coordinator, ByteHolder holder, OrdinaryDifferentialEquations.IDifferentialEquationSolver ordSolver, DataPerformer.Portable.DifferentialEquationProcessors.DifferentialEquationProcessor diffProcessor, IApplicationInitializer[] initializers, IUIFactory[] factories, bool throwsRepeatException, LightDictionary <string, ButtonWrapper[]> buttons, Icon icon, string filename, Dictionary <string, object>[] resources, string text, string ext, string fileFilter, TextWriter logWriter, TestCategory.Interfaces.ITestInterface testInterface) { EngineeringUIFactory factory = new EngineeringUIFactory(factories, true, ext); EngineeringInitializer initializer = new EngineeringInitializer(coordinator, ordSolver, diffProcessor, DataPerformer.Runtime.DataRuntimeFactory.Object, initializers, throwsRepeatException, resources, logWriter); DefaultApplicationCreator creator = new DefaultApplicationCreator(coordinator, buttons, icon, factory, holder, filename, factory.Start, resources, text, ext, fileFilter, initializer, logWriter, testInterface); return(CreateForm(creator)); }
public void SingleValue(LightDictionary<int, string> sut, int key, string value) { sut[key] = value; Assert.Equal(value, sut[key]); }
static ModelEditorPropertyEditor () { _typeInfo = XafTypesInfo.Instance; _modelApplicationBases=new LightDictionary<ModelApplicationBase, ITypesInfo>(); }
public ASPxMenuNavigationControl(){ ASPxMenuControl = RenderHelper.CreateASPxMenu(); ASPxMenuControl.AllowSelectItem = true; ASPxMenuControl.Border.BorderStyle = BorderStyle.None; ASPxMenuControl.ID = "NB"; ASPxMenuControl.ItemClick += ASPxMenuControl_ItemClick; ASPxMenuControl.Load += ASPxMenuControl_Load; ActionItemToMenuItemMap = new Dictionary<ChoiceActionItem, MenuItem>(); ActionItemToMenuGroupMap = new LightDictionary<ChoiceActionItem, MenuItem>(); MenuItemToWrapperMap = new Dictionary<MenuItem, ASPxMenuItemChoiceActionItem>(); GroupWrappers = new List<ASPxMenuGroupChoiceActionItem>(); }