Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(bool)

Here are the examples of the csharp api Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(bool) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

845 Examples 7

19 View Source File : WeakActionTest.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestPublicClreplacedAnonymousMethod()
        {
            Reset();

            const int index = 99;

            _itemPublic = new PublicTestClreplaced(index);
            _reference = new WeakReference(_itemPublic);

            _action = _itemPublic.GetAction(WeakActionTestCase.AnonymousMethod);

            replacedert.IsTrue(_reference.IsAlive);
            replacedert.IsTrue(_action.IsAlive);

            _action.Execute();

            replacedert.AreEqual(
                PublicTestClreplaced.Expected + index,
                PublicTestClreplaced.Result);

            _itemPublic = null;
            GC.Collect();

#if SILVERLIGHT
            replacedert.IsTrue(_reference.IsAlive); // Anonymous, private and internal methods cannot be GCed
            _action = null;
            GC.Collect();
            replacedert.IsFalse(_reference.IsAlive);
#else
            replacedert.IsFalse(_reference.IsAlive);
#endif
        }

19 View Source File : WeakActionTest.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestPublicClreplacedAnonymousStaticMethod()
        {
            Reset();

            _itemPublic = new PublicTestClreplaced();
            _reference = new WeakReference(_itemPublic);

            _action = _itemPublic.GetAction(WeakActionTestCase.AnonymousStaticMethod);

            replacedert.IsTrue(_reference.IsAlive);
            replacedert.IsTrue(_action.IsAlive);

            _action.Execute();

            replacedert.AreEqual(
                PublicTestClreplaced.Expected,
                PublicTestClreplaced.Result);

            _itemPublic = null;
            GC.Collect();

            replacedert.IsFalse(_reference.IsAlive);
        }

19 View Source File : WeakActionTest.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestInternalClreplacedPublicNamedMethod()
        {
            Reset();

            const int index = 99;

            _itemInternal = new InternalTestClreplaced(index);

            _action = _itemInternal.GetAction(WeakActionTestCase.PublicNamedMethod);

            _reference = new WeakReference(_itemInternal);
            replacedert.IsTrue(_reference.IsAlive);
            replacedert.IsTrue(_action.IsAlive);

            _action.Execute();

            replacedert.AreEqual(
                InternalTestClreplaced.Expected + InternalTestClreplaced.Public + index,
                InternalTestClreplaced.Result);

            _itemInternal = null;
            GC.Collect();

#if SILVERLIGHT
            replacedert.IsTrue(_reference.IsAlive); // Anonymous, private and internal methods cannot be GCed
            _action = null;
            GC.Collect();
            replacedert.IsFalse(_reference.IsAlive);
#else
            replacedert.IsFalse(_reference.IsAlive);
#endif
        }

19 View Source File : WeakActionTest.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestInternalClreplacedPublicStaticMethod()
        {
            Reset();

            _itemInternal = new InternalTestClreplaced();
            _reference = new WeakReference(_itemInternal);

            _action = _itemInternal.GetAction(WeakActionTestCase.PublicStaticMethod);

            replacedert.IsTrue(_reference.IsAlive);
            replacedert.IsTrue(_action.IsAlive);

            _action.Execute();

            replacedert.AreEqual(
                InternalTestClreplaced.Expected + InternalTestClreplaced.PublicStatic,
                InternalTestClreplaced.Result);

            _itemInternal = null;
            GC.Collect();

            replacedert.IsFalse(_reference.IsAlive);
        }

19 View Source File : WeakActionTest.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestInternalClreplacedInternalNamedMethod()
        {
            Reset();

            const int index = 99;

            _itemInternal = new InternalTestClreplaced(index);
            _reference = new WeakReference(_itemInternal);

            _action = _itemInternal.GetAction(WeakActionTestCase.InternalNamedMethod);

            replacedert.IsTrue(_reference.IsAlive);
            replacedert.IsTrue(_action.IsAlive);

            _action.Execute();

            replacedert.AreEqual(
                InternalTestClreplaced.Expected + InternalTestClreplaced.Internal + index,
                InternalTestClreplaced.Result);

            _itemInternal = null;
            GC.Collect();

#if SILVERLIGHT
            replacedert.IsTrue(_reference.IsAlive); // Anonymous, private and internal methods cannot be GCed
            _action = null;
            GC.Collect();
            replacedert.IsFalse(_reference.IsAlive);
#else
            replacedert.IsFalse(_reference.IsAlive);
#endif
        }

19 View Source File : WeakActionTest.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestInternalClreplacedInternalStaticMethod()
        {
            Reset();

            _itemInternal = new InternalTestClreplaced();
            _reference = new WeakReference(_itemInternal);

            _action = _itemInternal.GetAction(WeakActionTestCase.InternalStaticMethod);

            replacedert.IsTrue(_reference.IsAlive);
            replacedert.IsTrue(_action.IsAlive);

            _action.Execute();

            replacedert.AreEqual(
                InternalTestClreplaced.Expected + InternalTestClreplaced.InternalStatic,
                InternalTestClreplaced.Result);

            _itemInternal = null;
            GC.Collect();

            replacedert.IsFalse(_reference.IsAlive);
        }

19 View Source File : WeakActionTest.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestInternalClreplacedPrivateNamedMethod()
        {
            Reset();

            const int index = 99;

            _itemInternal = new InternalTestClreplaced(index);
            _reference = new WeakReference(_itemInternal);

            _action = _itemInternal.GetAction(WeakActionTestCase.PrivateNamedMethod);

            replacedert.IsTrue(_reference.IsAlive);
            replacedert.IsTrue(_action.IsAlive);

            _action.Execute();

            replacedert.AreEqual(
                InternalTestClreplaced.Expected + InternalTestClreplaced.Private + index,
                InternalTestClreplaced.Result);

            _itemInternal = null;
            GC.Collect();

#if SILVERLIGHT
            replacedert.IsTrue(_reference.IsAlive); // Anonymous, private and internal methods cannot be GCed
            _action = null;
            GC.Collect();
            replacedert.IsFalse(_reference.IsAlive);
#else
            replacedert.IsFalse(_reference.IsAlive);
#endif
        }

