|
10 | 10 | */ |
11 | 11 |
|
12 | 12 | using System; |
| 13 | +using System.CodeDom; |
13 | 14 | using System.Collections.Generic; |
14 | 15 | using System.Reflection; |
15 | 16 | using Microsoft.VisualStudio.TestTools.UnitTesting; |
@@ -2715,6 +2716,75 @@ public void TestNeedGivenWithParamName() |
2715 | 2716 |
|
2716 | 2717 | Assert.AreEqual(200, container.Make<TestNeedGivenWithParamNameClass>().MyParam); |
2717 | 2718 | } |
| 2719 | + |
| 2720 | + [TestMethod] |
| 2721 | + public void TestNullRelease() |
| 2722 | + { |
| 2723 | + var container = new Container(); |
| 2724 | + Assert.AreEqual(false, container.Release(null)); |
| 2725 | + } |
| 2726 | + |
| 2727 | + public class TestGivenInvalidTypeClass |
| 2728 | + { |
| 2729 | + public TestGivenInvalidTypeClass(Container container) |
| 2730 | + { |
| 2731 | + Assert.Fail(); |
| 2732 | + } |
| 2733 | + } |
| 2734 | + |
| 2735 | + [TestMethod] |
| 2736 | + [ExpectedException(typeof(UnresolvableException))] |
| 2737 | + public void TestGivenInvalidType() |
| 2738 | + { |
| 2739 | + var container = new Container(); |
| 2740 | + container.Bind<TestGivenInvalidTypeClass>() |
| 2741 | + .Needs("$container").Given(() => 123); |
| 2742 | + container.Make<TestGivenInvalidTypeClass>(); |
| 2743 | + } |
| 2744 | + |
| 2745 | + public class TestGivenInvalidTypeAttrClass |
| 2746 | + { |
| 2747 | + [Inject] |
| 2748 | + public Container container { get; set; } |
| 2749 | + } |
| 2750 | + |
| 2751 | + [TestMethod] |
| 2752 | + [ExpectedException(typeof(UnresolvableException))] |
| 2753 | + public void TestGivenInvalidTypeAttr() |
| 2754 | + { |
| 2755 | + var container = new Container(); |
| 2756 | + container.Bind<TestGivenInvalidTypeAttrClass>() |
| 2757 | + .Needs("$container").Given(() => 123); |
| 2758 | + container.Make<TestGivenInvalidTypeAttrClass>(); |
| 2759 | + } |
| 2760 | + |
| 2761 | + public class NotSupportNullInject : Container |
| 2762 | + { |
| 2763 | + protected override bool CanInject(Type type, object instance) |
| 2764 | + { |
| 2765 | + return instance != null; |
| 2766 | + } |
| 2767 | + } |
| 2768 | + |
| 2769 | + [TestMethod] |
| 2770 | + [ExpectedException(typeof(UnresolvableException))] |
| 2771 | + public void TestGivenInvalidTypeAttrNotSupportNullInject() |
| 2772 | + { |
| 2773 | + var container = new NotSupportNullInject(); |
| 2774 | + container.Bind<TestGivenInvalidTypeAttrClass>() |
| 2775 | + .Needs("$container").Given(() => null); |
| 2776 | + container.Make<TestGivenInvalidTypeAttrClass>(); |
| 2777 | + } |
| 2778 | + |
| 2779 | + [TestMethod] |
| 2780 | + [ExpectedException(typeof(UnresolvableException))] |
| 2781 | + public void TestGivenInvalidTypeNotSupportNullInject() |
| 2782 | + { |
| 2783 | + var container = new NotSupportNullInject(); |
| 2784 | + container.Bind<TestGivenInvalidTypeClass>() |
| 2785 | + .Needs("$container").Given(() => null); |
| 2786 | + container.Make<TestGivenInvalidTypeClass>(); |
| 2787 | + } |
2718 | 2788 | #endregion |
2719 | 2789 |
|
2720 | 2790 | /// <summary> |
|
0 commit comments