public void CreateEnterpriseTest() { var model = new EnterpriseModel(context); var enterprise = model.CreateEnterprise("Fantasia", "123456000132"); Assert.True(enterprise.Id != 0, "Falha ao inserir uma nova empresa"); }
public void CannotCreateEnterpriseWithoutCNPJTest() { var model = new EnterpriseModel(context); Assert.Throws <BusinessException>(() => { model.CreateEnterprise("teste", ""); }); Assert.Throws <BusinessException>(() => { model.CreateEnterprise("teste", " "); }); Assert.Throws <BusinessException>(() => { model.CreateEnterprise("teste", null); }); }
public void CannotCreateEnterpriseWithoutNameTest() { var model = new EnterpriseModel(context); Assert.Throws <BusinessException>(() => { model.CreateEnterprise("", "123123213213"); }); Assert.Throws <BusinessException>(() => { model.CreateEnterprise(" ", "123123213213"); }); Assert.Throws <BusinessException>(() => { model.CreateEnterprise(null, "123123213213"); }); }
public string Post() { var content = Body; var account = JsonConvert.DeserializeObject <AccountTO>(content); try { var person = personModel.CreatePerson(account.Name, account.LastName, account.CPF, account.Email, account.Phone); enterpriseModel.CreateEnterprise(account.Enterprise.Name, account.Enterprise.Cnpj); userModel.CreateUser(person.Id, account.User.Username, account.User.Password); return(JsonConvert.SerializeObject(new ResponseTO() { Code = 200, Message = "Conta cadastrada com sucesso.", Data = person.Id })); } catch (BusinessException be) { return(JsonConvert.SerializeObject(new ResponseTO() { Code = 500, Message = be.Message })); } catch (ArgumentException ae) { return(JsonConvert.SerializeObject(new ResponseTO() { Code = 500, Message = ae.Message })); } catch (Exception) { return(JsonConvert.SerializeObject(new ResponseTO() { Code = 500, Message = "Erro desconhecido. Tente novamente mais tarde." })); } }