19 View Source File : WeakActionTest.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestInternalClreplacedPrivateStaticMethod()
        {
            Reset();

            _itemInternal = new InternalTestClreplaced();
            _reference = new WeakReference(_itemInternal);

            _action = _itemInternal.GetAction(WeakActionTestCase.PrivateStaticMethod);

            replacedert.IsTrue(_reference.IsAlive);
            replacedert.IsTrue(_action.IsAlive);

            _action.Execute();

            replacedert.AreEqual(
                InternalTestClreplaced.Expected + InternalTestClreplaced.PrivateStatic,
                InternalTestClreplaced.Result);

            _itemInternal = null;
            GC.Collect();

            replacedert.IsFalse(_reference.IsAlive);
        }

19 View Source File : WeakActionTest.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestInternalClreplacedAnonymousMethod()
        {
            Reset();

            const int index = 99;

            _itemInternal = new InternalTestClreplaced(index);
            _reference = new WeakReference(_itemInternal);

            _action = _itemInternal.GetAction(WeakActionTestCase.AnonymousMethod);

            replacedert.IsTrue(_reference.IsAlive);
            replacedert.IsTrue(_action.IsAlive);

            _action.Execute();

            replacedert.AreEqual(
                InternalTestClreplaced.Expected + index,
                InternalTestClreplaced.Result);

            _itemInternal = null;
            GC.Collect();

#if SILVERLIGHT
            replacedert.IsTrue(_reference.IsAlive); // Anonymous, private and internal methods cannot be GCed
            _action = null;
            GC.Collect();
            replacedert.IsFalse(_reference.IsAlive);
#else
            replacedert.IsFalse(_reference.IsAlive);
#endif
        }

19 View Source File : WeakActionTest.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestInternalClreplacedAnonymousStaticMethod()
        {
            Reset();

            _itemInternal = new InternalTestClreplaced();
            _reference = new WeakReference(_itemInternal);

            _action = _itemInternal.GetAction(WeakActionTestCase.AnonymousStaticMethod);

            replacedert.IsTrue(_reference.IsAlive);
            replacedert.IsTrue(_action.IsAlive);

            _action.Execute();

            replacedert.AreEqual(
                InternalTestClreplaced.Expected,
                InternalTestClreplaced.Result);

            _itemInternal = null;
            GC.Collect();

            replacedert.IsFalse(_reference.IsAlive);
        }

19 View Source File : WeakActionTest.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestStaticMethodWithNullTarget()
        {
            Reset();
            var action = new WeakAction(null, DoStuffStatic);
            replacedert.IsTrue(action.IsAlive);
        }

19 View Source File : WeakActionTest.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestStaticMethodWithNonNullTarget()
        {
            Reset();

            _common = new CommonTestClreplaced();
            _reference = new WeakReference(_common);
            replacedert.IsTrue(_reference.IsAlive);

            var action = new WeakAction(_common, DoStuffStatic);
            replacedert.IsTrue(action.IsAlive);

            _common = null;
            GC.Collect();

            replacedert.IsFalse(_reference.IsAlive);
            replacedert.IsFalse(action.IsAlive);
        }

19 View Source File : WeakFuncGenericNestedTest.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestPublicClreplacedPublicNamedMethod()
        {
            Reset();

            const int index = 99;
            const string parameter = "My parameter";

            _itemPublic = new PublicNestedTestClreplaced<string>(index);

            _action = _itemPublic.GetFunc(WeakActionTestCase.PublicNamedMethod);

            _reference = new WeakReference(_itemPublic);
            replacedert.IsTrue(_reference.IsAlive);
            replacedert.IsTrue(_action.IsAlive);

            var result = _action.Execute(parameter);

            replacedert.AreEqual(
                PublicNestedTestClreplaced<string>.Expected + PublicNestedTestClreplaced<string>.Public + index + parameter,
                PublicNestedTestClreplaced<string>.Result);
            replacedert.AreEqual(
                PublicNestedTestClreplaced<string>.Expected + PublicNestedTestClreplaced<string>.Public + index + parameter,
                result);

            _itemPublic = null;
            GC.Collect();

            replacedert.IsFalse(_reference.IsAlive);
        }

19 View Source File : WeakFuncGenericNestedTest.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestPublicClreplacedPublicStaticMethod()
        {
            Reset();

            const string parameter = "My parameter";

            _itemPublic = new PublicNestedTestClreplaced<string>();
            _reference = new WeakReference(_itemPublic);

            _action = _itemPublic.GetFunc(WeakActionTestCase.PublicStaticMethod);

            replacedert.IsTrue(_reference.IsAlive);
            replacedert.IsTrue(_action.IsAlive);

            var result = _action.Execute(parameter);

            replacedert.AreEqual(
                PublicNestedTestClreplaced<string>.Expected + PublicNestedTestClreplaced<string>.PublicStatic + parameter,
                PublicNestedTestClreplaced<string>.Result);
            replacedert.AreEqual(
                PublicNestedTestClreplaced<string>.Expected + PublicNestedTestClreplaced<string>.PublicStatic + parameter,
                result);

            _itemPublic = null;
            GC.Collect();

            replacedert.IsFalse(_reference.IsAlive);
        }

