public async Task ShouldUpdateStepsIntoScenario() { var createScenarioCommand = new CreateScenarioCommand("s1", createProjectDto.Id); var createScenarioDto = await SendAsync(createScenarioCommand); var updateScenarioCommand = new UpdateStepsToScenarioCommand(createScenarioDto.Id, createProjectDto.Id, new List <UpdateStepsToScenarioCommand.StepDto> { new UpdateStepsToScenarioCommand.StepDto(1, "step 1"), new UpdateStepsToScenarioCommand.StepDto(2, "step 2"), new UpdateStepsToScenarioCommand.StepDto(3, "step 3"), }); await SendAsync(updateScenarioCommand); var scenarioEntity = await ExecuteDbContextAsync(db => db.Scenarios .Include(s => s.StepsList) .SingleOrDefaultAsync(p => p.Id.Equals(createScenarioDto.Id)) ); scenarioEntity.ShouldNotBeNull(); scenarioEntity.StepsList.Count.ShouldBe(3); var deleteScenarioCommand = new DeleteScenarioCommand(createScenarioDto.Id, createProjectDto.Id); await SendAsync(deleteScenarioCommand); scenarioEntity = await ExecuteDbContextAsync(db => db.Scenarios .SingleOrDefaultAsync(p => p.Id.Equals(createScenarioDto.Id)) ); scenarioEntity.ShouldBeNull(); }
public ViewModel() { model = new Model(this); plotModel = new PlotModel(new Plot("test")); TestWCF = new PokeServerCommand(this); CreateScenario = new CreateScenarioCommand(this); }
public async Task ShouldUpdateScenario() { var createScenarioCommand = new CreateScenarioCommand("s1", createProjectDto.Id); var createScenarioDto = await SendAsync(createScenarioCommand); var updateScenarioCommand = new UpdateScenarioCommand(createScenarioDto.Id, createProjectDto.Id, "description 1"); await SendAsync(updateScenarioCommand); var scenarioEntity = await ExecuteDbContextAsync(db => db.Scenarios .SingleOrDefaultAsync(p => p.Id.Equals(createScenarioDto.Id)) ); scenarioEntity.ShouldNotBeNull(); scenarioEntity.Description.ShouldBe("description 1"); var deleteScenarioCommand = new DeleteScenarioCommand(createScenarioDto.Id, createProjectDto.Id); await SendAsync(deleteScenarioCommand); scenarioEntity = await ExecuteDbContextAsync(db => db.Scenarios .SingleOrDefaultAsync(p => p.Id.Equals(createScenarioDto.Id)) ); scenarioEntity.ShouldBeNull(); }
public async Task ShouldGetScenarioWithSteps() { var createScenarioCommand = new CreateScenarioCommand("s1", createProjectDto.Id); var createScenarioDto = await SendAsync(createScenarioCommand); var updateStepsToScenarioCommand = new UpdateStepsToScenarioCommand(createScenarioDto.Id, createProjectDto.Id, new List <UpdateStepsToScenarioCommand.StepDto> { new UpdateStepsToScenarioCommand.StepDto(1, "step 1"), new UpdateStepsToScenarioCommand.StepDto(2, "step 2"), new UpdateStepsToScenarioCommand.StepDto(3, "step 3"), }); await SendAsync(updateStepsToScenarioCommand); var getScenarioCommand = new GetScenarioQuery(createScenarioDto.Id, createProjectDto.Id, true); var getScenarioDto = await SendAsync(getScenarioCommand); getScenarioDto.ShouldNotBeNull(); getScenarioDto.StepList.ShouldNotBeNull(); getScenarioDto.StepList.Count.ShouldBe(3); getScenarioDto.Description.ShouldBe("s1"); getScenarioDto.ProjectId.ShouldBe(createProjectDto.Id); var deleteScenarioCommand = new DeleteScenarioCommand(createScenarioDto.Id, createProjectDto.Id); await SendAsync(deleteScenarioCommand); }
public override async Task InitializeAsync() { await base.DisposeAsync(); createProjectCommand = new CreateProjectCommand("project1", true); createProjectDto = await SendAsync(createProjectCommand); createFeatureCommand = new CreateFeatureCommand("feature1", createProjectDto.Id); createFeatureDto = await SendAsync(createFeatureCommand); createScenarioCommand = new CreateScenarioCommand("s1", createProjectDto.Id); createScenarioDto = await SendAsync(createScenarioCommand); }
public async Task <ActionResult <Guid> > NewScenario(CreateScenarioCommand createScenarioCommand) { var vm = await mediator.Send(createScenarioCommand); if (vm.Id != Guid.Empty) { var link = Url.Link(nameof(GetScenario), new { scenarioId = vm.Id, projectId = createScenarioCommand.ProjectId }); return(Created(link, vm)); } else { return(BadRequest(vm)); } }
public async Task ShouldGetScenarioList() { var createScenarioCommand = new CreateScenarioCommand("s1", createProjectDto.Id); var createScenarioDto = await SendAsync(createScenarioCommand); var getScenarioListCommand = new GetScenarioListQuery(createProjectDto.Id, false, false); var getScenarioListDto = await SendAsync(getScenarioListCommand); getScenarioListDto.ShouldNotBeNull(); getScenarioListDto.Data.ShouldNotBeNull(); getScenarioListDto.Count.ShouldNotBe(0); getScenarioListDto.Data.ShouldBeOfType <List <GetScenarioDto> >(); var deleteScenarioCommand = new DeleteScenarioCommand(createScenarioDto.Id, createProjectDto.Id); await SendAsync(deleteScenarioCommand); }
public async Task ShouldGetScenario() { var createScenarioCommand = new CreateScenarioCommand("s1", createProjectDto.Id); var createScenarioDto = await SendAsync(createScenarioCommand); var getScenarioCommand = new GetScenarioQuery(createScenarioDto.Id, createProjectDto.Id, false); var getScenarioDto = await SendAsync(getScenarioCommand); getScenarioDto.ShouldNotBeNull(); getScenarioDto.StepList.Count.ShouldBe(0); getScenarioDto.Description.ShouldBe("s1"); getScenarioDto.ProjectId.ShouldBe(createProjectDto.Id); var deleteScenarioCommand = new DeleteScenarioCommand(createScenarioDto.Id, createProjectDto.Id); await SendAsync(deleteScenarioCommand); }
public void Handle_ValidCommand_AddsScenarioWithCorrectNameToRepository() { Procedure procedure = new Procedure("Test Procedure"); CreateScenarioCommand command = new CreateScenarioCommand { Name = "Test", ProcedureId = procedure.Id }; this._repositoryMock .Setup(r => r.Get(command.ProcedureId)) .Returns(Task.FromResult(procedure)); this._repositoryMock .Setup(r => r.Update(procedure)) .Returns(Task.CompletedTask); CreateScenarioCommandHandler handler = this.CreateHandler(); handler.Handle(command).Wait(); this._repositoryMock.Verify(r => r.Update(It.Is <Procedure>(p => p.Scenarios.Any(s => s.Name == command.Name))), Times.Once()); }
public async Task <IActionResult> AddScenario(Guid procedureId, [FromBody] CreateScenarioCommand command) { try { command.ProcedureId = procedureId; Scenario scenario = await this._mediator.Send(command); return(Ok(scenario)); } catch (ScenarioManagementDomainException ex) { this._logger.LogError(0, ex, ex.Message); return(BadRequest(new { Reason = ex.Message })); } catch (Exception ex) { this._logger.LogError(0, ex, ex.Message); return(BadRequest()); } }
public void Handle_ValidCommand_PublishesEventWithCorrectData() { Procedure procedure = new Procedure("Test Procedure"); CreateScenarioCommand command = new CreateScenarioCommand { Name = "Test", ProcedureId = procedure.Id }; this._repositoryMock .Setup(r => r.Get(command.ProcedureId)) .Returns(Task.FromResult(procedure)); this._repositoryMock .Setup(r => r.Update(It.IsAny <Procedure>())) .Returns(Task.CompletedTask); CreateScenarioCommandHandler handler = this.CreateHandler(); Scenario scenario = handler.Handle(command).Result; this._eventBusMock.Verify(b => b.Publish(It.Is <ScenarioCreatedEvent>(e => e.ProcedureId == procedure.Id && e.Name == command.Name && e.ScenarioId == scenario.Id))); }
public void Handle_ValidCommand_ReturnsSavedScenario() { Procedure procedure = new Procedure("Test Procedure"); Scenario scenario = null; CreateScenarioCommand command = new CreateScenarioCommand { Name = "Test", ProcedureId = procedure.Id }; this._repositoryMock .Setup(r => r.Get(command.ProcedureId)) .Returns(Task.FromResult(procedure)); this._repositoryMock .Setup(r => r.Update(It.IsAny <Procedure>())) .Returns(Task.CompletedTask) .Callback <Procedure>(p => { scenario = p.Scenarios.First(); }); CreateScenarioCommandHandler handler = this.CreateHandler(); Scenario result = handler.Handle(command).Result; Assert.AreEqual(scenario, result); }