Esempio n. 1
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>());
        }
Esempio n. 2
0
        public void TestConstructor()
        {
            var registrar = new Internals.Registrar <MockRenderer> ();

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

            Assert.Null(renderer);
        }
Esempio n. 3
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>());
        }
Esempio n. 4
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>());
        }
Esempio n. 5
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>());
        }