19 View Source File : WeakFuncGenericNestedTest.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestPublicClreplacedInternalNamedMethod()
        {
            Reset();

            const string parameter = "My parameter";
            const int index = 99;

            _itemPublic = new PublicNestedTestClreplaced<string>(index);
            _reference = new WeakReference(_itemPublic);

            _action = _itemPublic.GetFunc(WeakActionTestCase.InternalNamedMethod);

            replacedert.IsTrue(_reference.IsAlive);
            replacedert.IsTrue(_action.IsAlive);

            var result = _action.Execute(parameter);

            replacedert.AreEqual(
                PublicNestedTestClreplaced<string>.Expected + PublicNestedTestClreplaced<string>.Internal + index + parameter,
                PublicNestedTestClreplaced<string>.Result);
            replacedert.AreEqual(
                PublicNestedTestClreplaced<string>.Expected + PublicNestedTestClreplaced<string>.Internal + index + parameter,
                result);

            _itemPublic = null;
            GC.Collect();

#if SILVERLIGHT
            replacedert.IsTrue(_reference.IsAlive); // Anonymous, private and internal methods cannot be GCed
            _action = null;
            GC.Collect();
            replacedert.IsFalse(_reference.IsAlive);
#else
            replacedert.IsFalse(_reference.IsAlive);
#endif
        }

19 View Source File : WeakFuncGenericNestedTest.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestPublicClreplacedPrivateStaticMethod()
        {
            Reset();

            const string parameter = "My parameter";

            _itemPublic = new PublicNestedTestClreplaced<string>();
            _reference = new WeakReference(_itemPublic);

            _action = _itemPublic.GetFunc(WeakActionTestCase.PrivateStaticMethod);

            replacedert.IsTrue(_reference.IsAlive);
            replacedert.IsTrue(_action.IsAlive);

            var result = _action.Execute(parameter);

            replacedert.AreEqual(
                PublicNestedTestClreplaced<string>.Expected + PublicNestedTestClreplaced<string>.PrivateStatic + parameter,
                PublicNestedTestClreplaced<string>.Result);
            replacedert.AreEqual(
                PublicNestedTestClreplaced<string>.Expected + PublicNestedTestClreplaced<string>.PrivateStatic + parameter,
                result);

            _itemPublic = null;
            GC.Collect();

            replacedert.IsFalse(_reference.IsAlive);
        }

19 View Source File : WeakFuncGenericNestedTest.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestPublicClreplacedAnonymousMethod()
        {
            Reset();

            const int index = 99;
            const string parameter = "My parameter";

            _itemPublic = new PublicNestedTestClreplaced<string>(index);
            _reference = new WeakReference(_itemPublic);

            _action = _itemPublic.GetFunc(WeakActionTestCase.AnonymousMethod);

            replacedert.IsTrue(_reference.IsAlive);
            replacedert.IsTrue(_action.IsAlive);

            var result = _action.Execute(parameter);

            replacedert.AreEqual(
                PublicNestedTestClreplaced<string>.Expected + index + parameter,
                PublicNestedTestClreplaced<string>.Result);
            replacedert.AreEqual(
                PublicNestedTestClreplaced<string>.Expected + index + parameter,
                result);

            _itemPublic = null;
            GC.Collect();

#if SILVERLIGHT
            replacedert.IsTrue(_reference.IsAlive); // Anonymous, private and internal methods cannot be GCed
            _action = null;
            GC.Collect();
            replacedert.IsFalse(_reference.IsAlive);
#else
            replacedert.IsFalse(_reference.IsAlive);
#endif
        }

19 View Source File : WeakFuncGenericNestedTest.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestPublicClreplacedAnonymousStaticMethod()
        {
            Reset();

            const string parameter = "My parameter";

            _itemPublic = new PublicNestedTestClreplaced<string>();
            _reference = new WeakReference(_itemPublic);

            _action = _itemPublic.GetFunc(WeakActionTestCase.AnonymousStaticMethod);

            replacedert.IsTrue(_reference.IsAlive);
            replacedert.IsTrue(_action.IsAlive);

            var result = _action.Execute(parameter);

            replacedert.AreEqual(
                PublicNestedTestClreplaced<string>.Expected + parameter,
                PublicNestedTestClreplaced<string>.Result);
            replacedert.AreEqual(
                PublicNestedTestClreplaced<string>.Expected + parameter,
                result);

            _itemPublic = null;
            GC.Collect();

            replacedert.IsFalse(_reference.IsAlive);
        }

19 View Source File : WeakFuncGenericNestedTest.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestInternalClreplacedPublicNamedMethod()
        {
            Reset();

            const int index = 99;
            const string parameter = "My parameter";

            _itemInternal = new InternalNestedTestClreplaced<string>(index);

            _action = _itemInternal.GetFunc(WeakActionTestCase.PublicNamedMethod);

            _reference = new WeakReference(_itemInternal);
            replacedert.IsTrue(_reference.IsAlive);
            replacedert.IsTrue(_action.IsAlive);

            var result = _action.Execute(parameter);

            replacedert.AreEqual(
                InternalNestedTestClreplaced<string>.Expected + InternalNestedTestClreplaced<string>.Public + index + parameter,
                InternalNestedTestClreplaced<string>.Result);
            replacedert.AreEqual(
                InternalNestedTestClreplaced<string>.Expected + InternalNestedTestClreplaced<string>.Public + index + parameter,
                result);

            _itemInternal = null;
            GC.Collect();

#if SILVERLIGHT
            replacedert.IsTrue(_reference.IsAlive); // Anonymous, private and internal methods cannot be GCed
            _action = null;
            GC.Collect();
            replacedert.IsFalse(_reference.IsAlive);
#else
            replacedert.IsFalse(_reference.IsAlive);
#endif
        }

