public void Patch_DataCorrect_BoardUpdated() {
            var browser = new Browser(new DefaultNancyBootstrapper());
            
            var me = UserFaker.Create();
            var board = BoardFaker.Create(me);

            var updatedName = "updatedName_" + Rand.SmallInt();
            var updatedDescription = "updatedDescription_" + Rand.SmallInt();

            var result = browser.Patch("/api/v1/board/edit", with => {
                with.HttpRequest();
                with.Query("api_token", Jwt.FromUserId(me.id));
                with.Query("board_guid", board.guid);
                with.Query("name", updatedName);
                with.Query("description", updatedDescription);
            }).Result;
            
            Assert.AreEqual(HttpStatusCode.OK, result.StatusCode);
            
            var json = JObject.Parse(result.Body.AsString());
            
            Assert.AreEqual(board.guid, json["data"]["board"].Value<string>("guid"));
            Assert.AreEqual(updatedName, json["data"]["board"].Value<string>("name"));
            Assert.AreEqual(updatedDescription, json["data"]["board"].Value<string>("description"));
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }
예제 #5
0
        public void Edit_DataCorrect_StatusUpdated()
        {
            var user     = UserFaker.Create();
            var decision = EntityDecisionFaker.Create(user);

            Assert.AreEqual(DecisionStatus.Open, decision.status);
            Assert.NotNull(decision);

            var result = new Browser(new DefaultNancyBootstrapper())
                         .Patch("/api/v1/entity/decision/edit", with => {
                with.HttpRequest();
                with.Query("api_token", Jwt.FromUserId(user.id));
                with.Query("decision_guid", decision.guid);
                with.Query("new_status", DecisionStatus.Canceled.ToString());
            }).Result;

            var body = JObject.Parse(result.Body.AsString());

            Assert.AreEqual(HttpStatusCode.OK, result.StatusCode);

            Assert.IsNotEmpty(body["data"]["decision"].ToString());

            decision = decision.Refresh();

            Assert.AreEqual(DecisionStatus.Canceled, decision.status);
        }
예제 #6
0
        public void Create_DataCorrect_RepoCreated()
        {
            var user    = UserFaker.Create();
            var browser = new Browser(new DefaultNancyBootstrapper());

            var repoTitle = "testRepo" + Rand.SmallInt();

            var result = browser.Post("/api/v1/repository/create", with => {
                with.HttpRequest();
                with.Query("api_token", Jwt.FromUserId(user.id));
                with.Query("title", repoTitle);
                with.Query("repo_url", "randomUrl" + Rand.SmallInt());
                with.Query("service_type", RepoServiceType.GitHub.ToString());
            }).Result;

            Assert.AreEqual(HttpStatusCode.Created, result.StatusCode);

            var json = JObject.Parse(result.Body.AsString());

            var guid = json["data"]["repository"].Value <string>("guid") ?? "";

            var createdRepository = RepoRepository.FindByGuid(guid);

            Assert.NotNull(createdRepository);
            Assert.AreEqual(repoTitle, createdRepository.title);
            Assert.AreEqual(
                user.guid, json["data"]["repository"]["creator"].Value <string>("guid") ?? ""
                );
        }
