コード例 #1
0
        public void Patch_DataCorrect_CardUpdated()
        {
            var browser = new Browser(new DefaultNancyBootstrapper());

            var me   = UserFaker.Create();
            var card = CardFaker.Create(me);

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

            var result = browser.Patch("/api/v1/card/edit", with => {
                with.HttpRequest();
                with.Query("api_token", Jwt.FromUserId(me.id));
                with.Query("card_guid", card.guid);
                with.Query("name", updatedName);
                with.Query("description", updatedDescription);
                with.Query("column_order", updatedColumnOrder);
            }).Result;

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

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

            Assert.AreEqual(card.guid, json["data"]["card"].Value <string>("guid"));
            Assert.AreEqual(updatedName, json["data"]["card"].Value <string>("name"));
            Assert.AreEqual(updatedColumnOrder, json["data"]["card"].Value <string>("column_order"));
        }
コード例 #2
0
ファイル: ProjectTests.cs プロジェクト: gitcomteam/gitcom-api
        public void Cards_Ok()
        {
            var card    = CardFaker.Create();
            var project = card.Project();

            var foundCard = project.Cards().Where(c => c.id == card.id).ToArray()[0];

            Assert.AreEqual(card.id, foundCard.id);
        }
コード例 #3
0
        public void Get_DataCorrect_GotCardBalances()
        {
            var card = CardFaker.Create();

            FundingBalanceFaker.Create(card.id, EntityType.Card, CurrencyType.Ethereum, 0.2M);
            FundingBalanceFaker.Create(card.id, EntityType.Card, CurrencyType.BitCoin);

            var result = new Browser(new DefaultNancyBootstrapper())
                         .Get("/api/v1/entity/funding/balances/get", with => {
                with.HttpRequest();
                with.Query("entity_guid", card.guid);
                with.Query("entity_type", EntityType.Card.ToString());
            }).Result;

            Assert.AreEqual(HttpStatusCode.OK, result.StatusCode);
        }
コード例 #4
0
        public void Get_DataCorrect_GotCard()
        {
            var browser = new Browser(new DefaultNancyBootstrapper());

            var card = CardFaker.Create();

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

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

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

            Assert.AreEqual(card.guid, json["data"]["card"].Value <string>("guid"));
        }
コード例 #5
0
        public void Delete_DataCorrect_CardDeleted()
        {
            var browser = new Browser(new DefaultNancyBootstrapper());

            var me   = UserFaker.Create();
            var card = CardFaker.Create(me);

            Assert.NotNull(CardRepository.Find(card.id));

            var result = browser.Delete("/api/v1/card/delete", with => {
                with.HttpRequest();
                with.Query("api_token", Jwt.FromUserId(me.id));
                with.Query("card_guid", card.guid);
            }).Result;

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

            Assert.IsNull(CardRepository.Find(card.id));
        }
コード例 #6
0
        public void SubmitWork_DataCorrect_WorkCreated()
        {
            var card = CardFaker.Create();

            var project = card.Column().Board().Project();

            var workType = project.WorkTypes()[0];

            var result = new Browser(new DefaultNancyBootstrapper())
                         .Post("/api/v1/card/work/submit", with => {
                with.HttpRequest();
                with.Query("api_token", Jwt.FromUserId(UserFaker.Create().id));
                with.Query("card_guid", card.guid);
                with.Query("work_type_guid", workType.guid);
                with.Query("proof", "some proof");
            }).Result;

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

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

            Assert.AreEqual(card.guid, json["data"]["work_item"].Value <string>("card_guid"));
        }
コード例 #7
0
        public void GetWork_DataCorrect_GotWork()
        {
            var card = CardFaker.Create();

            var project = card.Column().Board().Project();

            var cardWork = CardWorkFaker.Create(project.WorkTypes()[0], card);

            var result = new Browser(new DefaultNancyBootstrapper())
                         .Get("/api/v1/card/work/get", with => {
                with.HttpRequest();
                with.Query("card_guid", card.guid);
            }).Result;

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

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

            var workItems = json["data"].Value <JArray>("work_items");

            Assert.NotNull(workItems);

            Assert.AreEqual(cardWork.guid, workItems[0].Value <string>("guid"));
        }
コード例 #8
0
 public static CardWork Create(ProjectWorkType workType, CardModel card = null, UserModel user = null)
 {
     user ??= UserFaker.Create();
     card ??= CardFaker.Create();
     return(CardWorkRepository.CreateAndGet(user, card, workType, "some proof like link or something"));
 }
コード例 #9
0
        public void Project_Ok()
        {
            var card = CardFaker.Create();

            Assert.NotNull(card.Project());
        }