public void Create_DataCorrect_DecisionCreated() { var user = UserFaker.Create(); var project = ProjectFaker.Create(); var result = new Browser(new DefaultNancyBootstrapper()) .Post("/api/v1/entity/decision/create", with => { with.HttpRequest(); with.Query("api_token", Jwt.FromUserId(user.id)); with.Query("entity_guid", project.guid); with.Query("entity_type", EntityType.Project.ToString()); with.Query("title", "test title"); with.Query("content", "test content here and longer than 10 characters"); with.Query("deadline", DateTime.Now.AddDays(2).ToString(CultureInfo.InvariantCulture)); with.Query("options", "['option a', 'option b']"); }).Result; var body = JObject.Parse(result.Body.AsString()); Assert.AreEqual(HttpStatusCode.Created, result.StatusCode); Assert.IsNotEmpty(body["data"]["decision"].ToString()); var decision = EntityDecisionRepository.FindByGuid(body["data"]["decision"].Value <string>("guid")); Assert.NotNull(decision); Assert.AreEqual(user.id, decision.creator_id); Assert.AreEqual(project.id, decision.entity_id); Assert.AreEqual(2, decision.Options().Length); }
public void Create_DataCorrect_BoardCreated() { var creator = UserFaker.Create(); var project = ProjectFaker.Create(creator); var browser = new Browser(new DefaultNancyBootstrapper()); var boardTitle = "testBoard" + Rand.SmallInt(); var boardDescription = "testDescription" + Rand.SmallInt(); var result = browser.Post("/api/v1/board/create", with => { with.HttpRequest(); with.Query("api_token", Jwt.FromUserId(creator.id)); with.Query("name", boardTitle); with.Query("description", boardDescription); with.Query("creator_guid", creator.guid); with.Query("project_guid", project.guid); }).Result; Assert.AreEqual(HttpStatusCode.Created, result.StatusCode); var json = JObject.Parse(result.Body.AsString()); var guid = json["data"]["board"].Value<string>("guid") ?? ""; var createdBoard = BoardRepository.FindByGuid(guid); Assert.NotNull(createdBoard); Assert.AreEqual(boardTitle, createdBoard.name); Assert.AreEqual(boardDescription, createdBoard.description); Assert.AreEqual( createdBoard.guid, json["data"]["board"].Value<string>("guid") ?? "" ); }
public void UpdateStatus_DataCorrect_DecisionClosed() { var user = UserFaker.Create(); var project = ProjectFaker.Create(user); var title = "test title"; var content = "test content"; EntityDecisionRepository.Create( user, project.id, EntityType.Project, title, content, DateTime.Now ); var decision = EntityDecisionRepository.Create( user, project.id, EntityType.Project, title, content, DateTime.Now ); Assert.AreEqual(DecisionStatus.Open, decision.status); var result = EntityDecisionRepository.UpdateStatus(decision, DecisionStatus.Closed); Assert.True(result); decision = decision.Refresh(); Assert.AreEqual(DecisionStatus.Closed, decision.status); }
public void Create_DataCorrect_InvoiceCreated() { var user = UserFaker.Create(); var project = ProjectFaker.Create(); var amount = Rand.SmallDecimal(); CurrencyWalletFaker.Create(CurrencyType.BitCoin); var result = new Browser(new DefaultNancyBootstrapper()) .Post("/api/v1/invoice/new", with => { with.HttpRequest(); with.Query("api_token", Jwt.FromUserId(user.id)); with.Query("entity_guid", project.guid); with.Query("entity_type", EntityType.Project.ToString()); with.Query("amount", amount.ToString(CultureInfo.InvariantCulture)); with.Query("currency_type", CurrencyType.BitCoin.ToString()); }).Result; Assert.AreEqual(1, global::App.DL.Model.Funding.Invoice.GetActiveForUser(user).Length); Assert.AreEqual(HttpStatusCode.Created, result.StatusCode); var jsonData = JObject.Parse(result.Body.AsString())["data"]["invoice"]; Assert.AreEqual(project.guid, jsonData.Value <string>("entity_guid") ?? ""); Assert.AreEqual(amount, jsonData.Value <decimal?>("amount") ?? 0); }
public void IsEntityExists_ProjectExists_Ok() { var project = ProjectFaker.Create(); Assert.True(EntityUtils.IsEntityExists(project.id, EntityType.Project)); Assert.True(EntityUtils.IsEntityExists(project.guid, EntityType.Project)); }
public static ProjectTeamMemberModel Create(ProjectModel project = null, UserModel user = null) { user = user ?? UserFaker.Create(); project = project ?? ProjectFaker.Create(); return(ProjectTeamMemberRepository.CreateAndGet( project, user )); }
public static BoardModel Create(UserModel user = null) { user = user ?? UserFaker.Create(); return(BoardRepository.CreateAndGet( "boardName_" + Rand.SmallInt(), "description" + Rand.SmallInt(), ProjectFaker.Create(user), user )); }
public void Create_DataCorrect_GotAlias() { var project = ProjectFaker.Create(); var alias = ProjectAliasRepository.Create(project); Assert.NotNull(alias); Assert.AreEqual(project.id, alias.project_id); }
public void HasEntityPermission_Project_HasPermission() { var user = UserFaker.Create(); var project = ProjectFaker.Create(); Assert.False(PermissionUtils.HasEntityPermission(user, project.id, EntityType.Project)); ProjectTeamMemberFaker.Create(project, user); Assert.True(PermissionUtils.HasEntityPermission(user, project.id, EntityType.Project)); }
public void Find_DataCorrect() { var user = UserFaker.Create(); var project = ProjectFaker.Create(); ProjectTeamMemberRepository.CreateAndGet(project, user); var teamMember = ProjectTeamMemberRepository.FindByProjectAndUser(project.guid, user.guid); Assert.AreEqual(teamMember.project_id, project.id); Assert.AreEqual(teamMember.user_id, user.id); }
public void Create_WithoutInvoice_TransactionCreated() { var user = UserFaker.Create(); var project = ProjectFaker.Create(user); var tx = FundingTransactionRepository.Create( user, project.id, EntityType.Project, null, 0.05M, CurrencyType.BitCoin ); Assert.True(tx.id > 0); }
public void Create_DataCorrect_GotTransaction() { var user = UserFaker.Create(); var project = ProjectFaker.Create(user); var invoice = InvoiceFaker.Create(user, project.id); var tx = FundingTransactionRepository.Create( user, project.id, EntityType.Project, invoice, 0.05M, CurrencyType.BitCoin ); Assert.True(tx.id > 0); }
public static Invoice Create( UserModel user = null, int?entityId = null, EntityType entityType = EntityType.Project, CurrencyType currencyType = CurrencyType.BitCoin, InvoiceStatus status = InvoiceStatus.Created ) { return(InvoiceRepository.Create( user ?? UserFaker.Create(), entityId ?? ProjectFaker.Create().id, entityType, 0.001M * Rand.SmallInt(), currencyType, status, CurrencyWalletFaker.Create(currencyType) )); }
public void GetActive_DataCorrect_GotDecisions() { var user = UserFaker.Create(); var project = ProjectFaker.Create(user); var title = "test title"; var content = "test content"; EntityDecisionRepository.Create( user, project.id, EntityType.Project, title, content, DateTime.Now ); var decisions = EntityDecisionRepository.GetActive(project.id, EntityType.Project); Assert.AreEqual(1, decisions.Length); }
public void Get_DataCorrect_GotProject() { var browser = new Browser(new DefaultNancyBootstrapper()); var project = ProjectFaker.Create(); var result = browser.Get("/api/v1/project/get", with => { with.HttpRequest(); with.Query("project_guid", project.guid); }).Result; Assert.AreEqual(HttpStatusCode.OK, result.StatusCode); var json = JObject.Parse(result.Body.AsString()); Assert.AreEqual(project.guid, json["data"]["project"].Value <string>("guid")); }
public void Create_DataCorrect_DecisionCreated() { var user = UserFaker.Create(); var project = ProjectFaker.Create(user); var title = "test title"; var content = "test content"; var decision = EntityDecisionRepository.Create( user, project.id, EntityType.Project, title, content, DateTime.Now ); Assert.NotNull(decision); Assert.AreEqual(title, decision.title); Assert.AreEqual(content, decision.content); }
public void FundEntity_DataCorrect_EntityFundedTxCreated() { var user = UserFaker.Create(); var project = ProjectFaker.Create(); var amount = Rand.SmallDecimal(); var balance = SubscriptionFundingUtils.FundEntity(user, project.id, EntityType.Project, amount, CurrencyType.BitCoin); Assert.AreEqual(amount, balance.balance); var txs = FundingTransactionRepository.Get(project.id, EntityType.Project, CurrencyType.BitCoin); Assert.AreEqual(1, txs.Length); Assert.AreEqual(amount, txs[0].amount); }
public void Create_DataCorrect_ProjectTeamMemberCreated() { var user = UserFaker.Create(); var project = ProjectFaker.Create(user); var browser = new Browser(new DefaultNancyBootstrapper()); var result = browser.Post("/api/v1/project_team_member/create", with => { with.HttpRequest(); with.Query("api_token", Jwt.FromUserId(user.id)); with.Query("project_guid", project.guid); with.Query("user_guid", user.guid); }).Result; Assert.AreEqual(HttpStatusCode.Created, result.StatusCode); var createdTeamMember = ProjectTeamMemberRepository.Find(project, user); Assert.NotNull(createdTeamMember); Assert.AreEqual(project.id, createdTeamMember.project_id); Assert.AreEqual(user.id, createdTeamMember.user_id); }
public void Patch_DataCorrect_ProjectUpdated() { var browser = new Browser(new DefaultNancyBootstrapper()); var project = ProjectFaker.Create(); var updatedDescription = "updatedDescription_" + Rand.SmallInt(); var result = browser.Patch("/api/v1/project/edit", with => { with.HttpRequest(); with.Query("api_token", Jwt.FromUserId(UserFaker.Create().id)); with.Query("project_guid", project.guid); with.Query("description", updatedDescription); }).Result; Assert.AreEqual(HttpStatusCode.OK, result.StatusCode); var json = JObject.Parse(result.Body.AsString()); Assert.AreEqual(project.guid, json["data"]["project"].Value <string>("guid")); Assert.AreEqual(updatedDescription, json["data"]["project"].Value <string>("description")); }
public static DecisionModel Create(UserModel user = null, int entityId = 0, EntityType type = EntityType.Project) { if (user == null) { user = UserFaker.Create(); } if (entityId == 0 && type == EntityType.Project) { var project = ProjectFaker.Create(); entityId = project.id; } return(EntityDecisionRepository.Create( user, entityId, type, "test title", "test content", DateTime.Now.AddDays(1) )); }
public void FundEntity_DataCorrect_EntityFunded() { var user = UserFaker.Create(); var amount = Rand.SmallDecimal(); var balance = UserBalanceRepository.FindOrCreate(user, CurrencyType.BitCoin); balance.UpdateBalance(amount); var info = UserSubscriptionInfoRepository.FindOrCreate(user); info.UpdateSelectedAmount(amount).Refresh(); ProjectFaker.Create(); SubscriptionUtils.PeriodPay(user); var txs = FundingTransactionRepository.Get(user); Assert.True(txs.Length > 0); Assert.True(txs[0].amount > 0); }