예제 #7
0
        public void Patch_DataCorrect_RepositoryUpdated()
        {
            var browser = new Browser(new DefaultNancyBootstrapper());

            var repo = RepoFaker.Create();

            var updatedTitle   = "updatedTitle_" + Rand.SmallInt();
            var updatedRepoUrl = "https://github.com/someuser/repo_" + Rand.SmallInt();

            var result = browser.Patch("/api/v1/repository/edit", with => {
                with.HttpRequest();
                with.Query("api_token", Jwt.FromUserId(UserFaker.Create().id));
                with.Query("repo_guid", repo.guid);
                with.Query("title", updatedTitle);
                with.Query("repo_url", updatedRepoUrl);
            }).Result;

            Assert.AreEqual(HttpStatusCode.OK, result.StatusCode);

            var json = JObject.Parse(result.Body.AsString());

            Assert.AreEqual(repo.guid, json["data"]["repository"].Value <string>("guid"));
            Assert.AreEqual(updatedTitle, json["data"]["repository"].Value <string>("title"));
            Assert.AreEqual(updatedRepoUrl, json["data"]["repository"].Value <string>("repo_url"));
        }
        public void Create_DataCorrect_CardCreated()
        {
            var user    = UserFaker.Create();
            var column  = BoardColumnFaker.Create(user);
            var browser = new Browser(new DefaultNancyBootstrapper());

            var cardTitle   = "testCard" + Rand.SmallInt();
            var description = "descriptionCard" + Rand.SmallInt();
            var columnOrder = Convert.ToString(Rand.IntRange(1, 25));

            var result = browser.Post("/api/v1/card/create", with => {
                with.HttpRequest();
                with.Query("api_token", Jwt.FromUserId(user.id));
                with.Query("name", cardTitle);
                with.Query("description", description);
                with.Query("column_guid", column.guid);
                with.Query("column_order", columnOrder);
                with.Query("creator_guid", user.guid);
            }).Result;

            Assert.AreEqual(HttpStatusCode.Created, result.StatusCode);

            var json = JObject.Parse(result.Body.AsString());

            var guid = json["data"]["card"].Value <string>("guid") ?? "";

            var createdCard = CardRepository.FindByGuid(guid);

            Assert.NotNull(createdCard);
            Assert.AreEqual(cardTitle, createdCard.name);
            Assert.AreEqual(columnOrder, Convert.ToString(createdCard.column_order));
            Assert.AreEqual(
                createdCard.guid, json["data"]["card"].Value <string>("guid") ?? ""
                );
        }
        public void Patch_DataCorrect_BoardUpdated()
        {
            var browser = new Browser(new DefaultNancyBootstrapper());

            var me          = UserFaker.Create();
            var boardColumn = BoardColumnFaker.Create(me);

            var updatedName       = "updatedName_" + Rand.SmallInt();
            var updatedBoardOrder = Convert.ToString(Rand.IntRange(0, 40));

            var result = browser.Patch("/api/v1/board_column/edit", with => {
                with.HttpRequest();
                with.Query("api_token", Jwt.FromUserId(me.id));
                with.Query("board_column_guid", boardColumn.guid);
                with.Query("name", updatedName);
                with.Query("board_order", updatedBoardOrder);
            }).Result;

            Assert.AreEqual(HttpStatusCode.OK, result.StatusCode);

            var json = JObject.Parse(result.Body.AsString());

            Assert.AreEqual(boardColumn.guid, json["data"]["board_column"].Value <string>("guid"));
            Assert.AreEqual(updatedName, json["data"]["board_column"].Value <string>("name"));
            Assert.AreEqual(updatedBoardOrder, json["data"]["board_column"].Value <string>("board_order"));
        }
        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 Create_DataCorrect_BoardColumnCreated()
        {
            var user    = UserFaker.Create();
            var board   = BoardFaker.Create(user);
            var browser = new Browser(new DefaultNancyBootstrapper());

            var boardColumnTitle = "testBoard" + Rand.SmallInt();
            var boardOrder       = Convert.ToString(Rand.IntRange(0, 25));

            var result = browser.Post("/api/v1/board_column/create", with => {
                with.HttpRequest();
                with.Query("api_token", Jwt.FromUserId(user.id));
                with.Query("name", boardColumnTitle);
                with.Query("board_guid", board.guid);
                with.Query("board_order", boardOrder);
            }).Result;

            Assert.AreEqual(HttpStatusCode.Created, result.StatusCode);

            var json = JObject.Parse(result.Body.AsString());

            var guid = json["data"]["board_column"].Value <string>("guid") ?? "";

            var createdBoardColumn = BoardColumnRepository.FindByGuid(guid);

            Assert.NotNull(createdBoardColumn);
            Assert.AreEqual(boardColumnTitle, createdBoardColumn.name);
            Assert.AreEqual(boardOrder, Convert.ToString(createdBoardColumn.board_order));
            Assert.AreEqual(
                createdBoardColumn.guid, json["data"]["board_column"].Value <string>("guid") ?? ""
                );
        }
예제 #12
0
        public void FindByEmail_DataCorrect_Ok()
        {
            Assert.AreEqual(0, global::BaseFramework.DL.Model.User.User.Count());
            var user = UserFaker.Create();

            Assert.NotNull(UserRepository.FindByEmail(user.email));
        }
예제 #13
0
        public void SetUp_DataCorrect_WorkTypesCreated()
        {
            var project = ProjectRepository.FindOrCreate(
                "tst project", UserFaker.Create(), RepoFaker.Create()
                );

            Assert.AreEqual(ProjectWorkUtils.GetDefaultWorkTypes().Length, project.WorkTypes().Length);
        }
예제 #14
0
        public void Find_SearchByUserAndServiceType_ItemCreated()
        {
            var user = UserFaker.Create();

            var accessToken = ServiceAccessTokenRepository.FindOrUpdateAccessToken(user, Rand.RandomString(), ServiceType.GitHub);

            Assert.NotNull(accessToken);
        }
예제 #15
0
        public void Create_DataCorrect_BalanceCreated()
        {
            var user    = UserFaker.Create();
            var id      = UserBalance.Create(user, CurrencyType.BitCoin);
            var balance = UserBalance.Find(id);

            Assert.NotNull(balance);
            Assert.AreEqual(user.id, balance.User().id);
        }