19 View Source File : WeakFuncGenericNestedTest.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestInternalClreplacedPublicStaticMethod()
        {
            Reset();

            const string parameter = "My parameter";

            _itemInternal = new InternalNestedTestClreplaced<string>();
            _reference = new WeakReference(_itemInternal);

            _action = _itemInternal.GetFunc(WeakActionTestCase.PublicStaticMethod);

            replacedert.IsTrue(_reference.IsAlive);
            replacedert.IsTrue(_action.IsAlive);

            var result = _action.Execute(parameter);

            replacedert.AreEqual(
                InternalNestedTestClreplaced<string>.Expected + InternalNestedTestClreplaced<string>.PublicStatic + parameter,
                InternalNestedTestClreplaced<string>.Result);
            replacedert.AreEqual(
                InternalNestedTestClreplaced<string>.Expected + InternalNestedTestClreplaced<string>.PublicStatic + parameter,
                result);

            _itemInternal = null;
            GC.Collect();

            replacedert.IsFalse(_reference.IsAlive);
        }

19 View Source File : WeakFuncGenericNestedTest.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestInternalClreplacedPrivateStaticMethod()
        {
            Reset();

            const string parameter = "My parameter";

            _itemInternal = new InternalNestedTestClreplaced<string>();
            _reference = new WeakReference(_itemInternal);

            _action = _itemInternal.GetFunc(WeakActionTestCase.PrivateStaticMethod);

            replacedert.IsTrue(_reference.IsAlive);
            replacedert.IsTrue(_action.IsAlive);

            var result = _action.Execute(parameter);

            replacedert.AreEqual(
                InternalNestedTestClreplaced<string>.Expected + InternalNestedTestClreplaced<string>.PrivateStatic + parameter,
                InternalNestedTestClreplaced<string>.Result);
            replacedert.AreEqual(
                InternalNestedTestClreplaced<string>.Expected + InternalNestedTestClreplaced<string>.PrivateStatic + parameter,
                result);

            _itemInternal = null;
            GC.Collect();

            replacedert.IsFalse(_reference.IsAlive);
        }

19 View Source File : WeakFuncGenericNestedTest.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestPrivateClreplacedPublicNamedMethod()
        {
            Reset();

            const int index = 99;
            const string parameter = "My parameter";

            _itemPrivate = new PrivateNestedTestClreplaced<string>(index);

            _action = _itemPrivate.GetFunc(WeakActionTestCase.PublicNamedMethod);

            _reference = new WeakReference(_itemPrivate);
            replacedert.IsTrue(_reference.IsAlive);
            replacedert.IsTrue(_action.IsAlive);

            var result = _action.Execute(parameter);

            replacedert.AreEqual(
                PrivateNestedTestClreplaced<string>.Expected + PrivateNestedTestClreplaced<string>.Public + index + parameter,
                PrivateNestedTestClreplaced<string>.Result);
            replacedert.AreEqual(
                PrivateNestedTestClreplaced<string>.Expected + PrivateNestedTestClreplaced<string>.Public + index + parameter,
                result);

            _itemPrivate = null;
            GC.Collect();

#if SILVERLIGHT
            replacedert.IsTrue(_reference.IsAlive); // Anonymous, private and internal methods cannot be GCed
            _action = null;
            GC.Collect();
            replacedert.IsFalse(_reference.IsAlive);
#else
            replacedert.IsFalse(_reference.IsAlive);
#endif
        }

19 View Source File : WeakFuncGenericNestedTest.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestPrivateClreplacedInternalStaticMethod()
        {
            Reset();

            const string parameter = "My parameter";

            _itemPrivate = new PrivateNestedTestClreplaced<string>();
            _reference = new WeakReference(_itemPrivate);

            _action = _itemPrivate.GetFunc(WeakActionTestCase.InternalStaticMethod);

            replacedert.IsTrue(_reference.IsAlive);
            replacedert.IsTrue(_action.IsAlive);

            var result = _action.Execute(parameter);

            replacedert.AreEqual(
                PrivateNestedTestClreplaced<string>.Expected + PrivateNestedTestClreplaced<string>.InternalStatic + parameter,
                PrivateNestedTestClreplaced<string>.Result);
            replacedert.AreEqual(
                PrivateNestedTestClreplaced<string>.Expected + PrivateNestedTestClreplaced<string>.InternalStatic + parameter,
                result);

            _itemPrivate = null;
            GC.Collect();

            replacedert.IsFalse(_reference.IsAlive);
        }

19 View Source File : WeakFuncGenericNestedTest.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestPrivateClreplacedPrivateNamedMethod()
        {
            Reset();

            const string parameter = "My parameter";
            const int index = 99;

            _itemPrivate = new PrivateNestedTestClreplaced<string>(index);
            _reference = new WeakReference(_itemPrivate);

            _action = _itemPrivate.GetFunc(WeakActionTestCase.PrivateNamedMethod);

            replacedert.IsTrue(_reference.IsAlive);
            replacedert.IsTrue(_action.IsAlive);

            var result = _action.Execute(parameter);

            replacedert.AreEqual(
                PrivateNestedTestClreplaced<string>.Expected + PrivateNestedTestClreplaced<string>.Private + index + parameter,
                PrivateNestedTestClreplaced<string>.Result);
            replacedert.AreEqual(
                PrivateNestedTestClreplaced<string>.Expected + PrivateNestedTestClreplaced<string>.Private + index + parameter,
                result);

            _itemPrivate = null;
            GC.Collect();

#if SILVERLIGHT
            replacedert.IsTrue(_reference.IsAlive); // Anonymous, private and internal methods cannot be GCed
            _action = null;
            GC.Collect();
            replacedert.IsFalse(_reference.IsAlive);
#else
            replacedert.IsFalse(_reference.IsAlive);
#endif
        }

