public void GetExistingArtifactVersions_ShowError_InvalidArtifactsPathConfiguration() { // Arrange var project = new SqlProject("a", @"C:\TestProject\TestProject.sqlproj", "c"); var config = new ConfigurationModel { ArtifactsPath = "", PublishProfilePath = "TestProfile.publish.xml", ReplaceUnnamedDefaultConstraintDrops = false, VersionPattern = "1.2.3.4", CommentOutUnnamedDefaultConstraintDrops = true, CreateDocumentationWithScriptCreation = false, CustomHeader = "TestHeader", CustomFooter = "TestFooter", BuildBeforeScriptCreation = true, TrackDacpacVersion = true }; var vsaMock = new Mock <IVisualStudioAccess>(); var fsaMock = new Mock <IFileSystemAccess>(); IArtifactsService service = new ArtifactsService(vsaMock.Object, fsaMock.Object); // Act var result = service.GetExistingArtifactVersions(project, config); // Assert Assert.IsNotNull(result); Assert.AreEqual(0, result.Length); vsaMock.Verify(m => m.ShowModalError("ERROR: The configured artifacts path is not valid. Please ensure that the configuration is correct."), Times.Once); }
public void GetExistingArtifactVersions_NoValidDirectories() { // Arrange var project = new SqlProject("a", @"C:\TestProject\TestProject.sqlproj", "c"); var config = new ConfigurationModel { ArtifactsPath = "_Deployment", PublishProfilePath = "TestProfile.publish.xml", ReplaceUnnamedDefaultConstraintDrops = false, VersionPattern = "1.2.3.4", CommentOutUnnamedDefaultConstraintDrops = true, CreateDocumentationWithScriptCreation = false, CustomHeader = "TestHeader", CustomFooter = "TestFooter", BuildBeforeScriptCreation = true, TrackDacpacVersion = true }; var vsaMock = new Mock <IVisualStudioAccess>(); var fsaMock = new Mock <IFileSystemAccess>(); fsaMock.Setup(m => m.GetDirectoriesIn(@"C:\TestProject\_Deployment")) .Returns(new [] { @"C:\TestProject\_Deployment\foo" }); IArtifactsService service = new ArtifactsService(vsaMock.Object, fsaMock.Object); // Act var result = service.GetExistingArtifactVersions(project, config); // Assert Assert.IsNotNull(result); Assert.AreEqual(0, result.Length); vsaMock.Verify(m => m.ShowModalError(It.IsAny <string>()), Times.Never); }
public void GetExistingArtifactVersions_ShowError_ExceptionDuringFileSystemAccess() { // Arrange var project = new SqlProject("a", @"C:\TestProject\TestProject.sqlproj", "c"); var config = new ConfigurationModel { ArtifactsPath = "_Deployment", PublishProfilePath = "TestProfile.publish.xml", ReplaceUnnamedDefaultConstraintDrops = false, VersionPattern = "1.2.3.4", CommentOutUnnamedDefaultConstraintDrops = true, CreateDocumentationWithScriptCreation = false, CustomHeader = "TestHeader", CustomFooter = "TestFooter", BuildBeforeScriptCreation = true, TrackDacpacVersion = true }; var vsaMock = new Mock <IVisualStudioAccess>(); var fsaMock = new Mock <IFileSystemAccess>(); fsaMock.Setup(m => m.GetDirectoriesIn(@"C:\TestProject\_Deployment")) .Throws(new InvalidOperationException("test exception")); IArtifactsService service = new ArtifactsService(vsaMock.Object, fsaMock.Object); // Act var result = service.GetExistingArtifactVersions(project, config); // Assert Assert.IsNotNull(result); Assert.AreEqual(0, result.Length); vsaMock.Verify(m => m.ShowModalError("ERROR: Failed to open script creation window: test exception"), Times.Once); }
public void GetExistingArtifactVersions_ArgumentNullException_Project() { // Arrange var vsaMock = Mock.Of <IVisualStudioAccess>(); var fsaMock = Mock.Of <IFileSystemAccess>(); IArtifactsService service = new ArtifactsService(vsaMock, fsaMock); // Act & Assert // ReSharper disable AssignNullToNotNullAttribute Assert.Throws <ArgumentNullException>(() => service.GetExistingArtifactVersions(null, null)); // ReSharper restore AssignNullToNotNullAttribute }