예제 #1
0
        public async Task Work_ScaffoldingStateModel_LoadedSuccessful_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 model       = new ScaffoldingStateModel(project, configuration, targetVersion, HandleWorkInProgressChanged);
            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 spsMock     = new Mock <ISqlProjectService>();

            spsMock.Setup(m => m.TryLoadPathsForScaffoldingAsync(project, configuration)).ReturnsAsync(paths);
            IWorkUnit <ScaffoldingStateModel> unit = new LoadPathsUnit(spsMock.Object);

            // Act
            await unit.Work(model, CancellationToken.None);

            // Assert
            Assert.AreEqual(StateModelState.PathsLoaded, model.CurrentState);
            Assert.IsNull(model.Result);
        }
예제 #2
0
        public void Work_ScriptCreationStateModel_ArgumentNullException_StateModel()
        {
            // Arrange
            var spsMock = new Mock <ISqlProjectService>();
            IWorkUnit <ScriptCreationStateModel> unit = new LoadPathsUnit(spsMock.Object);

            // Act & Assert
            // ReSharper disable once AssignNullToNotNullAttribute
            Assert.Throws <ArgumentNullException>(() => unit.Work(null, CancellationToken.None));
        }
예제 #3
0
        public async Task Work_ScaffoldingStateModel_LoadFailed_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 model   = new ScaffoldingStateModel(project, configuration, targetVersion, HandleWorkInProgressChanged);
            var spsMock = new Mock <ISqlProjectService>();

            spsMock.Setup(m => m.TryLoadPathsForScaffoldingAsync(project, configuration)).ReturnsAsync(null as PathCollection);
            IWorkUnit <ScaffoldingStateModel> unit = new LoadPathsUnit(spsMock.Object);

            // Act
            await unit.Work(model, CancellationToken.None);

            // Assert
            Assert.AreEqual(StateModelState.PathsLoaded, model.CurrentState);
            Assert.IsFalse(model.Result);
        }