public async Task Work_ScaffoldingStateModel_CopyFailed_Async() { // Arrange var project = new SqlProject("a", "b", "c"); var configuration = ConfigurationModel.GetDefault(); var targetVersion = new Version(1, 2, 3); Task HandleWorkInProgressChanged(bool arg) => Task.CompletedTask; var directories = new DirectoryPaths("projectDirectory", "latestArtifactsDirectory", "newArtifactsDirectory"); var sourcePaths = new DeploySourcePaths("newDacpacPath", "publishProfilePath", "previousDacpacPath"); var targetPaths = new DeployTargetPaths("deployScriptPath", "deployReportPath"); var paths = new PathCollection(directories, sourcePaths, targetPaths); var model = new ScaffoldingStateModel(project, configuration, targetVersion, HandleWorkInProgressChanged) { Paths = paths }; var bsMock = new Mock <IBuildService>(); bsMock.Setup(m => m.CopyBuildResultAsync(project, paths.Directories.NewArtifactsDirectory)).ReturnsAsync(false); IWorkUnit <ScaffoldingStateModel> unit = new CopyBuildResultUnit(bsMock.Object); // Act await unit.Work(model, CancellationToken.None); // Assert Assert.AreEqual(StateModelState.TriedToCopyBuildResult, model.CurrentState); Assert.IsFalse(model.Result); }
public void GetNextWorkUnit_ScriptCreationStateModel_CorrectWorkUnitTriedToCleanArtifactsDirectory() { // Arrange var bsMock = Mock.Of <IBuildService>(); var expectedWorkUnit = new CopyBuildResultUnit(bsMock); var drMock = new Mock <IDependencyResolver>(); drMock.Setup(m => m.Get <CopyBuildResultUnit>()).Returns(expectedWorkUnit); IWorkUnitFactory wuf = new WorkUnitFactory(drMock.Object); var project = new SqlProject("a", "b", "c"); var configuration = ConfigurationModel.GetDefault(); var previousVersion = new Version(1, 0); Task HandlerFunc(bool b) => Task.CompletedTask; var model = new ScriptCreationStateModel(project, configuration, previousVersion, false, HandlerFunc) { CurrentState = StateModelState.TriedToCleanArtifactsDirectory }; // Act var workUnit = wuf.GetNextWorkUnit(model); // Assert Assert.AreSame(expectedWorkUnit, workUnit); drMock.Verify(m => m.Get <CopyBuildResultUnit>(), Times.Once); }
public void Work_ScaffoldingStateModel_ArgumentNullException_StateModel() { // Arrange var bsMock = new Mock <IBuildService>(); IWorkUnit <ScaffoldingStateModel> unit = new CopyBuildResultUnit(bsMock.Object); // Act & Assert // ReSharper disable once AssignNullToNotNullAttribute Assert.Throws <ArgumentNullException>(() => unit.Work(null, CancellationToken.None)); }