public void Execute_Returns_Created_Company() { // Setup InitializeTestEntities(); // Act Company result = new CreateCompanyCommand(_serviceFactory.Object).WithJobSearch(_search.Id) .SetName("Name") .SetPhone("555-555-5555") .SetCity("City") .SetState("State") .SetZip("01234") .SetMetroArea("Metro") .SetIndustry("Industry") .SetNotes("Notes") .CalledByUserId(_user.Id) .Execute(); // Verify Assert.IsNotNull(result, "Returned company entity was null"); Assert.AreEqual("Name", result.Name, "The created company's name was incorrect"); Assert.AreEqual("555-555-5555", result.Phone, "The created company's phone number was incorrect"); Assert.AreEqual("City", result.City, "The created company's city was incorrect"); Assert.AreEqual("State", result.State, "The created company's state was incorrect"); Assert.AreEqual("01234", result.Zip, "The created company's zip was incorrect"); Assert.AreEqual("Metro", result.MetroArea, "The created company's metro area was incorrect"); Assert.AreEqual("Notes", result.Notes, "The created company's notes were incorrect"); Assert.AreEqual(_search, result.JobSearch, "The created company was associated with the incorrect job search"); }
public async Task <CompanyViewModel> Create() { var name = "Company 0001"; var command = new CreateCompanyCommand(name); return(await Create(command)); }
public CreateCompanyService(CreateCompanyCommand companyCommand, ICompanyRepository companyRepository) : base(companyCommand) { _companyRepository = companyRepository; _companyCommand = companyCommand; Run(); }
public async Task <CompanyViewModel> Create(CreateCompanyCommand command) { //send command to broker var result = await producer.Send <CreateCompanyCommand, Company>(command); return(mapper.Map <CompanyViewModel>(result)); }
public void Init() { _verifyTokenMock = new Mock <IProcess <VerifyUserLinkedInAccessTokenParams, UserAccessTokenResultViewModel> >(); _verifyTokenMock.Setup(x => x.Execute(It.IsAny <VerifyUserLinkedInAccessTokenParams>())).Returns(new UserAccessTokenResultViewModel { AccessTokenValid = true }); _createPositionMock = new Mock <IProcess <CreatePositionParams, PositionDisplayViewModel> >(); var createCompanyCmd = new CreateCompanyCommand(_serviceFactory.Object); _process = new LinkedInPositionSearchProcesses(_context, _verifyTokenMock.Object, createCompanyCmd, _createPositionMock.Object, null); // Initialize user with test (but valid) access token data _user = new User(); var oauth = new OAuthData { Token = "bfcf3fe4-b4d4-4f37-9d32-292ae9d45347", Secret = "f66673b2-5877-4fbf-80e0-3826ca9f7eed", TokenProvider = TokenProvider.LinkedIn, TokenType = TokenType.AccessToken, }; oauth.LinkedInUsers.Add(_user); _user.LinkedInOAuthData = oauth; _context.Users.Add(_user); _context.OAuthData.Add(oauth); _context.SaveChanges(); }
public Company Create(CreateCompanyCommand command) { var company = new Company { Name = command.Name, VATNumber = command.VATNumber, Addresses = new List <CompanyAddresses> { new CompanyAddresses { CompanyAddressType = CompanyAddressType.Headquarter, Address = new Address { Street = command.Street, Number = command.Number, Postcode = command.Postcode } } } }; _contactsContext.Companies.Add(company); _contactsContext.SaveChanges(); return(company); }
public async Task <Company> Create() { var name = "Company Test"; var command = new CreateCompanyCommand(name); return(await Create(command)); }
public async Task <CompanyViewModel> Create(CreateCompanyCommand command) { var response = await controller.Create(command) as CreatedResult; var viewmodel = response.Value as CompanyViewModel; return(viewmodel); }
/// <summary> /// Construtor da classe Company /// </summary> /// <param name="command">Comando de criação de uma Company</param> public Company(CreateCompanyCommand command) { this.CompanyId = Guid.NewGuid(); this.Name = command.Name; this.CreatedOn = command.CreatedOn; this.ModifiedOn = command.ModifiedOn; this.CompanyStatus = command.CompanyStatus; }
public async Task <IActionResult> PostAsync() { var command = new CreateCompanyCommand() { CompanyId = 1, Name = "AAAA", Email = "*****@*****.**", Logo = new byte[] { } }; var k = _mediator.Send(command); return(Ok(k)); }
public JigsawCompanySearchProcesses(MyJobLeadsDbContext context, CompanyByIdQuery companyQuery, CreateCompanyCommand createCompanyCmd, EditCompanyCommand editCompanyCmd) { _context = context; _companyByIdQuery = companyQuery; _createCompanyCmd = createCompanyCmd; _editCompanyCmd = editCompanyCmd; }
public static Company ToCompany(this CreateCompanyCommand command) { if (command == null) { return(null); } return(new Company() { Name = command.Name }); }
public void Execute_Initializes_Contact_List() { // Setup InitializeTestEntities(); // Act Company result = new CreateCompanyCommand(_serviceFactory.Object).WithJobSearch(_search.Id).CalledByUserId(_user.Id).Execute(); // Verify Assert.IsNotNull(result.Contacts, "Company's contact list was null"); }
public LinkedInPositionSearchProcesses(MyJobLeadsDbContext context, IProcess <VerifyUserLinkedInAccessTokenParams, UserAccessTokenResultViewModel> verifyLiTokenProcess, CreateCompanyCommand createCompanyCmd, IProcess <CreatePositionParams, PositionDisplayViewModel> createPositionProcess, CompanyByIdQuery companyQuery) { _context = context; _verifyLiTokenProcess = verifyLiTokenProcess; _createCompanyCmd = createCompanyCmd; _createPositionProcess = createPositionProcess; _companyQuery = companyQuery; }
public JigsawContactSearchProcesses(MyJobLeadsDbContext context, IProcess <GetUserJigsawCredentialsParams, JigsawCredentialsViewModel> getJsCredProc, CreateCompanyCommand createCompanyCmd, CompanyByIdQuery compByIdQuery, CreateContactCommand createContactcmd) { _context = context; _getJigsawCredentialsProc = getJsCredProc; _createCompanyCmd = createCompanyCmd; _companyByIdQuery = compByIdQuery; _createContactCmd = createContactcmd; }
public virtual ActionResult Edit(EditCompanyViewModel model) { Company company; try { // Determine if this is a new company or not if (model.Id == 0) { company = new CreateCompanyCommand(_serviceFactory).WithJobSearch(model.JobSearchId) .SetName(model.Name) .SetCity(model.City) .SetIndustry(model.Industry) .SetMetroArea(model.MetroArea) .SetNotes(model.Notes) .SetPhone(model.Phone) .SetState(model.State) .SetZip(model.Zip) .SetWebsite(model.Website) .CalledByUserId(CurrentUserId) .Execute(); } else { company = new EditCompanyCommand(_serviceFactory).WithCompanyId(model.Id) .SetName(model.Name) .SetCity(model.City) .SetIndustry(model.Industry) .SetMetroArea(model.MetroArea) .SetNotes(model.Notes) .SetPhone(model.Phone) .SetState(model.State) .SetZip(model.Zip) .SetLeadStatus(model.LeadStatus) .SetWebsite(model.Website) .RequestedByUserId(CurrentUserId) .Execute(); } return(RedirectToAction(MVC.Company.Details(company.Id))); } catch (ValidationException ex) { foreach (var error in ex.Errors) { ModelState.AddModelError(error.PropertyName, error.ErrorMessage); } model.AvailableLeadStatuses = _serviceFactory.GetService <LeadStatusesAvailableForCompaniesQuery>().Execute(); return(View(model)); } }
public void Command_Updates_JobSearch_Metrics() { // Setup InitializeTestEntities(); // Act Company company = new CreateCompanyCommand(_serviceFactory.Object).WithJobSearch(_search.Id) .CalledByUserId(_user.Id) .Execute(); // Verify _updateMetricsCmd.Verify(x => x.Execute(It.Is <UpdateJobSearchMetricsCmdParams>(y => y.JobSearchId == _search.Id)), Times.Once()); }
public void Execute_Indexes_New_Company() { // Setup InitializeTestEntities(); // Act Company company = new CreateCompanyCommand(_serviceFactory.Object).WithJobSearch(_search.Id) .CalledByUserId(_user.Id) .Execute(); // Verify _searchProvider.Verify(x => x.Index(company), Times.Once()); }
public void Should_Have_Error_When_Name_Is_Invalid_Format() { //Arrange var command = new CreateCompanyCommand() { Name = "Test/" }; //Act var result = _validator.TestValidate(command); //Assert result.ShouldHaveValidationErrorFor(x => x.Name); }
public void Should_Have_Error_When_Name_Is_Already_Exists() { //Arrange var command = new CreateCompanyCommand() { Name = "CompanyName1" }; //Act var result = _validator.TestValidate(command); //Assert result.ShouldHaveValidationErrorFor(x => x.Name); }
public void Should_Have_Error_When_Name_Is_Greater_Than_30_Characters() { //Arrange var command = new CreateCompanyCommand() { Name = new string('T', 31) }; //Act var result = _validator.TestValidate(command); //Assert result.ShouldHaveValidationErrorFor(x => x.Name); }
public Company Create(CreateCompanyCommand command) { var company = new Company(command.CompanyName, command.FantasyName, command.StateInscription, command.Cnpj, command.Email, command.ClassificationCompany, command.SizeCompany, command.ListAddressCompany, command.ListPhonesCompany); company.Register(); _repository.Create(company); if (Commit()) { return(company); } return(null); }
public async Task <CompanyViewModel> Create(CreateCompanyCommand command) { //arrange const int expectedNumberOfErrors = 0; //act var response = await appService.Create(command); //assert command.ValidateModelAnnotations().Count.Should().Be(expectedNumberOfErrors); response.Id.Should().NotBe(Guid.Empty); response.Name.Should().Be(command.Name); return(response); }
/// <summary> /// Método para realizar a criação de uma Company fazendo as verificações de escopo /// </summary> /// <param name="command">Comando de criação de Company</param> /// <returns>Retorna a Company criada ou null caso haja notificações no domínio</returns> public Company Create(CreateCompanyCommand command) { var company = new Company(command); company.CreateCompany(company); _repository.Create(company); if (Commit()) { return(company); } return(null); }
public async Task Handle_ValidCompany_ReturnsSpecyficType() { //Arrange var handler = new CreateCompanyCommandHandler(_mockCompanyRepository.Object, _mapper, _logger.Object, _mockUriService.Object); var command = new CreateCompanyCommand() { Name = "New Company", }; //Act var result = await handler.Handle(command, CancellationToken.None); //Assert result.ShouldBeOfType <CreateCompanyCommandResponse>(); }
public async Task <CoreResult> Create([FromBody] CreateCompanyRequestDto dto) { CoreResult result = new CoreResult(); CreateCompanyCommand command = new CreateCompanyCommand(dto.Name, dto.SkuPrefix, dto.AdditionalFee); var res = await _bus.SendCommandAsync(command); if (res) { result.Success("添加成功"); } else { result.Failed("添加失败"); } return(result); }
public async Task <bool> Handle(SeedCommand request, CancellationToken cancellationToken) { Consoler.TitleStart("seed database start"); var companies = CompanySpreadsheet.Import(); //var chance = new ChanceNET.Chance(); //var companies = new List<Company> {chance.Object<Company>()}; var bus = IocContainer.Container.Resolve <ICommandBus>(); /* * * DRGD - De-registered. * EXAD - External administration (in receivership/liquidation). * NOAC - Not active. * NRGD - Not registered. * PROV - Provisional (mentioned only under charges and refers * to those which have not been fully registered). * REGD – Registered. * SOFF - Strike-off action in progress. * DISS - Dissolved by Special Act of Parliament. * DIV3 - Organisation Transferred Registration via DIV3. * PEND - Pending - Schemes. * */ foreach (var company in companies)//.Where(x=>x.Status =="REGD")) { var command = new CreateCompanyCommand(CompanyId.New) { Company = company }; try { AsyncUtil.RunSync(() => bus.PublishAsync(command, cancellationToken)); await Task.CompletedTask; } catch (Exception e) { Console.WriteLine(e); throw; } } Consoler.TitleEnd("seed database finished"); return(true); }
public void TestCompanyCreation() { using (var uow = container.Resolve <IAppUnitOfWork>()) { var query = new CompanyQueries(uow); var count1 = query.GetAll().Count(); var command = new CreateCompanyCommand(); command.CreatedByUserId = GlobalConfig.AdminId; command.Name = "Test Company " + DateTime.Now.Ticks; pipelineService.HandleCommand(command); var count2 = query.GetAll().Count(); Assert.AreEqual(count1 + 1, count2, "number of companies"); } }
public async Task <CompanyExecutionResult> CreateCompanyAsync(CreateCompanyCommand command) { if (!IsNew) { throw DomainError.With("company exists"); } Emit(new CompanyCreatedEvent() { Company = command.Company }); return(await Task.FromResult(new CompanyExecutionResult() { IsSuccess = true })); }
public async Task Create_InvalidModel_ReturnsBadRequestStatus() { //Arrange var command = new CreateCompanyCommand() { Name = "NewCompany/" }; var json = JsonConvert.SerializeObject(command); var httpContent = new StringContent(json, Encoding.UTF8, JSON_CONTENT_TYPE); //Act var response = await _client.PostAsync(ApiRoutes.CompanyRoute.Create, httpContent); //Assert response.StatusCode.Should().Be(HttpStatusCode.BadRequest); }
public void Run() { IExecutable command = null; string line = Console.ReadLine(); while (line != "end") { string[] tokens = line.Split(); switch (tokens[0]) { case "create-company": command = new CreateCompanyCommand(db, tokens[1], tokens[2], tokens[3], decimal.Parse(tokens[4])); break; case "create-employee": string departmentName = null; if (tokens.Length > 5) { departmentName = tokens[5]; } command = new CreateEmployeeCommand(db, tokens[1], tokens[2], tokens[3], tokens[4], departmentName); break; case "create-department": string mainDepartmentName = null; if (tokens.Length > 5) { mainDepartmentName = tokens[5]; } command = new CreateDepartmentCommand(db, tokens[1], tokens[2], tokens[3], tokens[4], mainDepartmentName); break; case "pay-salaries": command = new PaySalariesCommand(tokens[1], db); break; case "show-employees": command = new ShowEmployeesCommand(tokens[1], db); break; } try { Console.Write(command.Execute()); } catch (Exception e) { Console.WriteLine(e.Message); } finally { line = Console.ReadLine(); } } }