Пример #1
0
        public async Task UpdateGroupMembership_ValidResponse()
        {
            Handler.Setup(h => h.ExecuteAsync <BoxGroupMembership>(It.IsAny <IBoxRequest>()))
            .Returns(() => Task.FromResult <IBoxResponse <BoxGroupMembership> >(new BoxResponse <BoxGroupMembership>()
            {
                Status        = ResponseStatus.Success,
                ContentString = @"{ ""type"": ""group_membership"", ""id"": ""2381570"",
                                        ""user"": { ""type"": ""user"", ""id"": ""4940223"", ""name"": ""<script>alert(12);</script>"", ""login"": ""*****@*****.**""},
                                        ""group"": { ""type"": ""group"", ""id"": ""159622"", ""name"": ""test204bbee0-f3b0-43b4-b213-214fcd2cb9a7"" },
                                        ""role"": ""admin"",
                                        ""created_at"": ""2013-11-13T13:19:44-08:00"",
                                        ""modified_at"": ""2013-11-13T13:19:44-08:00""}"
            }));

            BoxGroupMembershipRequest request = new BoxGroupMembershipRequest()
            {
                Role = "anything"
            };

            BoxGroupMembership response = await _groupsManager.UpdateGroupMembershipAsync("123", request);

            Assert.AreEqual("2381570", response.Id, "Wrong Membership id");
            Assert.AreEqual("group_membership", response.Type, "wrong type");
            Assert.AreEqual("159622", response.Group.Id, "Wrong group id");
            Assert.AreEqual("4940223", response.User.Id, "Wrong user id");
            Assert.AreEqual("admin", response.Role, "Wrong role");
            Assert.AreEqual(DateTime.Parse("2013-11-13T13:19:44-08:00"), response.CreatedAt, "Wrong created at");
            Assert.AreEqual(DateTime.Parse("2013-11-13T13:19:44-08:00"), response.ModifiedAt, "Wrong modified at");
        }