Example #1
0
        public void Dependency_EqualsAndGetHashCode()
        {
            var mockModel1 = IDependencyModelFactory.Implement(
                providerType: "providerType",
                id: "someId1");
            var mockModel2 = IDependencyModelFactory.Implement(
                providerType: "providerType",
                id: "someId1");
            var mockModel3 = IDependencyModelFactory.Implement(
                providerType: "providerType",
                id: "someId_other");

            var targetFramework = ITargetFrameworkFactory.Implement("tfm1");
            var dependency1     = new Dependency(mockModel1, targetFramework, @"C:\Foo\Project.csproj");
            var dependency2     = new Dependency(mockModel2, targetFramework, @"C:\Foo\Project.csproj");
            var dependency3     = new Dependency(mockModel3, targetFramework, @"C:\Foo\Project.csproj");

            Assert.Equal(dependency1, dependency2);
            Assert.NotEqual(dependency1, dependency3);
            Assert.False(dependency1.Equals(other: null));
            Assert.Equal(dependency1.GetHashCode(), dependency2.GetHashCode());
            Assert.NotEqual(dependency1.GetHashCode(), dependency3.GetHashCode());
        }
        public void Dependency_EqualsAndGetHashCode()
        {
            var dependencyModel1 = new TestDependencyModel {
                ProviderType = "providerType", Id = "someId1"
            };
            var dependencyModel2 = new TestDependencyModel {
                ProviderType = "providerType", Id = "someId1"
            };
            var dependencyModel3 = new TestDependencyModel {
                ProviderType = "providerType", Id = "someId_other"
            };

            var targetFramework = new TargetFramework("tfm1");
            var dependency1     = new Dependency(dependencyModel1, targetFramework, @"C:\Foo\Project.csproj");
            var dependency2     = new Dependency(dependencyModel2, targetFramework, @"C:\Foo\Project.csproj");
            var dependency3     = new Dependency(dependencyModel3, targetFramework, @"C:\Foo\Project.csproj");

            Assert.Equal(dependency1, dependency2);
            Assert.NotEqual(dependency1, dependency3);
            Assert.False(dependency1.Equals(other: null));
            Assert.Equal(dependency1.GetHashCode(), dependency2.GetHashCode());
            Assert.NotEqual(dependency1.GetHashCode(), dependency3.GetHashCode());
        }