public static void SwitchCaseMethodWithoutReturnValueAndThrowAsDefaultValue(ValueType1 input) { switch (input) { case ValueType1.A: return; case ValueType1.B: return; case ValueType1.C: return; default: throw new ArgumentOutOfRangeException(nameof(input), input, null); } }
public void Process_ChainedMemberAccess_OfValueTypes_WithNullValuedNullable_ReturningValueType() { // Arrange var model = new ValueType1 { NullableValueType2 = null }; var expression = GetExpression <ValueType1, DateTime>(m => m.NullableValueType2.Value.Date); // Act var func = CachedExpressionCompiler.Process(expression); // Assert Assert.NotNull(func); var result = func(model); Assert.Null(result); }
public static void IfMethodWithoutReturnValueAndThrowAsDefaultValue(ValueType1 input) { if (input == ValueType1.A) { return; } else if (input == ValueType1.B) { return; } else if (input == ValueType1.C) { return; } else { throw new ArgumentOutOfRangeException(nameof(input), input, null); } }
public void should_not_boxing_passed_value_type_arguments(RaiseWay raiseWay) { var expected1 = new ValueType1(389); var expected2 = new ValueType2(659); ValueType1 actual1 = default; ValueType2 actual2 = default; ITuple <ValueType2, ValueType1> actualTuple = null; // --arrange var builder = new Builder <string, int>(OnException); builder.DefineState(Initial).AddTransition(Event1, State1); builder.DefineState(State1) .OnEnter <ValueType1>(value => { }) .AddTransition(Event2, State2); builder.DefineState(Parent) .OnEnter <ValueType2>(value => actual2 = value); builder.DefineState(Child) .AsSubstateOf(Parent) .OnEnter <ValueType1>(value => actual1 = value); builder.DefineState(State2) .AsSubstateOf(Child) .OnEnter <ITuple <ValueType2, ValueType1> >(value => actualTuple = value); var target = builder.Build(Initial, true); // --act target.Raise(raiseWay, Event1, expected1); // pass to State1 target.Relaying <ValueType1>().Raise(raiseWay, Event2, expected2); // pass everywhere // --assert // actual.Should().Be(expected); -- this method leads boxing actual1.Value.Should().Be(expected1.Value); actual2.Value.Should().Be(expected2.Value); actualTuple !.RelayedArgument.Value.Should().Be(expected1.Value); actualTuple.PassedArgument.Value.Should().Be(expected2.Value); }
public void Process_ChainedMemberAccess_OfValueTypes_IncludingNullableType() { // Arrange var expected = "TestName"; var model = new ValueType1 { NullableValueType2 = new ValueType2 { Name = expected }, }; var expression = GetExpression <ValueType1, string>(m => m.NullableValueType2.Value.Name); // Act var func = CachedExpressionCompiler.Process(expression); // Assert Assert.NotNull(func); var result = func(model); Assert.Equal(expected, result); }
public void Process_ChainedMemberAccess_OfValueTypes_ReturningValueType() { // Arrange var expected = new DateTime(2001, 1, 1); var model = new ValueType1 { ValueType2 = new ValueType2 { Date = expected }, }; var expression = GetExpression <ValueType1, DateTime>(m => m.ValueType2.Date); // Act var func = CachedExpressionCompiler.Process(expression); // Assert Assert.NotNull(func); var result = func(model); Assert.Equal(expected, result); }
public void Process_ChainedMemberAccess_OfValueTypes_ReturningReferenceTypeMember() { // Arrange var expected = "TestName"; var model = new ValueType1 { ValueType2 = new ValueType2 { Name = expected }, }; var expression = GetExpression <ValueType1, string>(m => m.ValueType2.Name); // Act var func = CachedExpressionCompiler.Process(expression); // Assert Assert2.NotNull(func); var result = func(model); Assert2.Equal(expected, result); }
/// <summary>Required method for Designer support - do not modify the contents of this method with the code editor.</summary> private void InitializeComponent() { this.components = new System.ComponentModel.Container(); this.editMode = false; // // lblNeedToSave // this.lblNeedToSave = new System.Windows.Forms.Label(); this.lblNeedToSave.Location = new System.Drawing.Point(0, 10); this.lblNeedToSave.Name = "lblNeedToSave"; this.lblNeedToSave.Size = new System.Drawing.Size(200, 15); this.lblNeedToSave.Text = ""; // // btnCancel // this.btnCancel = new System.Windows.Forms.Button(); this.btnCancel.Location = new System.Drawing.Point(300, 10); this.btnCancel.Name = "btnCancel"; this.btnCancel.TabIndex = 6; this.btnCancel.Text = "Cancel"; this.btnCancel.UseVisualStyleBackColor = true; this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); // // btnSave // this.btnSave = new System.Windows.Forms.Button(); this.btnSave.Location = new System.Drawing.Point(400, 10); this.btnSave.Name = "btnSave"; this.btnSave.TabIndex = 7; this.btnSave.Text = "Save"; this.btnSave.UseVisualStyleBackColor = true; this.btnSave.Click += new System.EventHandler(this.btnSave_Click); // // pnlSave // this.pnlSave = new System.Windows.Forms.Panel(); this.pnlSave.Dock = System.Windows.Forms.DockStyle.Top; this.pnlSave.AutoSize = true; this.pnlSave.Location = new System.Drawing.Point(0, 0); this.pnlSave.Name = "pnlSave"; this.pnlSave.AutoScroll = true; this.pnlSave.TabIndex = 5; this.pnlSave.Controls.Add(this.btnSave); this.pnlSave.Controls.Add(this.btnCancel); this.pnlSave.Controls.Add(this.lblNeedToSave); this.pnlSave.Visible = false; // // lblSelectionMode // this.lblSelectionMode = new System.Windows.Forms.Label(); this.lblSelectionMode.Location = new System.Drawing.Point(0, 10); this.lblSelectionMode.Name = "lblSelectionMode"; this.lblSelectionMode.Text = "SelectionMode:"; // // cbxSelectionMode // this.cbxSelectionMode = new System.Windows.Forms.ComboBox(); this.cbxSelectionMode.Location = new System.Drawing.Point(100, 10); this.cbxSelectionMode.Name = "cbxSelectionMode"; this.cbxSelectionMode.Size = new System.Drawing.Size(200, 15); this.cbxSelectionMode.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cbxSelectionMode.TabIndex = 2; this.cbxSelectionMode.SelectedIndexChanged += new System.EventHandler(this.cbxSelectionMode_SelectedIndexChanged); this.cbxSelectionMode.Items.Add("ValueType1Value"); // // lblCurrentObject // this.lblCurrentObject = new System.Windows.Forms.Label(); this.lblCurrentObject.Location = new System.Drawing.Point(0, 45); this.lblCurrentObject.Width = 300; this.lblCurrentObject.Name = "lblCurrentObject"; this.lblCurrentObject.Text = "There is no selected ValueType1."; // // dgvCurrentObject // this.dgvCurrentObject = new System.Windows.Forms.DataGridView(); this.dgvCurrentObject.Dock = System.Windows.Forms.DockStyle.Top; this.dgvCurrentObject.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dgvCurrentObject.Location = new System.Drawing.Point(0, 265); this.dgvCurrentObject.Name = "dgvCurrentObject"; this.dgvCurrentObject.Size = new System.Drawing.Size(500, 150); this.dgvCurrentObject.TabIndex = 4; this.dgvCurrentObject.Columns.Add("ValueType1Value", "ValueType1Value"); this.dgvCurrentObject.Columns["ValueType1Value"].Visible = false; this.dgvCurrentObject.Columns.Add("DoesSomethingWithPerson", "DoesSomethingWithPerson"); this.dgvCurrentObject.Columns["DoesSomethingWithPerson"].Visible = false; this.dgvCurrentObject.Visible = false; this.dgvCurrentObject.CellBeginEdit += new System.Windows.Forms.DataGridViewCellCancelEventHandler(this.dgvCurrentObject_CellBeginEdit); this.Controls.Add(this.pnlSave); this.Controls.Add(this.dgvCurrentObject); // // connect // this.Select_ValueType1_connect = new SampleModelContext.ConnectionDelegate(GetConnection); // // testVar // this.testVar = new SampleModelContext(Select_ValueType1_connect); // // abstractTypeVar // this.abstractTypeVar = null; // // lbl // this.lblSelect = new System.Windows.Forms.Label(); this.lblSelect.Dock = System.Windows.Forms.DockStyle.Top; this.lblSelect.Name = "lblSelect"; this.lblSelect.Text = "Enter data to Select ValueType1 by:"; // // btn // this.btnSelect = new System.Windows.Forms.Button(); this.btnSelect.Location = new System.Drawing.Point(400, 10); this.btnSelect.Name = "btnSelect"; this.btnSelect.TabIndex = 3; this.btnSelect.Text = "Select"; this.btnSelect.UseVisualStyleBackColor = true; this.btnSelect.Click += new System.EventHandler(this.btnSelect_Click); // // dgv // this.dgvSelect = new System.Windows.Forms.DataGridView(); this.dgvSelect.Dock = System.Windows.Forms.DockStyle.Top; this.dgvSelect.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dgvSelect.Name = "dgvSelect"; this.dgvSelect.TabIndex = 0; this.dgvSelect.Columns.Add("ValueType1Value", "ValueType1Value"); this.dgvSelect.Columns.Add("DoesSomethingWithPerson", "DoesSomethingWithPerson"); this.dgvSelect.ScrollBars = System.Windows.Forms.ScrollBars.Both; this.dgvSelect.Height = 75; // // pnlDisplay // this.pnlDisplay = new System.Windows.Forms.Panel(); this.pnlDisplay.Dock = System.Windows.Forms.DockStyle.Top; this.pnlDisplay.AutoSize = true; this.pnlDisplay.Location = new System.Drawing.Point(0, 0); this.pnlDisplay.Name = "pnlDisplay"; this.pnlDisplay.AutoScroll = true; this.pnlDisplay.TabIndex = 1; this.pnlDisplay.Controls.Add(this.btnSelect); // // this // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; this.Controls.Add(this.pnlDisplay); this.Controls.Add(this.dgvSelect); this.Controls.Add(this.lblSelect); this.Name = "icSelectValueType1InputControl"; this.Size = new System.Drawing.Size(530, 490); ((System.ComponentModel.ISupportInitialize)this.dgvSelect).EndInit(); this.ResumeLayout(false); this.dgvCurrentObject.Height = this.dgvSelect.Height; this.pnlDisplay.Controls.Add(this.lblCurrentObject); this.pnlDisplay.Controls.Add(this.cbxSelectionMode); this.pnlDisplay.Controls.Add(this.lblSelectionMode); if (this.cbxSelectionMode.Items.Count > 0) { this.cbxSelectionMode.SelectedIndex = 0; } }
/// <summary>Required method for Designer support - do not modify the contents of this method with the code editor.</summary> private void InitializeComponent() { this.components = new System.ComponentModel.Container(); // // connect // this.Collection_ValueType1_connect = new SampleModelContext.ConnectionDelegate(GetConnection); // // testVar // this.testVar = new SampleModelContext(Collection_ValueType1_connect); // // abstractTypeVar // this.abstractTypeVar = null; // // lbl // this.lblCollection = new System.Windows.Forms.Label(); this.lblCollection.Dock = System.Windows.Forms.DockStyle.Top; this.lblCollection.Name = "lblCollection"; this.lblCollection.Text = "Click the Collection button to refresh the list of ValueType1 records."; // // btn // this.btnCollection = new System.Windows.Forms.Button(); this.btnCollection.Location = new System.Drawing.Point(400, 10); this.btnCollection.Name = "btnCollection"; this.btnCollection.TabIndex = 3; this.btnCollection.Text = "Collection"; this.btnCollection.UseVisualStyleBackColor = true; this.btnCollection.Click += new System.EventHandler(this.btnCollection_Click); // // dgv // this.dgvCollection = new System.Windows.Forms.DataGridView(); this.dgvCollection.Dock = System.Windows.Forms.DockStyle.Top; this.dgvCollection.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dgvCollection.Name = "dgvCollection"; this.dgvCollection.TabIndex = 0; this.dgvCollection.Columns.Add("ValueType1Value", "ValueType1Value"); this.dgvCollection.Columns.Add("DoesSomethingWithPerson", "DoesSomethingWithPerson"); this.dgvCollection.ScrollBars = System.Windows.Forms.ScrollBars.Both; this.dgvCollection.Height = 300; // // pnlDisplay // this.pnlDisplay = new System.Windows.Forms.Panel(); this.pnlDisplay.Dock = System.Windows.Forms.DockStyle.Top; this.pnlDisplay.AutoSize = true; this.pnlDisplay.Location = new System.Drawing.Point(0, 0); this.pnlDisplay.Name = "pnlDisplay"; this.pnlDisplay.AutoScroll = true; this.pnlDisplay.TabIndex = 1; this.pnlDisplay.Controls.Add(this.btnCollection); // // this // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; this.Controls.Add(this.pnlDisplay); this.Controls.Add(this.dgvCollection); this.Controls.Add(this.lblCollection); this.Name = "icCollectionValueType1InputControl"; this.Size = new System.Drawing.Size(530, 490); ((System.ComponentModel.ISupportInitialize)this.dgvCollection).EndInit(); this.ResumeLayout(false); }