Beispiel #1
0
        public void Should_allow_the_addition_of_new_components()
        {
            var sut       = new ServiceComponentList <ITestComponent>();
            var component = new TestComponentImpl();

            sut.Register(component);

            sut.Should().Equal(component);
        }
Beispiel #2
0
        public void Should_allow_unregistration_of_existing_component()
        {
            var sut       = new ServiceComponentList <ITestComponent>();
            var component = new TestComponentImpl();

            sut.Register(component);
            sut.Unregister(component);

            sut.Should().BeEmpty();
        }
Beispiel #3
0
        public void Should_allow_to_replace_a_component_with_another_one()
        {
            var sut          = new ServiceComponentList <ITestComponent>();
            var oldComponent = new TestComponentImpl();
            var newComponent = new TestComponentImpl();

            sut.Register(oldComponent);
            sut.Replace(oldComponent, newComponent);

            sut.Should().Equal(newComponent);
        }
Beispiel #4
0
        public void Should_allow_the_removal_of_default_component_via_generic_unregistration()
        {
            var sut             = new ServiceComponentList <ITestComponent>();
            var registeredFirst = new TestComponentImpl();

            sut.Register(registeredFirst);
            sut.SetDefault <AnotherImpl>();
            sut.Unregister <ITestComponent>();

            sut.Should().BeEmpty();
        }
Beispiel #5
0
        public void Should_allow_the_addition_of_default_components_at_the_end_of_the_list_via_generic_overload()
        {
            var sut             = new ServiceComponentList <ITestComponent>();
            var registeredFirst = new TestComponentImpl();
            var registeredLast  = new TestComponentImpl();

            sut.Register(registeredFirst);
            sut.Register(registeredLast);
            sut.SetDefault <AnotherImpl>();

            sut.Last().Should().BeOfType <AnotherImpl>();
        }
Beispiel #6
0
        public void Should_allow_the_addition_of_default_components_at_the_end_of_the_list()
        {
            var sut             = new ServiceComponentList <ITestComponent>();
            var registeredFirst = new TestComponentImpl();
            var registeredLast  = new TestComponentImpl();
            var @default        = new TestComponentImpl();

            sut.Register(registeredFirst);
            sut.Register(registeredLast);
            sut.SetDefault(@default);

            sut.Should().Equal(registeredLast, registeredFirst, @default);
        }
Beispiel #7
0
        public void Should_allow_clearing_all_components()
        {
            var sut             = new ServiceComponentList <ITestComponent>();
            var registeredFirst = new TestComponentImpl();
            var registeredLast  = new TestComponentImpl();
            var @default        = new TestComponentImpl();

            sut.Register(registeredFirst);
            sut.Register(registeredLast);
            sut.SetDefault(@default);
            sut.Clear();

            sut.Should().BeEmpty();
        }
Beispiel #8
0
        public void Should_allow_the_clearing_of_default_components()
        {
            var sut             = new ServiceComponentList <ITestComponent>();
            var registeredFirst = new TestComponentImpl();
            var registeredLast  = new TestComponentImpl();
            var @default        = new TestComponentImpl();

            sut.Register(registeredFirst);
            sut.Register(registeredLast);
            sut.SetDefault(@default);
            sut.ClearDefault();

            sut.Should().Equal(registeredLast, registeredFirst);
        }