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"));
        }
        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") ?? ""
                );
        }
Ejemplo n.º 3
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))
                       ));
        }
Ejemplo n.º 4
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));
        }
Ejemplo n.º 5
0
        public void Get_DataCorrect_GotBoard()
        {
            var browser = new Browser(new DefaultNancyBootstrapper());

            var board = BoardFaker.Create();

            var result = browser.Get("/api/v1/board/get", with => {
                with.HttpRequest();
                with.Query("board_guid", board.guid);
            }).Result;

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

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

            Assert.AreEqual(board.guid, json["data"]["board"].Value <string>("guid"));
        }
        public void Delete_DataCorrect_BoardDeleted() {
            var browser = new Browser(new DefaultNancyBootstrapper());

            var me = UserFaker.Create();
            var board = BoardFaker.Create(me);

            Assert.NotNull(BoardRepository.Find(board.id));

            var result = browser.Delete("/api/v1/board/delete", with => {
                with.HttpRequest();
                with.Query("api_token", Jwt.FromUserId(me.id));
                with.Query("board_guid", board.guid);
            }).Result;
            
            Assert.AreEqual(HttpStatusCode.OK, result.StatusCode);
            
            Assert.IsNull(BoardRepository.Find(board.id));
        }