Пример #1
0
        public void ResponseDataAsShouldReuseConvertedResponse()
        {
            string responseJson = "{\"sub\":\"411421B0-38D6-6568-A53A-DF99691B7EB6\",\"email\":\"[email protected]\",\"email_verified\":true,\"phone_number\":\"+447700200200\",\"phone_number_verified\":true,\"birthdate\":\"1990-04-11\",\"updated_at\":\"1460779506\",\"address\":{\"formatted\":\"123 Fake Street \r\n Manchester\",\"postal_code\":\"M1 1AB\"}}";
            var    response     = new RestResponse(System.Net.HttpStatusCode.Accepted, responseJson);

            var userInfoResponse = new IdentityResponse(response, IdentityService.InfoType.UserInfo);
            var first            = userInfoResponse.ResponseDataAs <UserInfoData>();
            var second           = userInfoResponse.ResponseDataAs <UserInfoData>();

            Assert.AreSame(first, second);
        }
Пример #2
0
        public void ResponseDataAsShouldReturnDefaultIfResponseJsonNull()
        {
            var response = new RestResponse(System.Net.HttpStatusCode.Accepted, null);

            var userInfoResponse = new IdentityResponse(response, IdentityService.InfoType.UserInfo);
            var actual           = userInfoResponse.ResponseDataAs <UserInfoData>();

            Assert.IsNull(actual);
        }
Пример #3
0
        public void ResponseDataAsShouldDeserializeToUserInfoData()
        {
            string responseJson = "{\"sub\":\"411421B0-38D6-6568-A53A-DF99691B7EB6\",\"email\":\"[email protected]\",\"email_verified\":true,\"phone_number\":\"+447700200200\",\"phone_number_verified\":true,\"birthdate\":\"1990-04-11\",\"updated_at\":\"1460779506\",\"address\":{\"formatted\":\"123 Fake Street \r\n Manchester\",\"postal_code\":\"M1 1AB\"}}";
            var    response     = new RestResponse(System.Net.HttpStatusCode.Accepted, responseJson);

            var userInfoResponse = new IdentityResponse(response, IdentityService.InfoType.UserInfo);
            var actual           = userInfoResponse.ResponseDataAs <UserInfoData>();

            Assert.IsNotNull(actual);
            Assert.AreEqual("411421B0-38D6-6568-A53A-DF99691B7EB6", actual.Sub);
            Assert.AreEqual("*****@*****.**", actual.Email);
            Assert.AreEqual(true, actual.EmailVerified);
            Assert.AreEqual("+447700200200", actual.PhoneNumber);
            Assert.AreEqual(true, actual.PhoneNumberVerified);
            Assert.IsNotNull(actual.Address);
            Assert.AreEqual("123 Fake Street \r\n Manchester", actual.Address.Formatted);
            Assert.AreEqual("M1 1AB", actual.Address.PostalCode);
            Assert.AreEqual("1990-04-11", actual.Birthdate);
            Assert.AreEqual(new DateTime(2016, 4, 16, 4, 5, 6), actual.UpdatedAt);
        }