19 View Source File : WeakFuncGenericNestedTest.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestPrivateClreplacedAnonymousMethod()
        {
            Reset();

            const int index = 99;
            const string parameter = "My parameter";

            _itemPrivate = new PrivateNestedTestClreplaced<string>(index);
            _reference = new WeakReference(_itemPrivate);

            _action = _itemPrivate.GetFunc(WeakActionTestCase.AnonymousMethod);

            replacedert.IsTrue(_reference.IsAlive);
            replacedert.IsTrue(_action.IsAlive);

            var result = _action.Execute(parameter);

            replacedert.AreEqual(
                PrivateNestedTestClreplaced<string>.Expected + index + parameter,
                PrivateNestedTestClreplaced<string>.Result);
            replacedert.AreEqual(
                PrivateNestedTestClreplaced<string>.Expected + index + parameter,
                result);

            _itemPrivate = null;
            GC.Collect();

#if SILVERLIGHT
            replacedert.IsTrue(_reference.IsAlive); // Anonymous, private and internal methods cannot be GCed
            _action = null;
            GC.Collect();
            replacedert.IsFalse(_reference.IsAlive);
#else
            replacedert.IsFalse(_reference.IsAlive);
#endif
        }

19 View Source File : WeakFuncGenericTest.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestPublicClreplacedPublicNamedMethod()
        {
            Reset();

            const int index = 99;
            const string parameter = "My parameter";

            _itemPublic = new PublicTestClreplaced<string>(index);

            _action = _itemPublic.GetFunc(WeakActionTestCase.PublicNamedMethod);

            _reference = new WeakReference(_itemPublic);
            replacedert.IsTrue(_reference.IsAlive);
            replacedert.IsTrue(_action.IsAlive);

            var result = _action.Execute(parameter);

            replacedert.AreEqual(
                PublicTestClreplaced<string>.Expected + PublicTestClreplaced<string>.Public + index + parameter,
                PublicTestClreplaced<string>.Result);
            replacedert.AreEqual(
                PublicTestClreplaced<string>.Expected + PublicTestClreplaced<string>.Public + index + parameter,
                result);

            _itemPublic = null;
            GC.Collect();

            replacedert.IsFalse(_reference.IsAlive);
        }

19 View Source File : WeakFuncGenericTest.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestPublicClreplacedInternalStaticMethod()
        {
            Reset();

            const string parameter = "My parameter";

            _itemPublic = new PublicTestClreplaced<string>();
            _reference = new WeakReference(_itemPublic);

            _action = _itemPublic.GetFunc(WeakActionTestCase.InternalStaticMethod);

            replacedert.IsTrue(_reference.IsAlive);
            replacedert.IsTrue(_action.IsAlive);

            var result = _action.Execute(parameter);

            replacedert.AreEqual(
                PublicTestClreplaced<string>.Expected + PublicTestClreplaced<string>.InternalStatic + parameter,
                PublicTestClreplaced<string>.Result);
            replacedert.AreEqual(
                PublicTestClreplaced<string>.Expected + PublicTestClreplaced<string>.InternalStatic + parameter,
                result);

            _itemPublic = null;
            GC.Collect();

            replacedert.IsFalse(_reference.IsAlive);
        }

19 View Source File : WeakFuncGenericTest.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestPublicClreplacedAnonymousMethod()
        {
            Reset();

            const int index = 99;
            const string parameter = "My parameter";

            _itemPublic = new PublicTestClreplaced<string>(index);
            _reference = new WeakReference(_itemPublic);

            _action = _itemPublic.GetFunc(WeakActionTestCase.AnonymousMethod);

            replacedert.IsTrue(_reference.IsAlive);
            replacedert.IsTrue(_action.IsAlive);

            var result = _action.Execute(parameter);

            replacedert.AreEqual(
                PublicTestClreplaced<string>.Expected + index + parameter,
                PublicTestClreplaced<string>.Result);
            replacedert.AreEqual(
                PublicTestClreplaced<string>.Expected + index + parameter,
                result);

            _itemPublic = null;
            GC.Collect();

#if SILVERLIGHT
            replacedert.IsTrue(_reference.IsAlive); // Anonymous, private and internal methods cannot be GCed
            _action = null;
            GC.Collect();
            replacedert.IsFalse(_reference.IsAlive);
#else
            replacedert.IsFalse(_reference.IsAlive);
#endif
        }

19 View Source File : WeakFuncGenericTest.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestInternalClreplacedPublicStaticMethod()
        {
            Reset();

            const string parameter = "My parameter";

            _itemInternal = new InternalTestClreplaced<string>();
            _reference = new WeakReference(_itemInternal);

            _action = _itemInternal.GetFunc(WeakActionTestCase.PublicStaticMethod);

            replacedert.IsTrue(_reference.IsAlive);
            replacedert.IsTrue(_action.IsAlive);

            var result = _action.Execute(parameter);

            replacedert.AreEqual(
                InternalTestClreplaced<string>.Expected + InternalTestClreplaced<string>.PublicStatic + parameter,
                InternalTestClreplaced<string>.Result);
            replacedert.AreEqual(
                InternalTestClreplaced<string>.Expected + InternalTestClreplaced<string>.PublicStatic + parameter,
                result);

            _itemInternal = null;
            GC.Collect();

            replacedert.IsFalse(_reference.IsAlive);
        }

19 View Source File : WeakFuncNestedTest.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestPublicNestedClreplacedPrivateStaticMethod()
        {
            Reset();

            _itemPublic = new PublicNestedTestClreplaced();
            _reference = new WeakReference(_itemPublic);

            _action = _itemPublic.GetFunc(WeakActionTestCase.PrivateStaticMethod);

            replacedert.IsTrue(_reference.IsAlive);
            replacedert.IsTrue(_action.IsAlive);

            var result = _action.Execute();

            replacedert.AreEqual(
                PublicNestedTestClreplaced.Expected + PublicNestedTestClreplaced.PrivateStatic,
                PublicNestedTestClreplaced.Result);
            replacedert.AreEqual(
                PublicNestedTestClreplaced.Expected + PublicNestedTestClreplaced.PrivateStatic,
                result);

            _itemPublic = null;
            GC.Collect();

            replacedert.IsFalse(_reference.IsAlive);
        }

