public async Task GivenNoContractInDb_WhenAddInvalidContract_ThenReturnBadRequest() { Contract newContract = new Contract { FirstContractorId = "", SecondContractorId = "" }; ActionResult response = await controller.AddContract(newContract); Assert.IsInstanceOfType(response, typeof(BadRequestObjectResult)); }
public async Task FinalizeContractNotAdmin() { var context = new POAMDbContext(); RemoveContract(context, "dummyContract"); var contract = GenerateContract(); RemoveAdmin(context); Authentication.Instance.AdminLogin(CreateAdmin(context)); var contractController = new ContractController(context); await contractController.AddContract(contract); Authentication.Instance.Logout(); RemoveAdmin(context); var result = await contractController.FinalizeContract(contract.IdContract); var existingContract = context.Contract.FirstOrDefault(c => c.Provider == "dummyContract"); Assert.NotNull(existingContract); var redirectResult = Assert.IsType <RedirectResult>(result); Assert.NotNull(redirectResult); Assert.Equal("~/MainPage", redirectResult.Url); }
public async Task AddContractSuccessful() { var context = new POAMDbContext(); RemoveContract(context, "dummyContract"); var contract = GenerateContract(); RemoveAdmin(context); Authentication.Instance.AdminLogin(CreateAdmin(context)); var contractController = new ContractController(context); var result = await contractController.AddContract(contract); var existingContract = context.Contract.FirstOrDefault(c => c.Provider == "dummyContract"); Assert.NotNull(existingContract); var redirectResult = Assert.IsType <RedirectToActionResult>(result); Assert.NotNull(redirectResult); Assert.Equal("ContractsList", redirectResult.ActionName); Authentication.Instance.Logout(); RemoveContract(context, "dummyContract"); RemoveAdmin(context); }
private void btn_send_to_database_Click(object sender, EventArgs e) { if (id != 0) { ContractController.UpdateContract(id, CompanyController.getByName(cbox_companies.Text), PatentController.getByNumber(cbox_patents.Text), dtime_deposit_date.Value, (int)nbox_duration.Value, Convert.ToDouble(tbox_price.Text)); MessageBox.Show("Le contrat a été correctement mise à jour dans la base de données", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { ContractController.AddContract(CompanyController.getByName(cbox_companies.Text), PatentController.getByNumber(cbox_patents.Text), dtime_deposit_date.Value, (int)nbox_duration.Value, Convert.ToDouble(tbox_price.Text.Replace('.', ','))); MessageBox.Show("Le contrat a été correctement ajoutée à la base de données", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } uc_MainContract.Instance.ReloadPanel(); this.SendToBack(); }
public Task <IHttpActionResult> AddContractTest( [PexAssumeUnderTest] ContractController target, Guid contextId, string token1, string token2, string fileChecksum, string contextHash ) { Task <IHttpActionResult> result = target.AddContract(contextId, token1, token2, fileChecksum, contextHash); Assert.IsNull(token1); Assert.IsNull(token2); Assert.IsNull(contextHash); Assert.IsNull(fileChecksum); return(result); }
public async Task TestCreateContract() { Contract contract = new Contract() { Id = new Guid(), Client = new Client(), Abonament = new Abonament() }; contract.Client.CodNumericPersonal = "1960914080014"; this.plataRepositoryMock.Setup(t => t.Get( It.IsAny <Expression <Func <Plata, bool> > >(), It.IsAny <Func <IQueryable <Plata>, IOrderedQueryable <Plata> > >(), It.IsAny <string>())).ReturnsAsync(new List <Plata>()); //this.clientControllerMock.Setup(t => t.CheckClientPaymentsOnTime(It.IsAny<Client>())).ReturnsAsync(true); this.contractRepository.Setup(t => t.Insert(It.IsAny <Contract>())).Verifiable(); await controller.AddContract(contract); this.contractRepository.VerifyAll(); }