Ejemplo n.º 1
0
        public void GivenChain_ThenSequenceIsCorrect()
        {
            var provider = BuildServiceProvider();
            var link     = provider.GetRequiredService <IMyLink>();

            var links = ChainInspector.UnfoldChain(link);

            links.Should()
            .NotBeEmpty()
            .And.HaveCount(3);

            links.ElementAt(0).Should().BeOfType(typeof(MyLink1));
            links.ElementAt(1).Should().BeOfType(typeof(MyLink2));
            links.ElementAt(2).Should().BeOfType(typeof(MyLink3));
        }
Ejemplo n.º 2
0
        public void GivenChain_ThenLinksAreTransient()
        {
            var provider = BuildServiceProvider();

            var link1 = provider.GetRequiredService <IMyLink>();
            var link2 = provider.GetRequiredService <IMyLink>();

            var links = new List <IMyLink>();

            links.AddRange(ChainInspector.UnfoldChain(link1));
            links.AddRange(ChainInspector.UnfoldChain(link2));

            var uniqueLinks = links.Select(x => x.GetHashCode());

            uniqueLinks.Count().Should().Be(links.Count);
        }
Ejemplo n.º 3
0
        public void GivenChain_WhenDefault_ThenSequenceIsCorrect()
        {
            var provider = BuildServiceProvider();
            var factory  = provider.GetRequiredService <MyLinkFactory>();
            var link     = factory.Initialize("SINGLE");

            var links = ChainInspector.UnfoldChain(link);

            links.Should()
            .NotBeEmpty()
            .And.HaveCount(3);

            links.ElementAt(0).Should().BeOfType(typeof(MyLink1));
            links.ElementAt(1).Should().BeOfType(typeof(MyLink2));
            links.ElementAt(2).Should().BeOfType(typeof(MyLink3));
        }
        public void GivenChain_ThenSequenceIsCorrect()
        {
            IChainLink <MyRequest, MyResponse> myLink1 = new MyLink1(false);
            IChainLink <MyRequest, MyResponse> myLink2 = new MyLink2(false);
            IChainLink <MyRequest, MyResponse> myLink3 = new MyLink3(false);

            var link = ChainFactory <MyRequest, MyResponse>
                       .Initialize()
                       .StartWith(myLink1)
                       .FollowedBy(myLink2)
                       .FollowedBy(myLink3)
                       .Build();

            var links = ChainInspector.UnfoldChain(link);

            links.Should()
            .NotBeEmpty()
            .And.HaveCount(3)
            .And.ContainInOrder(new[] { myLink1, myLink2, myLink3 });
        }