public void OnlyIncludeFilesWhichExist()
            {
                // arrange
                var mockFileSystem = MockGenerator.CreateMockFileSystem();

                // mock Bar.dll to not exist
                mockFileSystem.Setup(fs => fs.FileExists(It.IsAny <string>())).Returns <string>((s) => !s.Contains("Bar.dll"));

                var mockMSBuildProject = MockGenerator.CreateMockMSBuildProject();

                mockMSBuildProject.Setup(p => p.GetItemsWithMetadataProperty("Reference", "HintPath")).Returns(new Dictionary <string, string>()
                {
                    { "Foo", @"packages\Foo.dll" },
                    { "Bar", @"packages\Bar.dll" },
                    { "Baz", @"packages\Baz.dll" }
                });

                Dependencies.FileSystem            = mockFileSystem.Object;
                Dependencies.MSBuildProjectFactory = MockGenerator.CreateMSBuildProjectFactory(mockMSBuildProject.Object);

                // act
                var projectSystem = new NuGetMsBuildProjectSystem(@"C:\Dummy\Dummy.csproj");
                var results       = projectSystem.GetAssemblyReferencePaths();

                // assert
                string[] expected = { @"C:\Dummy\packages\Foo.dll", @"C:\Dummy\packages\Baz.dll" };
                Assert.Equal(expected, results);
            }
            public void StripExtensionFromReferenceName(string assemblyName, string expectedReferenceName)
            {
                // arrange
                var mockProject = MockGenerator.CreateMockMSBuildProject();

                mockProject.Setup(p => p.ReferenceExists(expectedReferenceName)).Verifiable();

                // act
                var projectSystem = new NuGetMsBuildProjectSystem(@"C:\DummyPath\Dummy.csproj", MockGenerator.CreateMSBuildProjectFactory(mockProject.Object));

                // assert
                Assert.False(projectSystem.ReferenceExists(assemblyName));
                mockProject.Verify();
            }
            public void OnlySearchReferenceItemType()
            {
                // arrange
                var mockProject = MockGenerator.CreateMockMSBuildProject();

                mockProject.Setup(p => p.ReferenceExists("DummyReference")).Returns(false).Verifiable();
                mockProject.Setup(p => p.ItemExists("Content", "DummyReference")).Returns(true);

                // act
                var projectSystem = new NuGetMsBuildProjectSystem(@"C:\DummyPath\Dummy.csproj", MockGenerator.CreateMSBuildProjectFactory(mockProject.Object));

                // assert
                Assert.False(projectSystem.ReferenceExists("DummyReference.dll"));
                mockProject.Verify();
            }
            public void UseRelativeHintPath(string fullPath, string hintPath)
            {
                // arrange
                var    mockProject = MockGenerator.CreateMockMSBuildProject();
                string actualHint  = "";

                mockProject.Setup(p => p.AddReference(It.IsAny <string>(), It.IsAny <string>()))
                .Callback <string, string>((_, hint) => actualHint = hint)
                .Verifiable();

                // act
                var projectSystem = new NuGetMsBuildProjectSystem(@"C:\DummyPath\Dummy.csproj", MockGenerator.CreateMSBuildProjectFactory(mockProject.Object));

                projectSystem.AddReference(fullPath, Stream.Null);

                // assert
                Assert.Equal(hintPath, actualHint);
                mockProject.Verify();
            }
            public void ReturnsFullPaths(string inputPath, IEnumerable <string> expected)
            {
                // arrange
                var mockFileSystem = MockGenerator.CreateMockFileSystem();

                mockFileSystem.Setup(fs => fs.FileExists(It.IsAny <string>())).Returns(true);

                var mockMSBuildProject = MockGenerator.CreateMockMSBuildProject();

                mockMSBuildProject.Setup(p => p.GetItemsWithMetadataProperty("Reference", "HintPath")).Returns(new Dictionary <string, string>()
                {
                    { Path.GetFileNameWithoutExtension(inputPath), inputPath }
                });

                Dependencies.FileSystem            = mockFileSystem.Object;
                Dependencies.MSBuildProjectFactory = MockGenerator.CreateMSBuildProjectFactory(mockMSBuildProject.Object);

                // act
                var projectSystem = new NuGetMsBuildProjectSystem(@"C:\Dummy\Dummy.csproj");
                var results       = projectSystem.GetAssemblyReferencePaths();

                // assert
                Assert.Equal(expected, results);
            }