public void RightToLeftPrecedence( SampleClass one, SampleClass two, dynamic target) { "Given an instance of a class with two properties set to variations of one" .x(() => one = new SampleClass { IntProperty = 1, StringProperty = "one" }); "And another instance with two properties set to variations of two" .x(() => { two = new SampleClass { IntProperty = 2, StringProperty = "two" }; }); "When I apply assign them giving one precedence" .x(() => { target = Objectify.Assign(new { }, two, one); }); "Then the output should contain the properties of the right most parameter" .x(() => { Assert.Equal(target.IntProperty, one.IntProperty); Assert.Equal(target.StringProperty, one.StringProperty); }); }
public void AdditionalProperty( SampleClass src, dynamic target) { "Given an instance of a class with two properties" .x(() => { src = new SampleClass { IntProperty = 6, StringProperty = "something" }; }); "When I assign it to a new object with an extra property" .x(() => { target = Objectify.Assign(new { AnotherProperty = "something else" }, src); }); "Then that object should have those properties" .x(() => { Assert.Equal(target.IntProperty, src.IntProperty); Assert.Equal(target.StringProperty, src.StringProperty); Assert.Equal(target.AnotherProperty, "something else"); }); }
//method to add the Object to the ArrayLst with its property's value, //which are provided by the user public void AddObject() { //to check whether if (textBox1.Text == "") { MessageBox.Show("Can not create Objects with no name!"); return; } else if ((textBox2.Text == "") && (textBox3.Text == "") && (textBox4.Text == "")) { MessageBox.Show("Can not create Objects with no properties at all"); return; } //Creating Object of class Objectify and storing all properties of it //from user input textboxes Objectify objectify = new Objectify(); objectify.name = textBox1.Text; objectify.property1 = textBox2.Text; objectify.property2 = textBox3.Text; objectify.property3 = textBox4.Text; //adding the Object with its properties in the ArrayList arraylist.Add((object)objectify); //adding this Object Name to the ComboBox so that //it can be accessed/referred easily from the //dropdown list comboBox1.Items.Add(objectify.name); }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { //NOT_SET is default if (comboBox1.SelectedItem == "NOT_SET") { groupBox1.Text = "No Object Selected"; label9.Text = "Null"; label10.Text = "Null"; label11.Text = "Null"; label12.Text = "Null"; } //<summary> //this for loop checks every Objects saved in the ArrayList //and the fetches the properties of each Object from that ArrayList. //In order to print out the properties of the Object, which is the selected item from the ComboBox, // it first compares the name of the Object saved in the ArrayList and the ComboBox selected item, //and if the names are same then only prints that out to the user as the output //</summary> for (int i = 0; i < arraylist.Count; i++) { Objectify Ob = (Objectify)arraylist[i]; if (string.Compare(comboBox1.SelectedItem.ToString(), Ob.name, true) == 0) { groupBox1.Text = Ob.name; label9.Text = Ob.name; label10.Text = Ob.property1; label11.Text = Ob.property2; label12.Text = Ob.property3; } } }
public void OverwriteProperty( SampleClass src, SampleClass target) { "Given an instance of a class with two properties" .x(() => src = new SampleClass { IntProperty = 6, StringProperty = "something" }); "When I assign it to a new object with an extra property" .x(() => { target = Objectify.Assign <SampleClass>(src, new { StringProperty = "something else" }); }); "Then that object should have those properties" .x(() => { Assert.Equal(src.IntProperty, target.IntProperty); Assert.Equal("something else", target.StringProperty); }); }
public void ActLikeAMapperWithAdditionalOverwritingProperties( SampleClass src, SampleClassTwo similarTarget) { "Given an instance of a class with two properties" .x(() => src = new SampleClass { IntProperty = 6, StringProperty = "something" }); "When I assign it to a new object with an extra property" .x(() => { similarTarget = Objectify.Assign <SampleClassTwo>(src, new { intproperty = 7 }, new { stringproperty = "seven" }); }); "Then that object should have those properties" .x(() => { Assert.Equal(7, similarTarget.IntProperty); Assert.Equal("seven", similarTarget.StringProperty); }); }
public void LikeForLike( SampleClass src, dynamic target) { "Given an instance of a class with two properties" .x(() => src = new SampleClass { IntProperty = 6, StringProperty = "something" }); "When I assign it to a new object" .x(() => { target = Objectify.Assign(new { }, src); }); "Then that object should have those properties" .x(() => { Assert.Equal(target.IntProperty, src.IntProperty); Assert.Equal(target.StringProperty, src.StringProperty); }); }
public void LikeForLike( SampleClass src, SampleClass target) { "Given an instance of a class with two properties" .x(() => src = new SampleClass { IntProperty = 6, StringProperty = "something" }); "When I assign it to a new object" .x(() => { target = Objectify.Assign <SampleClass>(src, src); }); "Then that object should have those properties" .x(() => { Assert.Equal(src.IntProperty, target.IntProperty); Assert.Equal(src.StringProperty, target.StringProperty); Assert.False(object.ReferenceEquals(src, target)); }); }
public void ActLikeAMapper( SampleClass src, SampleClassTwo similarTarget) { "Given an instance of a class with two properties" .x(() => src = new SampleClass { IntProperty = 6, StringProperty = "something" }); "When I assign it to a new object with an extra property" .x(() => { similarTarget = Objectify.Assign <SampleClassTwo>(src); }); "Then that object should have those properties" .x(() => { Assert.Equal(similarTarget.IntProperty, src.IntProperty); Assert.Equal(similarTarget.StringProperty, src.StringProperty); }); "And they shouldn't be the same reference" .x(() => Assert.False(ReferenceEquals(src, similarTarget))); }