public void BuildProjectAsync_ArgumentNullException_Project() { // Arrange var vsaMock = Mock.Of <IVisualStudioAccess>(); var fsaMock = Mock.Of <IFileSystemAccess>(); var loggerMock = Mock.Of <ILogger>(); IBuildService service = new BuildService(vsaMock, fsaMock, loggerMock); // Act & Assert // ReSharper disable once AssignNullToNotNullAttribute Assert.Throws <ArgumentNullException>(() => service.BuildProjectAsync(null)); }
public async Task BuildProjectAsync_Correctly_Async() { // Arrange var project = new SqlProject("a", @"C:\TestProject\TestProject.sqlproj", "c"); var vsaMock = new Mock <IVisualStudioAccess>(); var fsaMock = Mock.Of <IFileSystemAccess>(); var loggerMock = new Mock <ILogger>(); IBuildService service = new BuildService(vsaMock.Object, fsaMock, loggerMock.Object); // Act var result = await service.BuildProjectAsync(project); // Assert Assert.IsTrue(result); vsaMock.Verify(m => m.BuildProject(project), Times.Once); }
public async Task BuildProjectAsync_LogException_Async() { // Arrange var testException = new InvalidOperationException("test exception"); var project = new SqlProject("a", @"C:\TestProject\TestProject.sqlproj", "c"); var vsaMock = new Mock <IVisualStudioAccess>(); vsaMock.Setup(m => m.BuildProject(project)) .Throws(testException); var fsaMock = Mock.Of <IFileSystemAccess>(); var loggerMock = new Mock <ILogger>(); IBuildService service = new BuildService(vsaMock.Object, fsaMock, loggerMock.Object); // Act var result = await service.BuildProjectAsync(project); // Assert Assert.IsFalse(result); vsaMock.Verify(m => m.BuildProject(project), Times.Once); loggerMock.Verify(m => m.LogErrorAsync(testException, @"Failed to build C:\TestProject\TestProject.sqlproj"), Times.Once); }