public void CreateAsync_NewGroupNull_ThrowArgumentNullException()
        {
            WrikeGroup newGroup = null;

            var ex = Assert.ThrowsAsync <ArgumentNullException>(() => TestConstants.WrikeClient.Groups.CreateAsync(newGroup));

            Assert.AreEqual("newGroup", ex.ParamName);
        }
        public void CreateAsync_ShouldAddNewGroupWithTitle()
        {
            var newGroup     = new WrikeGroup("Sinan's Test Group");
            var createdGroup = WrikeClientFactory.GetWrikeClient().Groups.CreateAsync(newGroup).Result;

            Assert.IsNotNull(createdGroup);
            Assert.AreEqual(newGroup.Title, createdGroup.Title);

            //TODO: test other parameters
        }
        public void DeleteAsync_ShouldDeleteNewGroup()
        {
            var newGroup = new WrikeGroup("Sinan's Test Group");

            newGroup = WrikeClientFactory.GetWrikeClient().Groups.CreateAsync(newGroup).Result;

            WrikeClientFactory.GetWrikeClient().Groups.DeleteAsync(newGroup.Id).Wait();

            var groups         = WrikeClientFactory.GetWrikeClient().Groups.GetAsync().Result;
            var isGroupDeleted = !groups.Any(g => g.Id == newGroup.Id);

            Assert.IsTrue(isGroupDeleted);
        }
        public void UpdateAsync_ShouldUpdateGroupTitle()
        {
            var newGroup = new WrikeGroup("Sinan's Test Group");

            newGroup = WrikeClientFactory.GetWrikeClient().Groups.CreateAsync(newGroup).Result;

            var expectedGroupTitle = "Sinan's Test Group [Updated]";
            var updatedGroup       = WrikeClientFactory.GetWrikeClient().Groups.UpdateAsync(newGroup.Id, expectedGroupTitle).Result;

            Assert.IsNotNull(updatedGroup);
            Assert.AreEqual(expectedGroupTitle, updatedGroup.Title);

            //TODO: test other parameters
        }
        public static async Task Run(WrikeClient client)
        {
            var allGroups = await client.Groups.GetAsync();

            var newGroup = new WrikeGroup("Sinan's Test Group");

            newGroup = await client.Groups.CreateAsync(newGroup);



            var updatedGroup = await client.Groups.UpdateAsync(
                newGroup.Id,
                title : "Sinan's Group [Updated]",
                avatar : new WrikeGroupAvatar("#795548", "SG"));



            await client.Groups.DeleteAsync(newGroup.Id, true);

            await client.Groups.DeleteAsync(newGroup.Id);
        }
Exemple #6
0
        async Task <WrikeGroup> IWrikeGroupsClient.CreateAsync(WrikeGroup newGroup, string parentId, WrikeGroupAvatar avatar)
        {
            if (newGroup == null)
            {
                throw new ArgumentNullException(nameof(newGroup));
            }

            var requestUri = $"groups";

            var postDataBuilder = new WrikeFormUrlEncodedContentBuilder()
                                  .AddParameter("title", newGroup.Title)
                                  .AddParameter("members", newGroup.MemberIds)
                                  .AddParameter("parent", parentId)
                                  .AddParameter("avatar", avatar)
                                  .AddParameter("metadata", newGroup.Metadata);

            var postContent = postDataBuilder.GetContent();
            var response    = await SendRequest <WrikeGroup>(requestUri, HttpMethods.Post, postContent).ConfigureAwait(false);

            return(GetReponseDataFirstItem(response));
        }