public void ShouldReturnAllPathsFromSourceToDestinationWhenMultiplePathsExist()
        {
            //GIVEN
            var cache      = new NamespacesDependenciesCache();
            var namespace1 = Any.Instance <NamespaceName>();
            var namespace2 = Any.Instance <NamespaceName>();
            var namespace3 = Any.Instance <NamespaceName>();
            var namespace4 = Any.Instance <NamespaceName>();

            cache.AddMapping(namespace1, namespace2);
            cache.AddMapping(namespace2, namespace3);
            cache.AddMapping(namespace1, namespace4);
            cache.AddMapping(namespace4, namespace3);

            //WHEN
            var paths = cache.RetrievePathsBetween(
                Pattern.WithoutExclusion(namespace1.ToString()),
                Pattern.WithoutExclusion(namespace3.ToString()));

            //THEN
            paths[0].Should().Be(NamespaceDependencyPath.With(

                                     namespace1,
                                     namespace2,
                                     namespace3
                                     ));
            paths[1].Should().Be(
                NamespaceDependencyPath.With(
                    namespace1,
                    namespace4,
                    namespace3
                    ));
            paths.Should().HaveCount(2);
        }
        public void ShouldBeAbleToRetrieveMultipleIndirectCycleTakingOrderIntoAccount()
        {
            //GIVEN
            var cache      = new NamespacesDependenciesCache();
            var namespace1 = new NamespaceName("a");
            var namespace2 = new NamespaceName("b");
            var namespace3 = new NamespaceName("c");
            var namespace4 = new NamespaceName("d");

            cache.AddMapping(namespace1, namespace2);
            cache.AddMapping(namespace2, namespace1);

            cache.AddMapping(namespace1, namespace3);
            cache.AddMapping(namespace3, namespace4);
            cache.AddMapping(namespace4, namespace1);

            //WHEN
            var cycles = cache.RetrieveCycles();

            //THEN
            cycles[0].Should().Be(NamespaceDependencyPath.With(
                                      namespace1,
                                      namespace2,
                                      namespace1
                                      ));
            cycles[1].Should().Be(NamespaceDependencyPath.With(
                                      namespace1,
                                      namespace3,
                                      namespace4,
                                      namespace1
                                      ));
            cycles.Should().HaveCount(2);
        }
        public void ShouldFormatCycles()
        {
            //GIVEN
            var format     = new NamespaceBasedReportFragmentsFormat();
            var namespace1 = Any.Instance <NamespaceName>();
            var namespace2 = Any.Instance <NamespaceName>();
            var namespace3 = Any.Instance <NamespaceName>();
            var namespace4 = Any.Instance <NamespaceName>();
            var namespace5 = Any.Instance <NamespaceName>();
            var namespace6 = Any.Instance <NamespaceName>();
            var header     = Any.String();
            var cycles     = new List <NamespaceDependencyPath>
            {
                NamespaceDependencyPath.With(namespace1, namespace2, namespace3),
                NamespaceDependencyPath.With(namespace4, namespace5, namespace6),
            };

            //WHEN
            var result = format.ApplyTo(cycles, header);

            //THEN
            result.Should().Be(
                $"{header} 1:{Environment.NewLine}" +
                $"  {namespace1}{Environment.NewLine}" +
                $"    {namespace2}{Environment.NewLine}" +
                $"      {namespace3}{Environment.NewLine}" +
                $"{header} 2:{Environment.NewLine}" +
                $"  {namespace4}{Environment.NewLine}" +
                $"    {namespace5}{Environment.NewLine}" +
                $"      {namespace6}{Environment.NewLine}");
        }
        public void ShouldReturnADirectPathFromSourceToDestination()
        {
            //GIVEN
            var cache      = new NamespacesDependenciesCache();
            var namespace1 = Any.Instance <NamespaceName>();
            var namespace2 = Any.Instance <NamespaceName>();

            cache.AddMapping(namespace1, namespace2);

            //WHEN
            var paths = cache.RetrievePathsBetween(
                Pattern.WithoutExclusion(namespace1.ToString()),
                Pattern.WithoutExclusion(namespace2.ToString()));

            //THEN
            paths[0].Should().Be(NamespaceDependencyPath.With(
                                     namespace1,
                                     namespace2
                                     ));
            paths.Should().HaveCount(1);
        }