Esempio n. 1
0
        public void Equals_WithRuntimeAssembliesAndRelatedFiles(string left, string right, bool expected)
        {
            string[] leftParts           = left.Trim().Split(' ');
            var      leftRuntimeAssembly = new LockFileItem(leftParts[0]);

            if (leftParts.Length > 1)
            {
                leftRuntimeAssembly.Properties.Add("related", leftParts[1]);
            }
            var leftSide = new LockFileTargetLibrary()
            {
                RuntimeAssemblies = new List <LockFileItem>()
                {
                    leftRuntimeAssembly
                }
            };

            string[] rightParts           = right.Split(' ');
            var      rightRuntimeAssembly = new LockFileItem(rightParts[0]);

            if (rightParts.Length > 1)
            {
                rightRuntimeAssembly.Properties.Add("related", rightParts[1]);
            }
            var rightSide = new LockFileTargetLibrary()
            {
                RuntimeAssemblies = new List <LockFileItem>()
                {
                    rightRuntimeAssembly
                }
            };

            // Act & Assert
            if (expected)
            {
                leftSide.Should().Be(rightSide);
            }
            else
            {
                leftSide.Should().NotBe(rightSide);
            }
        }
        public void Equals_WithType(string left, string right, bool expected)
        {
            var leftSide = new LockFileTargetLibrary()
            {
                Type = left
            };

            var rightSide = new LockFileTargetLibrary()
            {
                Type = right
            };

            // Act & Assert
            if (expected)
            {
                leftSide.Should().Be(rightSide);
            }
            else
            {
                leftSide.Should().NotBe(rightSide);
            }
        }
        public void Equals_WithRuntimeTargets(string left, string right, bool expected)
        {
            var leftSide = new LockFileTargetLibrary()
            {
                RuntimeTargets = left.Split(';').Select(e => new LockFileRuntimeTarget(e)).ToList()
            };

            var rightSide = new LockFileTargetLibrary()
            {
                RuntimeTargets = right.Split(';').Select(e => new LockFileRuntimeTarget(e)).ToList()
            };

            // Act & Assert
            if (expected)
            {
                leftSide.Should().Be(rightSide);
            }
            else
            {
                leftSide.Should().NotBe(rightSide);
            }
        }
        public void Equals_WithVersion(string left, string right, bool expected)
        {
            var leftSide = new LockFileTargetLibrary()
            {
                Version = NuGetVersion.Parse(left)
            };

            var rightSide = new LockFileTargetLibrary()
            {
                Version = NuGetVersion.Parse(right)
            };

            // Act & Assert
            if (expected)
            {
                leftSide.Should().Be(rightSide);
            }
            else
            {
                leftSide.Should().NotBe(rightSide);
            }
        }
        public void Equals_WithBuildMultiTargeting(string left, string right, bool expected)
        {
            var leftSide = new LockFileTargetLibrary()
            {
                BuildMultiTargeting = left.Split(';').Select(e => new LockFileItem(e)).ToList()
            };

            var rightSide = new LockFileTargetLibrary()
            {
                BuildMultiTargeting = right.Split(';').Select(e => new LockFileItem(e)).ToList()
            };

            // Act & Assert
            if (expected)
            {
                leftSide.Should().Be(rightSide);
            }
            else
            {
                leftSide.Should().NotBe(rightSide);
            }
        }
        public void Equals_WithFrameworkReferences(string left, string right, bool expected)
        {
            var leftSide = new LockFileTargetLibrary()
            {
                FrameworkReferences = left.Split(';').Select(e => e).ToList()
            };

            var rightSide = new LockFileTargetLibrary()
            {
                FrameworkReferences = right.Split(';').Select(e => e).ToList()
            };

            // Act & Assert
            if (expected)
            {
                leftSide.Should().Be(rightSide);
            }
            else
            {
                leftSide.Should().NotBe(rightSide);
            }
        }
        public void Equals_WithPackageDependency(string left, string right, bool expected)
        {
            var leftSide = new LockFileTargetLibrary()
            {
                Dependencies = left.Split(';').Select(e => new PackageDependency(e, VersionRange.Parse("1.0.0"))).ToList()
            };

            var rightSide = new LockFileTargetLibrary()
            {
                Dependencies = right.Split(';').Select(e => new PackageDependency(e, VersionRange.Parse("1.0.0"))).ToList()
            };

            // Act & Assert
            if (expected)
            {
                leftSide.Should().Be(rightSide);
            }
            else
            {
                leftSide.Should().NotBe(rightSide);
            }
        }
        public void Equals_WithPackageType_IsIgnored()
        {
            var leftSide = new LockFileTargetLibrary()
            {
                PackageType = new List <PackageType>()
                {
                    PackageType.Dependency
                }
            };

            var rightSide = new LockFileTargetLibrary()
            {
                PackageType = new List <PackageType>()
                {
                    PackageType.DotnetCliTool
                }
            };

            leftSide.Should().Be(rightSide);
        }