示例#1
0
        public void FindProjectByName_Should_Return_Project_TypeOf_ListEmployeeDetailsModel_If_Project_Exists()
        {
            // Arrange
            var projectToReturn = new Project
            {
                Name = "TestProject"
            };

            mapperStub.Setup(x => x.Map <Project>(It.IsAny <CreateProjectModel>())).Returns(projectToReturn);

            // Act
            createProjectService.Execute(new List <string>()
            {
                "createProject", "TestProject"
            });

            var projectExists = this.dbStub
                                .Projects
                                .Where(p => p.Name == "TestProject")
                                .ProjectTo <ListProjectDetailsModel>()
                                .SingleOrDefault();

            // Assert
            Assert.IsInstanceOfType(projectExists, typeof(ListProjectDetailsModel));
        }
        public void ListProjects_Should_Return_ProjectList_TypeOf_ListEmployeesModel_If_Prpjects_Are_Found()
        {
            // Arrange
            var projectToReturn = new Project
            {
                Name = "TestProject"
            };

            mapperStub.Setup(x => x.Map <Project>(It.IsAny <CreateProjectModel>())).Returns(projectToReturn);

            // Act
            createProjectService.Execute(new List <string>()
            {
                "createProject", "TestProject"
            });

            // Act
            listProjectsService.Execute(new List <string>()
            {
                "listEmployees"
            });

            var projects = this.dbStub
                           .Projects
                           .ProjectTo <ListProjectsModel>()
                           .ToList();

            // Assert
            Assert.IsInstanceOfType(projects, typeof(List <ListProjectsModel>));
        }
示例#3
0
        public void ListProjectDetails_Should_Should_Find_Concrete_Project()
        {
            var projectToReturn = new Project
            {
                Name = "TestProject"
            };

            mapperStub.Setup(x => x.Map <Project>(It.IsAny <CreateProjectModel>())).Returns(projectToReturn);

            createProjectService.Execute(new List <string>()
            {
                "createProject", "TestProject"
            });

            // Act
            listProjectDetailsService.Execute(new List <string>()
            {
                "listProjectDetails", "TestProject"
            });

            var project = this.dbStub
                          .Projects
                          .Where(e => e.Name == "TestProject")
                          .ProjectTo <ListProjectDetailsModel>()
                          .SingleOrDefault();

            // Assert
            Assert.AreEqual("TestProject", project.Name);
        }
        public void CreateProject_Should_Throw_ArgumentException_If_No_Params_Are_Passed()
        {
            // Arrange
            var parameters = new List <string>()
            {
                "createProject"
            };

            // Act && Assert
            Assert.ThrowsException <ArgumentException>(() => createProjectService.Execute(parameters));
        }
        public CreateProjectProgressViewModel(FlutnetAppSettings appSettings, FlutnetProjectSettings projectSettings, NewProjectViewModel screen = null) : base("newprj_progress", screen)
        {
            _appSettings     = appSettings;
            _projectSettings = projectSettings;

            Title                = "New Project";
            Description          = "The project will take some time to generate.\nWait until the procedure finish.\n";
            IsDescriptionVisible = false;

            NextText     = "Finish";
            BackVisible  = false;
            IsFinishPage = true;

            OutputLines = new ObservableCollection <string>();
            // Observe any changes in the observable collection.
            // Note that the property has no public setters, so we
            // assume the collection is mutated by using the Add(),
            // Delete(), Clear() and other similar methods.
            OutputLines
            // Convert the collection to a stream of chunks,
            // so we have IObservable<IChangeSet<TKey, TValue>>
            // type also known as the DynamicData monad.
            .ToObservableChangeSet()
            // Each time the collection changes, we get
            // all updated items at once.
            .ToCollection()
            // Aggregate all the elements in the collection
            // into a multi-line string.
            .Select(lines => string.Join(Environment.NewLine, lines))
            // Then, we convert the multi-line string to the
            // property a multi-line TextBox can bind.
            .ToProperty(this, x => x.Output, out _output, scheduler: RxApp.MainThreadScheduler);

            // Create the command that calls Flutnet CLI
            CreateProject = ReactiveCommand.CreateFromTask(async ct =>
            {
                NewProjectInArg arguments = BuildCommandLineArg();

                CommandLineCallResult callResult = await CommandLineTools.Call <NewProjectOutArg>(arguments, ct, line =>
                {
                    OutputLines.Add(line);
                });

                // This is not the proper way to change property values and raise property change notifications:
                // we should return a public object and subscribe to the command observable
                // so that we can use ReactiveUI framework methods such as ToProperty, BindTo etc.
                if (callResult.Canceled)
                {
                    IsCanceled = true;
                }
                else if (callResult.Failed)
                {
                    IsFailed = true;
                }
                else
                {
                    OutArg result = callResult.CommandResult;
                    if (!result.Success)
                    {
                        IsFailed = true;
                    }
                    else
                    {
                        IsCompletedSuccessfully = true;
                    }
                }
            });

            CreateProject.IsExecuting.ToProperty(this, x => x.IsInProgress, out _isInProgress);
            CreateProject.IsExecuting.BindTo(this, x => x.IsBusy);

            BrowseProject = ReactiveCommand.Create(
                execute: () => Launcher.OpenFolder(Path.Combine(projectSettings.Location, projectSettings.SolutionName)),
                canExecute: this.WhenAnyValue(t => t.IsCompletedSuccessfully));

            // Execute the command when the View is activated
            Activator = new ViewModelActivator();
            this.WhenActivated(disposables =>
            {
                CreateProject.Execute(Unit.Default).Subscribe().DisposeWith(disposables);
            });

            this.WhenAnyValue(t => t.IsInProgress, t => !t).BindTo(this, t => t.NextEnabled);
        }