How to use WeakPropertyValue class of Telerik.JustMock.AutoMock.Ninject.Parameters package

Best JustMockLite code snippet using Telerik.JustMock.AutoMock.Ninject.Parameters.WeakPropertyValue

Run JustMockLite automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

WeakPropertyValue.cs

Source: WeakPropertyValue.cs Github

copy
1//-------------------------------------------------------------------------------
2// <copyright file="WeakPropertyValue.cs" company="Ninject Project Contributors">
3//   Copyright (c) 2009-2013 Ninject Project Contributors
4//   Authors: Remo Gloor ([email protected])
5//           
6//   Dual-licensed under the Apache License, Version 2.0, and the Microsoft Public License (Ms-PL).
7//   you may not use this file except in compliance with one of the Licenses.
8//   You may obtain a copy of the License at
9//
10//       http://www.apache.org/licenses/LICENSE-2.0
11//   or
12//       http://www.microsoft.com/opensource/licenses.mspx
13//
14//   Unless required by applicable law or agreed to in writing, software
15//   distributed under the License is distributed on an "AS IS" BASIS,
16//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17//   See the License for the specific language governing permissions and
18//   limitations under the License.
19// </copyright>
20//-------------------------------------------------------------------------------
21
22namespace Telerik.JustMock.AutoMock.Ninject.Parameters
23{
24    using System;
25
26    /// <summary>
27    /// Overrides the injected value of a property.
28    /// Keeps a weak reference to the value.
29    /// </summary>
30    public class WeakPropertyValue : Parameter, IPropertyValue
31    {
32        private readonly WeakReference weakReference;
33
34        /// <summary>
35        /// Initializes a new instance of the <see cref="WeakPropertyValue"/> class.
36        /// </summary>
37        /// <param name="name">The name of the property to override.</param>
38        /// <param name="value">The value to inject into the property.</param>
39        public WeakPropertyValue(string name, object value)
40            : base(name, (object)null, false)
41        {
42            this.weakReference = new WeakReference(value);
43            this.ValueCallback = (ctx, target) => this.weakReference.Target;            
44        }
45        
46    }
47}
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

Most used methods in WeakPropertyValue

Run Selenium Automation Tests on LambdaTest Cloud Grid

Trigger Selenium automation tests on a cloud-based Grid of 3000+ real browsers and operating systems.

Test now for Free
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)