19 View Source File : WeakFuncNestedTest.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestInternalNestedClreplacedAnonymousStaticMethod()
        {
            Reset();

            _itemInternal = new InternalNestedTestClreplaced();
            _reference = new WeakReference(_itemInternal);

            _action = _itemInternal.GetFunc(WeakActionTestCase.AnonymousStaticMethod);

            replacedert.IsTrue(_reference.IsAlive);
            replacedert.IsTrue(_action.IsAlive);

            var result = _action.Execute();

            replacedert.AreEqual(
                InternalNestedTestClreplaced.Expected,
                InternalNestedTestClreplaced.Result);
            replacedert.AreEqual(
                InternalNestedTestClreplaced.Expected,
                result);

            _itemInternal = null;
            GC.Collect();

            replacedert.IsFalse(_reference.IsAlive);
        }

19 View Source File : WeakFuncNestedTest.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestPrivateNestedClreplacedPrivateStaticMethod()
        {
            Reset();

            _itemPrivate = new PrivateNestedTestClreplaced();
            _reference = new WeakReference(_itemPrivate);

            _action = _itemPrivate.GetFunc(WeakActionTestCase.PrivateStaticMethod);

            replacedert.IsTrue(_reference.IsAlive);
            replacedert.IsTrue(_action.IsAlive);

            var result = _action.Execute();

            replacedert.AreEqual(
                PrivateNestedTestClreplaced.Expected + PrivateNestedTestClreplaced.PrivateStatic,
                PrivateNestedTestClreplaced.Result);
            replacedert.AreEqual(
                PrivateNestedTestClreplaced.Expected + PrivateNestedTestClreplaced.PrivateStatic,
                result);

            _itemPrivate = null;
            GC.Collect();

            replacedert.IsFalse(_reference.IsAlive);
        }

19 View Source File : WeakFuncTest.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestPublicClreplacedPublicNamedMethod()
        {
            Reset();

            const int index = 99;

            _itemPublic = new PublicTestClreplaced(index);

            _action = _itemPublic.GetFunc(WeakActionTestCase.PublicNamedMethod);

            _reference = new WeakReference(_itemPublic);
            replacedert.IsTrue(_reference.IsAlive);
            replacedert.IsTrue(_action.IsAlive);

            var result = _action.Execute();

            replacedert.AreEqual(
                PublicTestClreplaced.Expected + PublicTestClreplaced.Public + index,
                PublicTestClreplaced.Result);
            replacedert.AreEqual(
                PublicTestClreplaced.Expected + PublicTestClreplaced.Public + index,
                result);

            _itemPublic = null;
            GC.Collect();

            replacedert.IsFalse(_reference.IsAlive);
        }

19 View Source File : WeakFuncTest.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestPublicClreplacedPrivateNamedMethod()
        {
            Reset();

            const int index = 99;

            _itemPublic = new PublicTestClreplaced(index);
            _reference = new WeakReference(_itemPublic);

            _action = _itemPublic.GetFunc(WeakActionTestCase.PrivateNamedMethod);

            replacedert.IsTrue(_reference.IsAlive);
            replacedert.IsTrue(_action.IsAlive);

            var result = _action.Execute();

            replacedert.AreEqual(
                PublicTestClreplaced.Expected + PublicTestClreplaced.Private + index,
                PublicTestClreplaced.Result);
            replacedert.AreEqual(
                PublicTestClreplaced.Expected + PublicTestClreplaced.Private + index,
                result);

            _itemPublic = null;
            GC.Collect();

#if SILVERLIGHT
            replacedert.IsTrue(_reference.IsAlive); // Anonymous, private and internal methods cannot be GCed
            _action = null;
            GC.Collect();
            replacedert.IsFalse(_reference.IsAlive);
#else
            replacedert.IsFalse(_reference.IsAlive);
#endif
        }

19 View Source File : WeakFuncTest.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestPublicClreplacedPrivateStaticMethod()
        {
            Reset();

            _itemPublic = new PublicTestClreplaced();
            _reference = new WeakReference(_itemPublic);

            _action = _itemPublic.GetFunc(WeakActionTestCase.PrivateStaticMethod);

            replacedert.IsTrue(_reference.IsAlive);
            replacedert.IsTrue(_action.IsAlive);

            var result = _action.Execute();

            replacedert.AreEqual(
                PublicTestClreplaced.Expected + PublicTestClreplaced.PrivateStatic,
                PublicTestClreplaced.Result);
            replacedert.AreEqual(
                PublicTestClreplaced.Expected + PublicTestClreplaced.PrivateStatic,
                result);

            _itemPublic = null;
            GC.Collect();

            replacedert.IsFalse(_reference.IsAlive);
        }

19 View Source File : WeakFuncTest.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestInternalClreplacedPublicNamedMethod()
        {
            Reset();

            const int index = 99;

            _itemInternal = new InternalTestClreplaced(index);

            _action = _itemInternal.GetFunc(WeakActionTestCase.PublicNamedMethod);

            _reference = new WeakReference(_itemInternal);
            replacedert.IsTrue(_reference.IsAlive);
            replacedert.IsTrue(_action.IsAlive);

            var result = _action.Execute();

            replacedert.AreEqual(
                InternalTestClreplaced.Expected + InternalTestClreplaced.Public + index,
                InternalTestClreplaced.Result);
            replacedert.AreEqual(
                InternalTestClreplaced.Expected + InternalTestClreplaced.Public + index,
                result);

            _itemInternal = null;
            GC.Collect();

#if SILVERLIGHT
            replacedert.IsTrue(_reference.IsAlive); // Anonymous, private and internal methods cannot be GCed
            _action = null;
            GC.Collect();
            replacedert.IsFalse(_reference.IsAlive);
#else
            replacedert.IsFalse(_reference.IsAlive);
#endif
        }

