public void FindProjectItemReturnsNullIfFoundInProjectButIsNonExistent() { // Arrange const string itemName = "ItemName"; const string fullName = "FullName"; var ioService = Mock.Of <IIOService>(f => f.FileExists(It.IsAny <string>()) == false); var dte = Mock.Of <DTE2>(d => d.Solution == Mock.Of <Solution>(s => s.FindProjectItem(itemName) == Mock.Of <ProjectItem>(p => p.get_FileNames(1) == fullName))); var service = new ProjectItemService(dte, ioService); // Act var item = service.FindProjectItem(itemName); // Assert Mock.Get(ioService).Verify(f => f.FileExists(It.IsAny <string>())); Assert.IsNull(item); }
public void FindProjectItemDoesNotCheckFileExistenceIfItemIsNotFoundInProject() { // Arrange const string itemName = "ItemName"; var solutionMock = new Mock <Solution>(); solutionMock .Setup(s => s.FindProjectItem(It.IsAny <string>())) .Returns <ProjectItem>(null); var ioService = Mock.Of <IIOService>(); var dte = Mock.Of <DTE2>(d => d.Solution == solutionMock.Object); var service = new ProjectItemService(dte, ioService); // Act var item = service.FindProjectItem(itemName); // Assert Mock.Get(ioService) .Verify(f => f.FileExists(It.IsAny <string>()), Times.Never); Assert.IsNull(item); }
public void FindProjectItemReturnsItemIfFoundInProjectAndExists() { // Arrange const string itemName = "ItemName"; const string fullName = "FullName"; var ioService = Mock.Of <IIOService>(f => f.FileExists(fullName) == true); var projectItem = Mock.Of <ProjectItem>(p => p.get_FileNames(1) == fullName); var dte = Mock.Of <DTE2>(d => d.Solution == Mock.Of <Solution>(s => s.FindProjectItem(itemName) == projectItem)); var service = new ProjectItemService(dte, ioService); // Act var item = service.FindProjectItem(itemName); // Assert Mock.Get(ioService).Verify(f => f.FileExists(fullName)); Assert.AreEqual(projectItem, item); }
/// <summary> /// Project Item added event handler. /// </summary> /// <param name="projectItem">The project item.</param> internal void ProjectItemsEventsItemAdded(ProjectItem projectItem) { string message = string.Format( "BaseController::ProjectItemsEventsItemAdded file={0}", projectItem.Name); TraceService.WriteLine(message); ProjectItemService projectItemService = new ProjectItemService(projectItem); this.ProjectItemAdded(projectItemService); }