public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { var concreteValue = (SourceClass)value; var result = new TargetClass { FullName = string.Format("{0} {1}", concreteValue.FirstName, concreteValue.LastName) }; return result; }
// [TestMethod] public void TestString() { SourceClass source = new SourceClass(); TargetClass target = new TargetClass(); BindingBase binding = new BindingBase(target, "Title", source, "Text", BindingMode.OneWay); binding.Bind(); source.Text = "Text!"; Assert.AreEqual( target.Title, source.Text ); }
public void TestListBinding2() { SourceClass source = new SourceClass(); TargetClass target = new TargetClass(); BindingBase binding = new BindingBase(target, "Items", source, "SourceItems", BindingMode.OneWay); source.SourceItems.Add("1"); binding.Bind(); Assert.IsTrue(target.Items[0] == "1"); source.SourceItems.Remove("1"); Assert.IsTrue(target.Items.Count == 0); }
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { var concreteValue = (SourceClass)value; var result = new TargetClass { Yes = ConvertYesNo(concreteValue.Yes), No = ConvertYesNo(concreteValue.No) }; return result; }
public void TestObjectIsNormallyGarbageCollected() { TargetClass targetClass = new TargetClass(); WeakReference weakRefTargetClass = new WeakReference(targetClass); targetClass = null; GCHelper.ForceAndWaitGarbageCollection(); Assert.False(weakRefTargetClass.IsAlive); }
private void buttonTargetFrom_Click(object sender, EventArgs e) { string name; double x, y, z; if (TargetClass.GetTargetPosition(out name, out x, out y, out z)) { SelectFromCoords(false); // enable system box textBox_From.Text = TargetClass.GetNameWithoutPrefix(name); UpdateFrom(false); } }
public void TestMethod1() { TargetClass target = new TargetClass( ); SourceClass source = new SourceClass( ); BindingBase binding = new BindingBase(target, "Text", source, "Val"); binding.Converter = new DoubleToStringConverter( ); binding.Bind( ); source.Val = 3.0f; Assert.IsTrue(target.Text == "3"); target.Text = "0.5"; Assert.IsTrue(source.Val == 0.5); }
public void SetAttack(float duration, Vector2Int pos, float damage, ElementalType ele, BaseCharacter attacker, List <ScriptableObjectAttackEffect> atkEffects, float effectChances) { GameObject nextT = TargetIndicatorManagerScript.Instance.GetTargetIndicator(AttackType.Tile); nextT.SetActive(true); TargetClass tc = new TargetClass(duration, nextT); nextT.transform.parent = transform; nextT.transform.localPosition = TargetsPosition[0]; Targets.Add(tc); UpdateQueue(); StartCoroutine(FireTarget(tc, pos, damage, ele, attacker, atkEffects, effectChances)); }
public void ObjectMapTest() { DateTime now = DateTime.Now; SourceClass a = new SourceClass { Name = "abc", Score = 10, DoTime = now }; TargetClass b = SweetMapper <SourceClass, TargetClass> .Map(a); Assert.IsTrue(b.DoTime == now && b.Name == "abc" && b.Score == 10); }
// [TestMethod] public void TestListRebind() { SourceClass source = new SourceClass(); TargetClass target = new TargetClass(); BindingBase binding = new BindingBase(target, "Items", source, "SourceItems", BindingMode.OneWay); binding.Bind(); source.SourceItems.Add("1"); // First change should not affect target list Assert.IsTrue(target.Items.Count == 0); source.SourceItems.Add("1"); Assert.IsTrue(target.Items[0] == "1"); source.SourceItems.Remove("1"); Assert.IsTrue(target.Items.Count == 0); }
public void RefreshRow(DataGridView vsc, DataGridViewRow vscrow, bool addattop = false) { SuspendLayout(); Point3D tpos; string name; TargetClass.GetTargetPosition(out name, out tpos); // tpos.? is NAN if no target UpdateRow(vsc, vscrow, addattop, statictoplines, tpos); // add= 0 , we do a refesh. If all=true, we do an insert at top UpdateEventsOnControls(this); ResumeLayout(); }
public static void TestConversion() { SourceClass source = new SourceClass(); TargetClass target = new TargetClass(); BindingBase binding = new BindingBase(target, "TargetInt", source, "SourceStr", BindingMode.OneWay); BindingBase binding2 = new BindingBase(target, "TargetStr", source, "SourceInt", BindingMode.OneWay); binding.Bind(); binding2.Bind(); source.SourceInt = 5; source.SourceStr = "4"; Assert.AreEqual(target.TargetInt, 4); Assert.AreEqual(target.TargetStr, "5"); }
public void RemoveConfigTest() { SweetMapper <SourceClass, TargetClass> .ClearConfig(); SourceClass a = new SourceClass { Name = "abc", DoTime = DateTime.Now }; TargetClass b = SweetMapper <SourceClass, TargetClass> .Map(a); Assert.IsTrue(b.DoTime == "" && b.Name == "abc"); }
private void Awake() { //Initialize the correct UnitType, and place it in variable thisUnit unitContainer = FindObjectOfType <UnitTypeContainer>(); unitTypes = unitContainer.unitTypes; for (int i = 0; i < unitTypes.Count; i++) { if (unitTypes[i].unitTypeName.Equals(unitTypeName)) { thisUnit = unitTypes[i]; break; } } //Basic For-loop to find the correct UnitType from container //Initialize the UnitType stats to this instance health = thisUnit.health; attackPower = thisUnit.attackPower; attackPerSecond = thisUnit.attackPerSecond; baseSpeed = thisUnit.baseSpeed; sizeRadius = thisUnit.sizeRadius; attackRadius = thisUnit.attackRadius; aggroRadius = thisUnit.aggroRadius; targets = thisUnit.targets; characteristcs = thisUnit.characteristcs; //Initialize some private stats as well: attackRad = attackRadius; //The tolrance distance for when the enemy starts "Attacking" the target instead of "Navigating" towards it. reachRad = attackRad * 1.2f; //Once the "Attacking" has started, we need to enlargen the attackDiameter, so that there won't occur any "following jitter", where the unit stops, but has to start navigating agian, because the enemy is out-of-reach on the next update. attackTimer = attackPerSecond; //Initialize the NavMeshAgent and assign stats to the agent's parameters agent = GetComponent <NavMeshAgent>(); agent.speed = baseSpeed; agent.radius = sizeRadius; //Assert the correct player id: thisPlayer = GetComponentInParent <PlayerID>().playerID; enemyPlayer = (thisPlayer == 1) ? 2 : 1; //Assert the correct TargetInformation to this unit targetInfo = GetComponent <UnitTargetInfo>(); targetInfo.SetTargetEnum(targets); targetInfo.SetCharacteristicsEnum(characteristcs); //Add the unit's Transform to the current battlefield units Hashset: targetManager = FindObjectOfType <TargetingManager>(); targetManager.RegisterUnit(gameObject.transform, thisPlayer); //Initialize the Unit States, so the game will orient the unit correctly starting from Update() currentState = AIstate.NoState; previousState = AIstate.NoState; }
public async Task Node() { var target = new TargetClass { SubProperty = new SubClass { Property1 = "PropertyValue1", Property2 = "PropertyValue2" } }; var result = await RoundTrip.Run(target); Assert.Equal("PropertyValue1", result.SubProperty?.Property1); }
public static BattleAction fromJSONObject(JSONObject json) { JSONObject inputArr = json.GetField("inputs"); List <JSONObject> inputList = inputArr.list; int targetClassInt = (int)inputList[0].n; int basePower = (int)inputList[1].n; int damageTypeId = (int)inputList[2].n; double chanceToHit = (double)inputList[3].n; TargetClass targetClass = (TargetClass)targetClassInt; CreatureType creatureType = CreatureType.creatureTypes[(CreatureType.Name)damageTypeId]; return(new DamageBattleAction(targetClass, basePower, creatureType, chanceToHit)); }
public void ObjectInitializersTest() { // object initializer 사용 TargetClass t = new TargetClass { intMember = 5, strMember = "ohyecloudy", Property = 1, }; Assert.AreEqual(5, t.intMember); Assert.AreEqual("ohyecloudy", t.strMember); Assert.AreEqual(1, t.Property); }
public void TestUnsubscribeWorks() { TargetClass target = new TargetClass(); MulticastWeakDelegate <Action> testInst = new MulticastWeakDelegate <Action>(); testInst.Add(target.TestMethod); testInst.GetDelegate()(); Assert.AreEqual(1, target.CallCount); testInst.Remove(target.TestMethod); var d = testInst.GetDelegate(); Assert.IsNull(d); }
public void Property_1_RepeatReflection() { var test = new TargetClass(); int tmp = 0; var get = Reflection.CreateGetPropertyValueDelegate <int>(typeof(TargetClass).GetProperty("Property")); var set = Reflection.CreateSetPropertyValueDelegate <int>(typeof(TargetClass).GetProperty("Property")); for (int i = 0; i < repeats; i++) { set(test, i); tmp = get(test); } }
public void Field_2_RepeatILEmit() { var test = new TargetClass(); int tmp = 0; var get = ILEmit.CreateGetFieldValueDelegate <int>(typeof(TargetClass).GetField("Field")); var set = ILEmit.CreateSetFieldValueDelegate <int>(typeof(TargetClass).GetField("Field")); for (int i = 0; i < repeats; i++) { set(test, i); tmp = get(test); } }
public void Bookmark(BookmarkClass bk) // from multiple places, update this bookmark, region or system.. { string note = ""; string name; if (!bk.isRegion) { InitialisePos(bk.x, bk.y, bk.z); SystemNoteClass sn = SystemNoteClass.GetNoteOnSystem(bk.StarName); note = (sn != null) ? sn.Note : ""; name = bk.StarName; } else { // region, set position, set name InitialisePos(bk.x, bk.y, bk.z); name = bk.Heading; } this.Text = "Update Bookmark".T(EDTx.BookmarkForm_UB); buttonOK.Text = "Update".T(EDTx.BookmarkForm_Update); textBoxName.Text = name; textBoxName.ReadOnly = !bk.isRegion; textBoxName.ReturnPressed += (ctrl) => { return(true); }; textBoxBookmarkNotes.Text = bk.Note; textBoxBookmarkNotes.CursorToEnd(); textBoxBookmarkNotes.ScrollToCaret(); textBoxTravelNote.Text = note; textBoxTime.Text = EDDConfig.Instance.ConvertTimeToSelectedFromUTC(bk.TimeUTC).ToString(); checkBoxTarget.Checked = bk.id == TargetClass.GetTargetBookmark(); // who is the target of a bookmark (0=none) //foreach (Control c in panelOuter.Controls) System.Diagnostics.Debug.WriteLine("All Control {0} at {1}", c.Name, c.Top); if (bk.isRegion) { HideEDSM(); HideTravelNote(); // in order note HideSurfaceBookmarks(); } else { var edsm = new EDSMClass(); edsmurl = edsm.GetUrlToSystem(name); SurfaceBookmarks.Init(bk.StarName, helist, bk.PlanetaryMarks); } buttonOK.Enabled = true; }
public void ObjectInitializersTest() { // object initializer 사용 TargetClass t = new TargetClass { intMember = 5, strMember = "ohyecloudy", Property = 1, }; Assert.Equal(5, t.intMember); Assert.Equal("ohyecloudy", t.strMember); Assert.Equal(1, t.Property); }
public void Advices_InjectAfterIteratorMethod_WithArgs() { Checker.Passed = false; var a = new TargetClass(); foreach (var d in a.Get1("test")) { Assert.IsFalse(Checker.Passed); d.Equals('a'); } Assert.IsTrue(Checker.Passed); }
public void Advices_InjectAfterIteratorMethod2() { Checker.Passed = false; var a = new TargetClass(); foreach (var d in a.Get2()) { Assert.False(Checker.Passed); d.Equals('a'); } Assert.True(Checker.Passed); }
public void Update(BookmarkClass bk) // from multiple places, update this bookmark, region or system.. { string note = ""; string name; if (!bk.isRegion) { ISystem s = SystemClassDB.GetSystem(bk.StarName); if (s != null) // paranoia { InitialisePos(s); } SystemNoteClass sn = SystemNoteClass.GetNoteOnSystem(bk.StarName); note = (sn != null) ? sn.Note : ""; name = bk.StarName; } else { // region, set position, set name InitialisePos(bk.x, bk.y, bk.z); name = bk.Heading; } this.Text = "Update Bookmark"; buttonOK.Text = "Update"; textBoxName.Text = name; textBoxName.ReadOnly = !bk.isRegion; textBoxBookmarkNotes.Text = bk.Note; textBoxBookmarkNotes.CursorToEnd(); textBoxBookmarkNotes.ScrollToCaret(); textBoxTravelNote.Text = note; textBoxTime.Text = bk.Time.ToString(); checkBoxTarget.Checked = bk.id == TargetClass.GetTargetBookmark(); // who is the target of a bookmark (0=none) if (bk.isRegion) { HideEDSM(); HideTravelNote(); HideSurfaceBookmarks(); } else { var edsm = new EDSMClass(); edsmurl = edsm.GetUrlToEDSMSystem(name); userControlSurfaceBookmarks.Init(bk.StarName, bk.PlanetaryMarks); } buttonOK.Enabled = true; }
public void TestConversion( ) { SourceClass source = new SourceClass(); TargetClass target = new TargetClass(); BindingBase binding = new BindingBase(target, "TargetInt", source, "SourceStr", BindingMode.OneWay); BindingBase binding2 = new BindingBase(target, "TargetStr", source, "SourceInt", BindingMode.OneWay); binding.Bind(); binding2.Bind( ); source.SourceInt = 5; source.SourceStr = "4"; Assert.AreEqual(target.TargetInt, 4); Assert.AreEqual(target.TargetStr, "5"); }
public void Node() { var target = new TargetClass { SubProperty = new SubClass { Property1 = "PropertyValue1", Property2 = "PropertyValue2" } }; var result = RoundTrip.Run(target); Assert.Equal("PropertyValue1", result.SubProperty.Property1); }
public void TestGetWeakReferenceDelegateSafeAllowsObjectToBeGarabageCollected() { TargetClass targetClass = new TargetClass(); WeakReference weakRefTargetClass = new WeakReference(targetClass); SomeDelegate d = targetClass.GetWeakReferenceDelegateSafe(); string actualTextResultFromCall = d(); targetClass = null; GCHelper.ForceAndWaitGarbageCollection(); Assert.False(weakRefTargetClass.IsAlive); //we also make sure the call to the method is done Assert.Equal(ExpectedText, actualTextResultFromCall); }
public MethodToHook(SmaliAnnotation annot, SmaliMethod interceptor) { TargetClass = annot.Properties["clazz"].Trim(); TargetMethod = annot.Properties["method"].Trim(); Interceptor = interceptor; TargetClassFormatted = string.Format("L{0};", TargetClass.Replace('.', '/')); string[] split = TargetMethod.Split(' '); string when = split[0].Trim(); if (when == "after") { HookAfter = true; } else if (when == "before") { HookBefore = true; } else { throw new Exception("Not specified when to hook method"); } if (split.Length >= 3) { if (split[1].Trim() == "static") { IsStatic = true; } else if (split[1].Trim() == "nostatic") { IsStatic = false; } } string signature = split[split.Length - 1].Trim(); int firstParenthesis = signature.IndexOf('('); if (firstParenthesis >= 0) { } else { MethodName = signature; } }
public bool Equals(TargetClass other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(other.Boolean.Equals(Boolean) && other.Byte == Byte && other.Char == Char && other.DateTime.Equals(DateTime) && other.DateTimeOffset.Equals(DateTimeOffset) && other.Decimal == Decimal && other.Double == Double && other.Float == Float && other.Int == Int && other.Guid.Equals(Guid) && other.Long == Long && Equals(other.String, String) && other.TimeSpan.Equals(TimeSpan) && Equals(other.Uri, Uri)); }
public void GetPropatyNamesWithAttribute() { // Arrange var target = new TargetClass(); // Act var actual = ValidationUtility.GetPropatyNamesWithAttribute(typeof(TargetClass)); // Assert var expected = new List <string> { "Id", "Message" }; Assert.True(TestHelper.IsSameCollection(expected, (List <string>)actual)); }
public void ExistingClassExistingIrrelevantFields() { SourceWebPage sourceWebPage = new SourceWebPage { ClassFullName = "Test1.TestSourceClass", PageUrl = "TestSourceClass.aspx", Controls = new List <SourceWebControl>() { new SourceWebControl { ClassFullName = "System.Web.UI.WebControls.HyperLink", FieldName = "NewTargetField" } } }; var targetClass = new TargetClass() { TargetFieldList = new List <TargetField>() { new TargetField { IsDirty = false, SourceClassFullName = "TestSourcenamespace.TestSourceClass", SourceFieldName = "ExistingTargetField", TargetControlType = EnumTargetControlType.Unknown, TargetFieldName = "ExistingTargetFieldName" } } }; var targetModelGenerator = new TargetModelGenerator(); targetClass = targetModelGenerator.UpdateClass(sourceWebPage, targetClass); Assert.AreEqual(2, targetClass.TargetFieldList.Count); TestValidators.ValidateTargetField(targetClass.TargetFieldList[0], isDirty: false, sourceClassFullName: "TestSourcenamespace.TestSourceClass", sourceFieldName: "ExistingTargetField", targetControlType: EnumTargetControlType.Unknown, targetFieldName: "ExistingTargetFieldName"); TestValidators.ValidateTargetField(targetClass.TargetFieldList[1], isDirty: true, sourceClassFullName: "System.Web.UI.WebControls.HyperLink", sourceFieldName: "NewTargetField", targetControlType: EnumTargetControlType.Link, targetFieldName: "NewTargetField"); }
// [TestMethod] public void TestMethod1() { SourceClass source = new SourceClass( ); TargetClass target = new TargetClass( ); BindingBase binding = new BindingBase( target, "TargetStr", source, "SourceInt" ); BindingResult lastResult = null; binding.OnBinding += result => { lastResult = result; }; binding.Bind( ); target.TargetStr = "5"; Assert.IsTrue( source.SourceInt == 5 ); target.TargetStr = "invalid int"; Assert.IsTrue(source.SourceInt == 0); Assert.IsTrue( lastResult.hasConversionError ); }
// [TestMethod] public void TestMethod1() { SourceClass source = new SourceClass( ); TargetClass target = new TargetClass( ); BindingBase binding = new BindingBase(target, "S", source, "Str"); binding.Adapter = new MyAdapter( ); binding.Bind(); source.Str = "123"; Assert.IsTrue(target.GetTargetStr( ) == "123"); target.SetTargetStr("456"); Assert.IsTrue(source.Str == "456"); binding.Unbind( ); source.Str = "123"; Assert.IsTrue(target.GetTargetStr() == "456"); }
public void TestMethod1() { using (ShimsContext.Create()) { ShimShimClass x = new ShimShimClass { NowGet = () => { return(DateTime.Now); } }; var a = new TargetClass(); if (a.DoSomething().Year != 2017) { Assert.Fail(); } } }
// [TestMethod] public void TestListBinding() { SourceClass source = new SourceClass( ); TargetClass target = new TargetClass( ); BindingBase binding = new BindingBase(target, "Items", source, "SourceItems", BindingMode.OneWay); binding.Bind( ); source.SourceItems.Add("1"); Assert.IsTrue(target.Items[0] == "1"); source.SourceItems.Add("2"); Assert.IsTrue(target.Items[0] == "1"); Assert.IsTrue(target.Items[1] == "2"); source.SourceItems.Remove("1"); Assert.IsTrue(target.Items.Count == 1); Assert.IsTrue(target.Items[0] == "2"); }
public void Should_work() { var source = new SourceClass() { Name = "SourceName", Code = "SourceCode" }; Interface3 dest = new TargetClass() { Name = "TargetName", Code = "TargetCode" }; Mapper.Map(source, dest); dest.Code.ShouldBe("TargetCode"); dest.Name.ShouldBe("SourceName"); }
// [TestMethod] public void TestMethod1() { SourceClass source = new SourceClass( ); TargetClass target = new TargetClass( ); BindingBase binding = new BindingBase(target, "TargetStr", source, "SourceInt"); BindingResult lastResult = null; binding.OnBinding += result => { lastResult = result; }; binding.Bind( ); target.TargetStr = "5"; Assert.IsTrue(source.SourceInt == 5); target.TargetStr = "invalid int"; Assert.IsTrue(source.SourceInt == 0); Assert.IsTrue(lastResult.hasConversionError); }
public void DisableAutoMapTest() { SweetMapper <SourceClass, TargetClass> .SetConfig((source, target) => { target.DoTime = source.DoTime.ToString("yyyy-MM-dd"); }, true); DateTime now = DateTime.Now; SourceClass a = new SourceClass { Name = "abc", DoTime = now }; TargetClass b = SweetMapper <SourceClass, TargetClass> .Map(a); Assert.IsTrue(b.DoTime == now.ToString("yyyy-MM-dd") && b.Name == ""); }
public void TestProperUsageofWeakRef2() { TargetClass myTestObj = new TargetClass(); WeakReference w = new WeakReference(myTestObj); myTestObj = null; // no matter what we do the garbage collection won't happen GCHelper.ForceAndWaitGarbageCollection(); TargetClass output = (TargetClass)w.Target; GCHelper.ForceAndWaitGarbageCollection(); if (output == null) throw new Exception("Object was already garbage collect, wait!? what? how?"); // does not affect us, we already have a strong reference in the // current function, so the object won't be garbage collected GCHelper.ForceAndWaitGarbageCollection(); Assert.NotNull(output); }
public void TestBadWeakReferenceUsage2() { TargetClass myTestObj = new TargetClass(); WeakReference w = new WeakReference(myTestObj); myTestObj = null; // This just won't clear the targetClass from memory... GCHelper.ForceAndWaitGarbageCollection(); if (w.IsAlive) { //suppose we have a collection here GCHelper.ForceAndWaitGarbageCollection(); TargetClass output = (TargetClass)w.Target; Assert.NotNull(output); } else { throw new Exception("Object was already garbage collect, wait!? what? how?"); } }
public void CustomObjectTest2 () { // set the binding, set the datacontext, then create the hierarchy Canvas c = new Canvas (); TargetClass tc = new TargetClass (); tc.SetBinding (TargetClass.TestProperty, new Binding ()); c.DataContext = "hi"; Assert.IsFalse (tc.GetPropertyChanged (), "#1"); c.Children.Add (tc); Assert.IsFalse (tc.GetPropertyChanged (), "#2"); Assert.IsNull (tc.Test, "#3"); }
public void CustomObjectTest1 () { // create the hierarchy, set the binding, and then set datacontext Canvas c = new Canvas (); TargetClass tc = new TargetClass (); c.Children.Add (tc); tc.SetBinding (TargetClass.TestProperty, new Binding ()); Assert.IsFalse (tc.GetPropertyChanged (), "#1"); c.DataContext = "hi"; Assert.IsTrue (tc.GetPropertyChanged (), "#2"); Assert.AreEqual ("hi", tc.Test, "#3"); }
public Adapter(TargetClass target) { _target = target; }
/// <summary> /// Looks for results for the specified targets. /// </summary> /// <param name="result">The result to examine</param> /// <param name="targets">The targets to search for</param> /// <param name="targetClass">The class of targets</param> /// <param name="targetsMissingResults">An optional list to be populated with missing targets</param> /// <param name="skippedResultsAreOK">If true, a status of "skipped" counts as having valid results /// for that target. Otherwise, a skipped target is treated as equivalent to a missing target.</param> /// <returns>False if there were missing results, true otherwise.</returns> private bool CheckResults(BuildResult result, List<string> targets, TargetClass targetClass, HashSet<string> targetsMissingResults, bool skippedResultsAreOK) { bool returnValue = true; foreach (string target in targets) { if (!result.HasResultsForTarget(target) || (result[target].ResultCode == TargetResultCode.Skipped && !skippedResultsAreOK)) { if (null != targetsMissingResults) { targetsMissingResults.Add(target); returnValue = false; } else { return false; } } else { // If the result was a failure and we have not seen any skipped targets up to this point, then we conclude we do // have results for this request, and they indicate failure. if (result[target].ResultCode == TargetResultCode.Failure && (targetsMissingResults == null || targetsMissingResults.Count == 0)) { return true; } } } return returnValue; }
// [TestMethod] public void TestValidation( ) { SourceClass source = new SourceClass(); TargetClass target = new TargetClass(); BindingBase binding = new BindingBase(target, "TargetStr", source, "SourceInt", BindingMode.OneWay); binding.UpdateSourceIfBindingFails = false; binding.Bind(); target.TargetInt = 1; source.SourceStr = "invalid int"; Assert.IsTrue( target.TargetInt == 1 ); }
public void Run() { var targetClass = new TargetClass(); Assert.Throws<ArgumentException>(() => targetClass.Method(string.Empty)); }
public void DPSetValuePreferred_TwoWay_sl3() { var str = "test_string"; var source = new TargetClass (); source.SetValue(TargetClass.TestProperty, str); var target = new TargetClass(); target.SetBinding(TargetClass.TestProperty, new Binding("Test") { Source = source, Mode = BindingMode.TwoWay }); Assert.IsFalse(source.SetterCalled, "#1"); Assert.IsFalse(source.GetterCalled, "#2"); Assert.IsFalse(target.SetterCalled, "#3"); Assert.IsFalse(target.GetterCalled, "#4"); source.SetValue(TargetClass.TestProperty, "otherstring"); Assert.IsFalse(source.SetterCalled, "#5"); Assert.IsFalse(source.GetterCalled, "#6"); Assert.IsFalse(target.SetterCalled, "#7"); Assert.IsFalse(target.GetterCalled, "#8"); target.SetValue (TargetClass.TestProperty, "somestring"); Assert.IsFalse(source.SetterCalled, "#9"); Assert.IsFalse(source.GetterCalled, "#10"); Assert.IsFalse(target.SetterCalled, "#11"); Assert.IsFalse(target.GetterCalled, "#12"); }
public StructWithRef(object any) { Ref = null; }
public Adapter(TargetClass target) { this.target = target; }
public void TestMethod1() { TargetClass target = new TargetClass( ); SourceClass source = new SourceClass( ); BindingBase binding = new BindingBase( target, "Text", source, "Val" ); binding.Converter = new DoubleToStringConverter( ); binding.Bind( ); source.Val = 3.0f; Assert.IsTrue( target.Text == "3" ); target.Text = "0.5"; Assert.IsTrue( source.Val == 0.5 ); }
private static WeakReference WeakReference() { TargetClass myTestObj = new TargetClass(); WeakReference w = new WeakReference(myTestObj); return w; }
public void Run() { var targetClass = new TargetClass(); Assert.Throws<ArgumentNullException>(() => targetClass.Method(null)); }
// [TestMethod] public void TestMethod1() { SourceClass source = new SourceClass( ); TargetClass target = new TargetClass( ); BindingBase binding = new BindingBase( target, "S", source, "Str" ); binding.Adapter = new MyAdapter( ); binding.Bind(); source.Str = "123"; Assert.IsTrue( target.GetTargetStr( ) == "123" ); target.SetTargetStr( "456" ); Assert.IsTrue(source.Str == "456"); binding.Unbind( ); source.Str = "123"; Assert.IsTrue(target.GetTargetStr() == "456"); }