19 View Source File : WeakFuncTest.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestInternalClreplacedInternalNamedMethod()
        {
            Reset();

            const int index = 99;

            _itemInternal = new InternalTestClreplaced(index);
            _reference = new WeakReference(_itemInternal);

            _action = _itemInternal.GetFunc(WeakActionTestCase.InternalNamedMethod);

            replacedert.IsTrue(_reference.IsAlive);
            replacedert.IsTrue(_action.IsAlive);

            var result = _action.Execute();

            replacedert.AreEqual(
                InternalTestClreplaced.Expected + InternalTestClreplaced.Internal + index,
                InternalTestClreplaced.Result);
            replacedert.AreEqual(
                InternalTestClreplaced.Expected + InternalTestClreplaced.Internal + index,
                result);

            _itemInternal = null;
            GC.Collect();

#if SILVERLIGHT
            replacedert.IsTrue(_reference.IsAlive); // Anonymous, private and internal methods cannot be GCed
            _action = null;
            GC.Collect();
            replacedert.IsFalse(_reference.IsAlive);
#else
            replacedert.IsFalse(_reference.IsAlive);
#endif
        }

19 View Source File : WeakFuncTest.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestStaticMethodWithNullTarget()
        {
            Reset();
            var func = new WeakFunc<string>(null, DoStuffStaticWithResult);
            replacedert.IsTrue(func.IsAlive);
        }

19 View Source File : SimpleIocTestContains.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestContainsClreplaced()
        {
            SimpleIoc.Default.Reset();
            SimpleIoc.Default.Register<TestClreplaced1>();

            replacedert.IsFalse(SimpleIoc.Default.ContainsCreated<TestClreplaced1>());
            SimpleIoc.Default.GetInstance<TestClreplaced1>();
            replacedert.IsTrue(SimpleIoc.Default.ContainsCreated<TestClreplaced1>());
        }

19 View Source File : SimpleIocTestContains.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestContainsInstanceAfterUnregister()
        {
            SimpleIoc.Default.Reset();
            SimpleIoc.Default.Register<TestBaseClreplaced>(true);

            replacedert.IsTrue(SimpleIoc.Default.IsRegistered<TestBaseClreplaced>());
            replacedert.IsTrue(SimpleIoc.Default.ContainsCreated<TestBaseClreplaced>());

            var instance = SimpleIoc.Default.GetInstance<TestBaseClreplaced>();
            instance.Remove();

            replacedert.IsTrue(SimpleIoc.Default.IsRegistered<TestBaseClreplaced>());
            replacedert.IsFalse(SimpleIoc.Default.ContainsCreated<TestBaseClreplaced>());
        }

19 View Source File : SimpleIocTestIsRegistered.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestIsClreplacedRegisteredWithFactoryAndKey()
        {
            SimpleIoc.Default.Reset();
            const string key1 = "My key 1";
            const string key2 = "My key 2";

            var instance = new TestClreplaced1();
            replacedert.IsFalse(SimpleIoc.Default.IsRegistered<TestClreplaced1>(key1));
            replacedert.IsFalse(SimpleIoc.Default.IsRegistered<TestClreplaced1>(key2));

            SimpleIoc.Default.Register(() => instance, key1);
            replacedert.IsTrue(SimpleIoc.Default.IsRegistered<TestClreplaced1>(key1));
            replacedert.IsFalse(SimpleIoc.Default.IsRegistered<TestClreplaced1>(key2));

            SimpleIoc.Default.GetInstance<TestClreplaced1>(key1);
            replacedert.IsTrue(SimpleIoc.Default.IsRegistered<TestClreplaced1>(key1));

            SimpleIoc.Default.Unregister<TestClreplaced1>(key1);
            replacedert.IsFalse(SimpleIoc.Default.IsRegistered<TestClreplaced1>(key1));
            replacedert.IsFalse(SimpleIoc.Default.IsRegistered<TestClreplaced1>(key2));
        }

19 View Source File : SimpleIocTestIsRegistered.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestIsInterfaceRegistered()
        {
            SimpleIoc.Default.Reset();

            replacedert.IsFalse(SimpleIoc.Default.IsRegistered<ITestClreplaced>());
            SimpleIoc.Default.Register<ITestClreplaced, TestClreplaced1>();
            replacedert.IsTrue(SimpleIoc.Default.IsRegistered<ITestClreplaced>());

            SimpleIoc.Default.GetInstance<ITestClreplaced>();
            replacedert.IsTrue(SimpleIoc.Default.IsRegistered<ITestClreplaced>());

            SimpleIoc.Default.Unregister<ITestClreplaced>();
            replacedert.IsFalse(SimpleIoc.Default.IsRegistered<ITestClreplaced>());
        }

19 View Source File : SimpleIocTestMultipleInstances.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestGetAllInstances1()
        {
            SimpleIoc.Default.Reset();

            const string key1 = "key1";
            var instance1 = new TestClreplaced1();
            SimpleIoc.Default.Register(() => instance1, key1);

            SimpleIoc.Default.Register<TestClreplaced1>();

            var instances = SimpleIoc.Default.GetAllInstances<TestClreplaced1>().ToList();
            replacedert.AreEqual(2, instances.Count);

            var getInstance1 = SimpleIoc.Default.GetInstance<TestClreplaced1>(key1);
            replacedert.AreSame(instance1, getInstance1);

            replacedert.IsTrue(instances.Contains(instance1));

            instances.Remove(instance1);
            replacedert.AreEqual(1, instances.Count);

            var getInstance2 = SimpleIoc.Default.GetInstance<TestClreplaced1>();
            replacedert.AreSame(instances[0], getInstance2);

            SimpleIoc.Default.GetInstance<TestClreplaced1>("key2");

            instances = SimpleIoc.Default.GetAllInstances<TestClreplaced1>().ToList();
            replacedert.AreEqual(3, instances.Count);
        }

