Ejemplo n.º 1
0
        public void GetHandlerTypeForObject()
        {
            var registrar = new Internals.Registrar <MockRenderer>();

            registrar.Register(typeof(View), typeof(MockRenderer));
            registrar.Register(typeof(Button), typeof(ButtonMockRenderer));

            Assert.AreEqual(typeof(ButtonMockRenderer), registrar.GetHandlerTypeForObject(new Button()));
        }
Ejemplo n.º 2
0
        public void GetHandlerForObject()
        {
            var registrar = new Internals.Registrar <MockRenderer>();

            registrar.Register(typeof(View), typeof(MockRenderer));
            registrar.Register(typeof(Button), typeof(ButtonMockRenderer));

            var buttonRenderer = registrar.GetHandlerForObject <MockRenderer> (new Button());

            Assert.That(buttonRenderer, Is.InstanceOf <ButtonMockRenderer> ());
        }
Ejemplo n.º 3
0
        public void TestReplaceRenderer()
        {
            var registrar = new Internals.Registrar <MockRenderer> ();

            registrar.Register(typeof(View), typeof(MockRenderer));
            registrar.Register(typeof(Button), typeof(ButtonMockRenderer));
            registrar.Register(typeof(Button), typeof(ShinyButtonMockRenderer));

            var buttonRenderer = registrar.GetHandler(typeof(Button));

            Assert.That(buttonRenderer, Is.InstanceOf <ShinyButtonMockRenderer>());
        }
Ejemplo n.º 4
0
        public void TestGetRendererNullViewRenderer()
        {
            var registrar = new Internals.Registrar <MockRenderer>();

            //let's say that we are now registering the view of a viewcell
            registrar.Register(typeof(View), typeof(MockRenderer));
            //later we had a view that was registered with null because there's
            //no default renderer for View
            registrar.Register(typeof(View), null);

            var renderer = registrar.GetHandler(typeof(View));

            Assert.That(renderer, Is.InstanceOf <MockRenderer>());
        }
Ejemplo n.º 5
0
        public void TestGetRendererWithRegisteredSubclass()
        {
            var registrar = new Internals.Registrar <MockRenderer> ();

            registrar.Register(typeof(View), typeof(MockRenderer));
            registrar.Register(typeof(Button), typeof(ButtonMockRenderer));

            var buttonRenderer = registrar.GetHandler(typeof(Button));
            var viewRenderer   = registrar.GetHandler(typeof(View));

            Assert.That(buttonRenderer, Is.InstanceOf <ButtonMockRenderer>());
            Assert.That(viewRenderer, Is.Not.InstanceOf <ButtonMockRenderer>());
            Assert.That(viewRenderer, Is.InstanceOf <MockRenderer>());
        }
Ejemplo n.º 6
0
        public void GetHandlerType()
        {
            var registrar = new Internals.Registrar <MockRenderer>();

            registrar.Register(typeof(View), typeof(MockRenderer));

            Assert.AreEqual(typeof(MockRenderer), registrar.GetHandlerType(typeof(View)));
        }
Ejemplo n.º 7
0
        public void TestGetRendererForUnknownSubclass()
        {
            var registrar = new Internals.Registrar <MockRenderer> ();

            registrar.Register(typeof(View), typeof(MockRenderer));

            var renderer = registrar.GetHandler(typeof(Button));

            Assert.That(renderer, Is.InstanceOf <MockRenderer>());
        }