private void SCMSystem_Load(object sender, EventArgs e) { // Define the border style of the form to a dialog box. this.FormBorderStyle = FormBorderStyle.FixedDialog; // Set the MaximizeBox to false to remove the maximize box. this.MaximizeBox = false; // Set the MinimizeBox to false to remove the minimize box. this.MinimizeBox = false; // Set the start position of the form to the center of the screen. this.StartPosition = FormStartPosition.CenterScreen; //Creating a unique ID for Order ID lblOrderID.Text = UniqueIDGenerator.NewId(); // Hard code Buyer ID tbxBuyerIDOrder.Text = "GFS1810"; // List View Settings to fix the width this.lvProduct.ColumnWidthChanging += new ColumnWidthChangingEventHandler(lvProduct_ColumnWidthChanging); this.lvInvoiceInvoice.ColumnWidthChanging += new ColumnWidthChangingEventHandler(lvInvoiceInvoice_ColumnWidthChanging); // List view Settings to retrieve the information from database and display in the listview SCMDBManager.ListViewItem(lvProduct); SCMDBManager.FillDropDownListProductID(cbBoxOrderProductID); // ReadOnly controls for textbox so that no edit is allow. tbxSizeOrder.ReadOnly = true; tbxColorOrder.ReadOnly = true; tbxDescriptionOrder.ReadOnly = true; tbxQuantitiesOrder.ReadOnly = true; tbxExisitingUnitPriceOrder.ReadOnly = true; }
public static _TestCaseDiscovered TestCaseDiscovered <TClass>( string testMethod, string?testCaseDisplayName = null) { var typeInfo = typeof(TClass); var methodInfo = Guard.NotNull($"Could not find method '{testMethod}' in type '{typeInfo.FullName}'", typeInfo.GetMethod(testMethod)); var skipReason = methodInfo.GetCustomAttribute <FactAttribute>()?.Skip; var traits = GetTraits(methodInfo); var testClassUniqueID = UniqueIDGenerator.ForTestClass(DefaultTestCollectionUniqueID, typeInfo.FullName); var testMethodUniqueID = UniqueIDGenerator.ForTestMethod(testClassUniqueID, testMethod); var testCaseUniqueID = UniqueIDGenerator.ForTestCase(testMethodUniqueID, null, null); return(TestCaseDiscovered( DefaultAssemblyUniqueID, DefaultTestCaseSerialization, skipReason, sourceFilePath: null, sourceLineNumber: null, testCaseDisplayName ?? $"{typeInfo.FullName}.{testMethod}", testCaseUniqueID, typeInfo.Name, testClassUniqueID, typeInfo.FullName, DefaultTestCollectionUniqueID, testMethod, testMethodUniqueID, typeInfo.Namespace, traits )); }
public void NoData() { using var generator = new UniqueIDGenerator(); var result = generator.Compute(); Assert.Equal("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", result); }
/// <summary> /// Initializes a new instance of the <see cref="TestClass"/> class. /// </summary> /// <param name="testCollection">The test collection the class belongs to</param> /// <param name="class">The test class</param> /// <param name="uniqueID">The unique ID for the test class (only used to override default behavior in testing scenarios)</param> public TestClass( _ITestCollection testCollection, _ITypeInfo @class, string?uniqueID = null) { this.@class = Guard.ArgumentNotNull(@class); this.testCollection = Guard.ArgumentNotNull(testCollection); this.uniqueID = uniqueID ?? UniqueIDGenerator.ForTestClass(TestCollection.UniqueID, Class.Name); }
internal T GetRelativePropertyValue <T>(T backingField, string propertyName) where T : IStateObject { if (backingField == null) { var relativeUid = UniqueIDGenerator.GetRelativeUniqueID(this, propertyName); backingField = (T)StateManager.Current.GetObject(relativeUid); } return(backingField); }
internal void SetRelativePropertyValue <T>(T value, ref T backingField, string propertyName) where T : IStateObject { backingField = value; if (value != null) { backingField.UniqueID = UniqueIDGenerator.GetRelativeUniqueID(this, propertyName); StateManager.Current.AddNewObject(backingField); } }
/// <summary> /// Initializes a new instance of the <see cref="XunitTest"/> class. /// </summary> /// <param name="testCase">The test case this test belongs to.</param> /// <param name="displayName">The display name for this test.</param> /// <param name="testIndex">The index of this test inside the test case. Used for computing <see cref="UniqueID"/>.</param> public XunitTest( IXunitTestCase testCase, string displayName, int testIndex) { TestCase = Guard.ArgumentNotNull(nameof(testCase), testCase); DisplayName = Guard.ArgumentNotNull(nameof(displayName), displayName); UniqueID = UniqueIDGenerator.ForTest(testCase.UniqueID, testIndex); }
public void SingleString() { using var generator = new UniqueIDGenerator(); generator.Add("Hello, world!"); var result = generator.Compute(); Assert.Equal("5450bb49d375ba935c1fe9c4dc48775d7d343fb97f22f07f8950f34a75a2708f", result); }
static Xunit2MessageAdapterTests() { try { throw new DivideByZeroException(); } catch (Exception ex) { ThrownException = ex; } Traits = new Dictionary <string, List <string> > { { "key1", new List <string> { "value1a", "value1b" } }, { "key2", new List <string> { "value2" } }, { "key3", new List <string>() } }; TestAssembly = Xunit2Mocks.TestAssembly("testAssembly.dll", "xunit.runner.json"); TestAssemblyUniqueID = UniqueIDGenerator.ForAssembly( TestAssembly.Assembly.Name, TestAssembly.Assembly.AssemblyPath, TestAssembly.ConfigFileName ); TestCollectionDefinition = Xunit2Mocks.TypeInfo(); TestCollection = Xunit2Mocks.TestCollection(TestAssembly, TestCollectionDefinition, "test-collection-display-name"); TestCollectionUniqueID = UniqueIDGenerator.ForTestCollection( TestAssemblyUniqueID, TestCollection.DisplayName, TestCollectionDefinition.Name ); TestClassType = Xunit2Mocks.TypeInfo(); TestClass = Xunit2Mocks.TestClass(TestCollection, TestClassType); TestClassUniqueID = UniqueIDGenerator.ForTestClass( TestCollectionUniqueID, TestClass.Class.Name ); TestMethod = Xunit2Mocks.TestMethod(TestClass, "MyTestMethod"); TestMethodUniqueID = UniqueIDGenerator.ForTestMethod( TestClassUniqueID, TestMethod.Method.Name ); TestCase = Xunit2Mocks.TestCase(TestMethod, "test-case-display-name", "skip-reason", "source-file", 2112, Traits, "test-case-id"); TestCaseUniqueID = TestCase.UniqueID; Test = Xunit2Mocks.Test(TestCase, "test-display-name"); TestUniqueID = UniqueIDGenerator.ForTest(TestCaseUniqueID, 0); }
/// <summary> /// Initializes a new instance of the <see cref="TestMethod"/> class. /// </summary> /// <param name="testClass">The test class</param> /// <param name="method">The test method</param> /// <param name="uniqueID">The unique ID for the test method (only used to override default behavior in testing scenarios)</param> public TestMethod( _ITestClass testClass, _IMethodInfo method, string?uniqueID = null) { this.testClass = Guard.ArgumentNotNull(nameof(testClass), testClass); this.method = Guard.ArgumentNotNull(nameof(method), method); this.uniqueID = uniqueID ?? UniqueIDGenerator.ForTestMethod(testClass.UniqueID, this.method.Name); }
public void GuardClause() { using var generator = new UniqueIDGenerator(); var ex = Record.Exception(() => generator.Add(null !)); var anex = Assert.IsType <ArgumentNullException>(ex); Assert.Equal("value", anex.ParamName); }
public void CannotComputeAfterDispose() { using var generator = new UniqueIDGenerator(); generator.Dispose(); var ex = Record.Exception(() => generator.Compute()); Assert.IsType <ObjectDisposedException>(ex); Assert.StartsWith("Cannot use UniqueIDGenerator after you have called Compute or Dispose", ex.Message); }
public void SuccessCases( string assemblyName, string?assemblyPath, string?configFilePath, string expected) { var actual = UniqueIDGenerator.ForAssembly(assemblyName, assemblyPath, configFilePath); Assert.Equal <object>(expected, actual); }
public void UniqueIDUsesOnlyShortAssemblyNameForDiscoveryVsExecutionConsistency() { var longName = "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"; var shortName = "mscorlib"; var longID = UniqueIDGenerator.ForAssembly(longName, null, null); var shortID = UniqueIDGenerator.ForAssembly(shortName, null, null); Assert.NotEmpty(longID); Assert.Equal(shortID, longID); }
/// <summary> /// Initializes a new instance of the <see cref="TestCollection"/> class. /// </summary> /// <param name="testAssembly">The test assembly the collection belongs to</param> /// <param name="collectionDefinition">The optional type which contains the collection definition</param> /// <param name="displayName">The display name for the test collection</param> /// <param name="uniqueID">The unique ID for the test collection (only used to override default behavior in testing scenarios)</param> public TestCollection( _ITestAssembly testAssembly, _ITypeInfo?collectionDefinition, string displayName, string?uniqueID = null) { CollectionDefinition = collectionDefinition; this.displayName = Guard.ArgumentNotNull(displayName); this.testAssembly = Guard.ArgumentNotNull(testAssembly); this.uniqueID = uniqueID ?? UniqueIDGenerator.ForTestCollection(testAssembly.UniqueID, this.displayName, CollectionDefinition?.Name); }
void SendDiscoveryStartingMessage(_IMessageSink messageSink) { // There is no v2 equivalent to this, so we manufacture it ourselves var discoveryStarting = new _DiscoveryStarting { AssemblyName = assemblyInfo.Name, AssemblyPath = assemblyInfo.AssemblyPath, AssemblyUniqueID = UniqueIDGenerator.ForAssembly(assemblyInfo.Name, assemblyInfo.AssemblyPath, configFileName), ConfigFilePath = configFileName }; messageSink.OnMessage(discoveryStarting); }
public Game(GameNetwork Network, int NeededNumberOfPlayersForGameToStart, UniqueIDGenerator gamesIDGenerator) { GamesIDGenerator = gamesIDGenerator; GameID = GamesIDGenerator.GetID(); Logger.GameID = GameID; Logger.GameLog("Initialising a new Game with " + Convert.ToString(NeededNumberOfPlayersForGameToStart) + " Players"); this.Network = Network; this.Network.ClientLost += OnClientLost; GameState = GameStates.Initializing; GameStructure = new GameStructure(NeededNumberOfPlayersForGameToStart); GameEngine = new GameEngine(GameStructure); NumberOfPlayers = NeededNumberOfPlayersForGameToStart; GameEngine.TeamScoredHandler += OnTeamScored; GameEngine.OnGameFinished += HandleFinishedGame; }
/// <summary> /// Initializes a new instance of the <see cref="TestAssembly"/> class. /// </summary> /// <param name="assembly">The test assembly.</param> /// <param name="configFileName">The optional configuration filename</param> /// <param name="version">The version number of the assembly (defaults to "0.0.0.0")</param> /// <param name="uniqueID">The unique ID for the test assembly (only used to override default behavior in testing scenarios)</param> public TestAssembly( _IAssemblyInfo assembly, string?configFileName = null, Version?version = null, string?uniqueID = null) { Assembly = Guard.ArgumentNotNull(assembly); ConfigFileName = configFileName; this.uniqueID = uniqueID ?? UniqueIDGenerator.ForAssembly(assembly.Name, assembly.AssemblyPath, configFileName); Version = version ?? (assembly as _IReflectionAssemblyInfo)?.Assembly?.GetName()?.Version ?? new Version(0, 0, 0, 0); }
_TestOutput ToTestOutput( Xunit1TestCase testCase, string output) { return(new _TestOutput { AssemblyUniqueID = testCase.AssemblyUniqueID, Output = output, TestCaseUniqueID = testCase.TestCaseUniqueID, TestClassUniqueID = testCase.TestClassUniqueID, TestCollectionUniqueID = testCase.TestCollectionUniqueID, TestMethodUniqueID = testCase.TestMethodUniqueID, TestUniqueID = UniqueIDGenerator.ForTest(testCase.TestCaseUniqueID, currentTestIndex) }); }
public static void serializeID(UniqueIDGenerator id) { try { using (FileStream fStream = new FileStream(@".\UniqueID\idGenerator.fmg", FileMode.Create)) { BinaryFormatter formatter = new BinaryFormatter(); formatter.Serialize(fStream, id); } } catch (Exception ex) { MessageBox.Show("Something went wrong with saving the user ID's. Check your .exe file location"); } }
_TestStarting ToTestStarting( Xunit1TestCase testCase, string testDisplayName) { return(new _TestStarting { AssemblyUniqueID = testCase.AssemblyUniqueID, TestCaseUniqueID = testCase.TestCaseUniqueID, TestClassUniqueID = testCase.TestClassUniqueID, TestCollectionUniqueID = testCase.TestCollectionUniqueID, TestDisplayName = testDisplayName, TestMethodUniqueID = testCase.TestMethodUniqueID, TestUniqueID = UniqueIDGenerator.ForTest(testCase.TestCaseUniqueID, currentTestIndex) }); }
public PageNewDevice(ComosWebSDK.UI.UICachedScreen screen, string uid, string pic, string owner, CCachedDevice cached = null) { InitializeComponent(); midiacontrol = midiaControl; cacheddevice = cached; verifiedSystemUid = ""; txtDescription.BindingContext = this; this.ShowHome = false; this.ShowFavoriteButton = false; this.ShowAttributeView = false; this.Title = owner; uidowner = uid; uidcdev = screen.UID; ownername = owner; user = ProjectData.User; project = ProjectData.SelectedProject.UID; workinglayer = ProjectData.SelectedLayer.UID; language = ProjectData.SelectedLanguage.LCID; servername = db.ReadSetting("ServerNameBR", "http://siemens.southcentralus.cloudapp.azure.com:5109/Service.svc"); //NavigationBarControl.OnSaved += NavigationBarControl_OnSaved; UpdateAttributesUI(screen.JSONContent); DescLabel.WidthRequest = (XComosMobile.App.WidthPixels / 3); if (cached != null) { tempuid = cached.TempUID; this.Description = cached.Description; OnPropertyChanged("Description"); } else { tempuid = UniqueIDGenerator.GenerateID(); } string name = ""; if (MainObject != null) { name = MainObject.Name; } midiaControl.StartComponent(tempuid, name); }
/// <summary> /// Used for de-serialization. /// </summary> protected TestAssembly( SerializationInfo info, StreamingContext context) { Version = Guard.NotNull("Could not retrieve Version from serialization", info.GetValue <Version>("Version")); ConfigFileName = info.GetValue <string>("ConfigFileName"); var assemblyPath = Guard.NotNull("Could not retrieve AssemblyPath from serialization", info.GetValue <string>("AssemblyPath")); var assemblyName = Path.GetFileNameWithoutExtension(assemblyPath); var assembly = System.Reflection.Assembly.Load(new AssemblyName { Name = assemblyName, Version = Version }); Assembly = Reflector.Wrap(assembly); uniqueID = UniqueIDGenerator.ForAssembly(assemblyName, assemblyPath, ConfigFileName); }
_TestSkipped ToTestSkipped( Xunit1TestCase testCase, string reason) { return(new _TestSkipped { AssemblyUniqueID = testCase.AssemblyUniqueID, ExecutionTime = 0m, Output = "", Reason = reason, TestCaseUniqueID = testCase.TestCaseUniqueID, TestClassUniqueID = testCase.TestClassUniqueID, TestCollectionUniqueID = testCase.TestCollectionUniqueID, TestMethodUniqueID = testCase.TestMethodUniqueID, TestUniqueID = UniqueIDGenerator.ForTest(testCase.TestCaseUniqueID, currentTestIndex) }); }
_TestPassed ToTestPassed( Xunit1TestCase testCase, decimal executionTime, string output) { return(new _TestPassed { AssemblyUniqueID = testCase.AssemblyUniqueID, ExecutionTime = executionTime, Output = output, TestCaseUniqueID = testCase.TestCaseUniqueID, TestClassUniqueID = testCase.TestClassUniqueID, TestCollectionUniqueID = testCase.TestCollectionUniqueID, TestMethodUniqueID = testCase.TestMethodUniqueID, TestUniqueID = UniqueIDGenerator.ForTest(testCase.TestCaseUniqueID, currentTestIndex) }); }
string UniqueIDForTest( string testCaseUniqueID, ITest test) { lock (testUniqueIDsByTestCase) { var uniqueIDLookup = testUniqueIDsByTestCase.GetOrAdd(test.TestCase, () => new Dictionary <ITest, string>()); if (!uniqueIDLookup.TryGetValue(test, out var result)) { var testIndex = uniqueIDLookup.Count; result = UniqueIDGenerator.ForTest(testCaseUniqueID, testIndex); uniqueIDLookup[test] = result; } return(result); } }
public static UniqueIDGenerator loadUniqueID() { try { using (FileStream fStream = new FileStream(@".\UniqueID\idGenerator.fmg", FileMode.Open)) { BinaryFormatter formatter = new BinaryFormatter(); UniqueIDGenerator id = (UniqueIDGenerator)formatter.Deserialize(fStream); //users.Add(user); return(id); } } catch (Exception ex) { // MessageBox.Show("Something went wrong with reading the users. Check the location of your .exe file"); UniqueIDGenerator id = new UniqueIDGenerator(); serializeID(id); return(id); } }
public ChangeUser(List <User> users, UniqueIDGenerator ID, bool secondPlayer) { InitializeComponent(); this.ID = ID; this.users = users; if (users.Count > 0) { if (users.Count > 1) { foreach (User u in users) { if (secondPlayer) { secondPlayer = false; continue; } listBox1.Items.Add(u); } listBox1.SelectedIndex = 0; setUser((User)(listBox1.SelectedItem)); } else { if (!secondPlayer) { listBox1.Items.Add(users[0]); listBox1.SelectedIndex = 0; } else { done.Enabled = false; removeButton.Enabled = false; changeAvatarButton.Enabled = false; InfoLabel.Visible = true; } } } }
/// <summary> /// Initializes a new instance of the <see cref="TestMethodTestCase"/> class. /// </summary> /// <param name="defaultMethodDisplay">Default method display to use (when not customized).</param> /// <param name="defaultMethodDisplayOptions">Default method display options to use (when not customized).</param> /// <param name="testMethod">The test method this test case belongs to.</param> /// <param name="testMethodArguments">The optional arguments for the test method.</param> /// <param name="skipReason">The optional reason for skipping the test.</param> /// <param name="traits">The optional traits list.</param> /// <param name="uniqueID">The optional unique ID for the test case; if not provided, will be calculated.</param> protected TestMethodTestCase( TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, _ITestMethod testMethod, object?[]?testMethodArguments = null, string?skipReason = null, Dictionary <string, List <string> >?traits = null, string?uniqueID = null) { DefaultMethodDisplay = defaultMethodDisplay; DefaultMethodDisplayOptions = defaultMethodDisplayOptions; SkipReason = skipReason; TestMethod = Guard.ArgumentNotNull(nameof(testMethod), testMethod); TestMethodArguments = testMethodArguments; if (traits != null) { Traits = new Dictionary <string, List <string> >(traits, StringComparer.OrdinalIgnoreCase); } else { Traits = new Dictionary <string, List <string> >(StringComparer.OrdinalIgnoreCase); } formatter = new DisplayNameFormatter(defaultMethodDisplay, defaultMethodDisplayOptions); var initResults = Initialize(BaseDisplayName, testMethod, TestMethodArguments); displayName = initResults.displayName; InitializationException = initResults.initException; Method = initResults.method; MethodGenericTypes = initResults.methodGenericTypes; this.uniqueID = uniqueID ?? UniqueIDGenerator.ForTestCase(TestMethod.UniqueID, MethodGenericTypes, TestMethodArguments); disposalTracker.AddRange(TestMethodArguments); }
_TestFailed ToTestFailed( Xunit1TestCase testCase, decimal executionTime, string output, XmlNode failure) { var errorMetadata = Xunit1ExceptionUtility.ConvertToErrorMetadata(failure); return(new _TestFailed { AssemblyUniqueID = testCase.AssemblyUniqueID, ExceptionParentIndices = errorMetadata.ExceptionParentIndices, ExceptionTypes = errorMetadata.ExceptionTypes, ExecutionTime = executionTime, Messages = errorMetadata.Messages, Output = output, StackTraces = errorMetadata.StackTraces, TestCaseUniqueID = testCase.TestCaseUniqueID, TestClassUniqueID = testCase.TestClassUniqueID, TestCollectionUniqueID = testCase.TestCollectionUniqueID, TestMethodUniqueID = testCase.TestMethodUniqueID, TestUniqueID = UniqueIDGenerator.ForTest(testCase.TestCaseUniqueID, currentTestIndex) }); }