19 View Source File : SimpleIocTestSingleInstance.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestGetDefaultWithoutCaching()
        {
            SimpleIoc.Default.Reset();
            SimpleIoc.Default.Register<TestClreplaced1>();

            var instance1 = SimpleIoc.Default.GetInstanceWithoutCaching<TestClreplaced1>();
            var instance2 = SimpleIoc.Default.GetInstanceWithoutCaching<TestClreplaced1>();

            replacedert.IsTrue(SimpleIoc.Default.IsRegistered<TestClreplaced1>());
            replacedert.IsFalse(SimpleIoc.Default.ContainsCreated<TestClreplaced1>());
            replacedert.AreNotSame(instance1, instance2);
        }

19 View Source File : SimpleIocTestSingleInstance.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestGetFromFactoryWithoutCaching()
        {
            SimpleIoc.Default.Reset();
            SimpleIoc.Default.Register(() => new TestClreplaced1());

            var instance1 = SimpleIoc.Default.GetInstanceWithoutCaching<TestClreplaced1>();
            var instance2 = SimpleIoc.Default.GetInstanceWithoutCaching<TestClreplaced1>();

            replacedert.IsTrue(SimpleIoc.Default.IsRegistered<TestClreplaced1>());
            replacedert.IsFalse(SimpleIoc.Default.ContainsCreated<TestClreplaced1>());
            replacedert.AreNotSame(instance1, instance2);
        }

19 View Source File : SimpleIocTestSingleInstance.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestGetWithKeyWithoutCaching()
        {
            SimpleIoc.Default.Reset();
            SimpleIoc.Default.Register<TestClreplaced1>();

            const string key = "key1";

            var instance1 = SimpleIoc.Default.GetInstanceWithoutCaching<TestClreplaced1>(key);
            var instance2 = SimpleIoc.Default.GetInstanceWithoutCaching<TestClreplaced1>(key);

            replacedert.IsTrue(SimpleIoc.Default.IsRegistered<TestClreplaced1>());
            replacedert.IsFalse(SimpleIoc.Default.ContainsCreated<TestClreplaced1>());
            replacedert.AreNotSame(instance1, instance2);
        }

19 View Source File : SimpleIocTestSingleInstance.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestMixCacheAndNoCache()
        {
            SimpleIoc.Default.Reset();
            SimpleIoc.Default.Register<TestClreplaced1>();

            var instance1 = SimpleIoc.Default.GetInstanceWithoutCaching<TestClreplaced1>();
            replacedert.IsTrue(SimpleIoc.Default.IsRegistered<TestClreplaced1>());
            replacedert.IsFalse(SimpleIoc.Default.ContainsCreated<TestClreplaced1>());

            var instance2 = SimpleIoc.Default.GetInstance<TestClreplaced1>();
            replacedert.IsTrue(SimpleIoc.Default.IsRegistered<TestClreplaced1>());
            replacedert.IsTrue(SimpleIoc.Default.ContainsCreated<TestClreplaced1>());
            replacedert.AreNotSame(instance1, instance2);
        }

19 View Source File : SimpleIocTestUnregistration.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestUnregisterAndImmediateRegisterWithInterface()
        {
            SimpleIoc.Default.Reset();

            SimpleIoc.Default.Register<ITestClreplaced, TestClreplaced1>();
            replacedert.IsTrue(SimpleIoc.Default.IsRegistered<ITestClreplaced>());

            SimpleIoc.Default.Unregister<ITestClreplaced>();
            replacedert.IsFalse(SimpleIoc.Default.IsRegistered<ITestClreplaced>());

            SimpleIoc.Default.Register<ITestClreplaced, TestClreplaced1>();
            replacedert.IsTrue(SimpleIoc.Default.IsRegistered<ITestClreplaced>());
        }

19 View Source File : SimpleIocTestUnregistration.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestUnregisterFactoryInstance()
        {
            SimpleIoc.Default.Reset();

            var instance0 = new TestClreplaced1();

            SimpleIoc.Default.Register(() => instance0);

            replacedert.IsTrue(SimpleIoc.Default.IsRegistered<TestClreplaced1>());
            replacedert.IsFalse(SimpleIoc.Default.ContainsCreated<TestClreplaced1>());

            var instance1 = SimpleIoc.Default.GetInstance<TestClreplaced1>();
            replacedert.AreSame(instance0, instance1);

            replacedert.IsTrue(SimpleIoc.Default.IsRegistered<TestClreplaced1>());
            replacedert.IsTrue(SimpleIoc.Default.ContainsCreated<TestClreplaced1>());

            var instance2 = SimpleIoc.Default.GetInstance<TestClreplaced1>();
            replacedert.AreSame(instance0, instance2);

            SimpleIoc.Default.Unregister(instance0);

            replacedert.IsTrue(SimpleIoc.Default.IsRegistered<TestClreplaced1>());
            replacedert.IsFalse(SimpleIoc.Default.ContainsCreated<TestClreplaced1>());

            var instance3 = SimpleIoc.Default.GetInstance<TestClreplaced1>();
            replacedert.AreSame(instance0, instance3);
        }

19 View Source File : GarbageCollectionTest.cs
License : MIT License
Project Creator : lbugnion

[TestMethod]
        public void TestGarbageCollectionForNamedInternalStaticMethod()
        {
            Messenger.Reset();
            TestRecipient.Reset();

            _recipient = new TestRecipient(WeakActionTestCase.InternalStaticMethod);
            _recipientReference = new WeakReference(_recipient);

            replacedert.AreEqual(null, TestRecipient.ContentStatic);
            replacedert.IsTrue(_recipientReference.IsAlive);

            const string message = "Hello world";

            Messenger.Default.Send(message);

            replacedert.AreEqual(message, TestRecipient.ContentStatic);

            _recipient = null;
            GC.Collect();

            replacedert.IsFalse(_recipientReference.IsAlive);
        }

See More Examples