예제 #16
0
        public void Store_UserId_WithoutCrashing()
        {
            var user = UserFaker.Create();

            for (int i = 0; i <= 100; i++)
            {
                UserRepository.Find(user.id);
            }
        }
예제 #17
0
 public static RepoModel Create()
 {
     return(RepoRepository.CreateAndGet(
                UserFaker.Create(),
                "randomTitle_" + Rand.SmallInt(),
                "repoUrl_" + Rand.SmallInt(),
                RepoServiceType.GitHub
                ));
 }
예제 #18
0
 public static ProjectTeamMemberModel Create(ProjectModel project = null, UserModel user = null)
 {
     user    = user ?? UserFaker.Create();
     project = project ?? ProjectFaker.Create();
     return(ProjectTeamMemberRepository.CreateAndGet(
                project,
                user
                ));
 }
예제 #19
0
 public static ProjectModel Create(UserModel user = null, RepoModel repository = null)
 {
     user       = user ?? UserFaker.Create();
     repository = repository ?? RepoFaker.Create();
     return(ProjectRepository.FindOrCreate(
                "repoName_" + Rand.SmallInt(),
                user,
                repository
                ));
 }
예제 #20
0
 public static BoardModel Create(UserModel user = null)
 {
     user = user ?? UserFaker.Create();
     return(BoardRepository.CreateAndGet(
                "boardName_" + Rand.SmallInt(),
                "description" + Rand.SmallInt(),
                ProjectFaker.Create(user),
                user
                ));
 }
예제 #21
0
        public void Find_DataCorrect_GotServiceTypeCorrect()
        {
            var user = UserFaker.Create();
            var repo = RepoRepository.CreateAndGet(
                user, "some_title_" + Rand.SmallInt(), "random_url_" + Rand.SmallInt(), RepoServiceType.GitLab
                );

            repo = repo.Refresh();
            Assert.AreEqual(RepoServiceType.GitLab, repo.service_type);
        }
        public void FindOrCreate_DataCorrect_InfoCreated()
        {
            var user = UserFaker.Create();

            Assert.IsNull(UserSubscriptionInfoRepository.Find(user));

            UserSubscriptionInfoRepository.FindOrCreate(user);

            Assert.NotNull(UserSubscriptionInfoRepository.Find(user));
        }
예제 #23
0
        public static BoardColumnModel Create(UserModel user = null)
        {
            user = user ?? UserFaker.Create();
            var board = BoardFaker.Create(user);

            return(BoardColumnRepository.CreateAndGet(
                       "boardColumnName_" + Rand.SmallInt(),
                       board,
                       Convert.ToInt16(Rand.IntRange(0, 20))
                       ));
        }
        public void Create_DataCorrect_ReferralCreated()
        {
            var user     = UserFaker.Create();
            var referral = UserFaker.Create();

            UserReferralRepository.Create(user, referral);

            var invitedUsers = UserReferralRepository.GetInvited(referral);

            Assert.AreEqual(invitedUsers[0].referral_id, referral.id);
        }
 public static FundingTransaction Create(int entityId = 0, EntityType entityType = EntityType.Project)
 {
     return(FundingTransactionRepository.Create(
                UserFaker.Create(),
                entityId == 0 ? Rand.Int() : entityId,
                entityType,
                InvoiceFaker.Create(),
                0.01M * Rand.SmallInt(),
                CurrencyType.Ethereum
                ));
 }
예제 #26
0
 public static CardModel Create(UserModel user = null)
 {
     user ??= UserFaker.Create();
     return(CardRepository.CreateAndGet(
                "cardName_" + Rand.SmallInt(),
                "description" + Rand.SmallInt(),
                Rand.IntRange(0, 100),
                BoardColumnFaker.Create(user),
                user
                ));
 }
예제 #27
0
        public void Create_WithAmount_BalanceEquals()
        {
            var randomBalance = Rand.SmallDecimal();
            var user          = UserFaker.Create();
            var id            = UserBalance.Create(user, CurrencyType.BitCoin, randomBalance);
            var balance       = UserBalance.Find(id);

            Assert.NotNull(balance);
            Assert.AreEqual(user.id, balance.User().id);
            Assert.AreEqual(randomBalance, balance.balance);
        }
예제 #28
0
        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));
        }
예제 #29
0
        public void HasEntityPermission_Board_HasPermission()
        {
            var user  = UserFaker.Create();
            var board = BoardFaker.Create();

            Assert.False(PermissionUtils.HasEntityPermission(user, board.id, EntityType.Board));

            ProjectTeamMemberFaker.Create(board.Project(), user);

            Assert.True(PermissionUtils.HasEntityPermission(user, board.id, EntityType.Board));
        }
        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);
        }