Пример #1
0
 public void SetUp()
 {
     ControlRegistrator.Reset();
     kind = MyEnum.ValueOne;
     type = typeof(MyClass);
     ControlRegistrator.RegisterControl(kind, type);
 }
Пример #2
0
        public void GetMultipleInstancesTest1()
        {
            var kind2     = MyEnum.ValueTwo;
            var type2     = typeof(MyParameterClass);
            var parameter = "A String Parameter";

            ControlRegistrator.RegisterControl(kind2, type2);

            var first  = GetInstanceOfTypeTest1Helper <MyParameterClass>(kind2, new[] { parameter });
            var second = GetInstanceOfTypeTest1Helper <MyParameterClass>(kind2, new[] { parameter });

            Assert.AreEqual(first, second);
            Assert.AreNotSame(first, second);
        }
Пример #3
0
        public void GetMultipleInstancesTest()
        {
            var first  = GetInstanceOfTypeTestHelper <MyClass>(kind);
            var second = GetInstanceOfTypeTestHelper <MyClass>(kind);

            Assert.AreNotEqual(first, second);
            Assert.AreNotSame(first, second);

            ControlRegistrator.Reset();
            kind = MyEnum.ValueOne;
            type = typeof(MyClass);
            ControlRegistrator.RegisterControl(kind, type, new SingletonInstance());

            first  = GetInstanceOfTypeTestHelper <MyClass>(kind);
            second = GetInstanceOfTypeTestHelper <MyClass>(kind);
            Assert.AreEqual(first, second);
            Assert.AreSame(first, second);
        }
Пример #4
0
        public void GetInstanceOfTypeTest1()
        {
            // Construct with parameter.
            var kind2     = MyEnum.ValueTwo;
            var type2     = typeof(MyParameterClass);
            var parameter = "A String Parameter";

            ControlRegistrator.RegisterControl(kind2, type2);
            var actual = GetInstanceOfTypeTest1Helper <MyParameterClass>(kind2, new[] { parameter });

            Assert.IsNotNull(actual);

            var expected = parameter;

            Assert.AreEqual(expected, actual.Parameter);

            // wrong parameters.
            Assert.Throws <NullReferenceException>(
                () => GetInstanceOfTypeTest1Helper <MyParameterClass>(kind2, null));
            Assert.Throws <NullReferenceException>(
                () => GetInstanceOfTypeTest1Helper <MyParameterClass>(kind2, new object[0]));
            Assert.Throws <NullReferenceException>(
                () => GetInstanceOfTypeTest1Helper <MyParameterClass>(kind2, new object[] { 5.5d }));
        }
Пример #5
0
 public void RegisterControlTest()
 {
     Assert.Throws <ArgumentNullException>(() => ControlRegistrator.RegisterControl(null, type));
     Assert.Throws <ArgumentNullException>(() => ControlRegistrator.RegisterControl(kind, null));
 }