public async Task GetAssetsFilePathAsync_WithValidMSBuildProjectExtensionsPath_Succeeds() { // Arrange using (var testDirectory = TestDirectory.Create()) { var testMSBuildProjectExtensionsPath = Path.Combine(testDirectory, "obj"); Directory.CreateDirectory(testMSBuildProjectExtensionsPath); var projectAdapter = Mock.Of <IVsProjectAdapter>(); Mock.Get(projectAdapter) .SetupGet(x => x.MSBuildProjectExtensionsPath) .Returns(testMSBuildProjectExtensionsPath); var testProject = new LegacyPackageReferenceProject( projectAdapter, Guid.NewGuid().ToString(), new TestProjectSystemServices(), _threadingService); await _threadingService.JoinableTaskFactory.SwitchToMainThreadAsync(); // Act var assetsPath = await testProject.GetAssetsFilePathAsync(); // Assert Assert.Equal(Path.Combine(testMSBuildProjectExtensionsPath, "project.assets.json"), assetsPath); // Verify Mock.Get(projectAdapter) .VerifyGet(x => x.MSBuildProjectExtensionsPath, Times.AtLeastOnce); } }
public async Task GetAssetsFilePathAsync_WithNoMSBuildProjectExtensionsPath_Throws() { // Arrange using (TestDirectory.Create()) { var testProject = new LegacyPackageReferenceProject( Mock.Of <IVsProjectAdapter>(), Guid.NewGuid().ToString(), new TestProjectSystemServices(), _threadingService); await _threadingService.JoinableTaskFactory.SwitchToMainThreadAsync(); // Act & Assert await Assert.ThrowsAsync <InvalidDataException>( () => testProject.GetAssetsFilePathAsync()); } }