public void GetApiMethodParamFullDescriptionNotAllAttributes()
        {
            var description = vkApiSpecifier.GetApiMethodParamFullDescription(authorizeMethodName, "login");

            Assert.IsNotNull(description);
            Assert.IsNull(description.MinValue);
            Assert.IsNull(description.MaxValue);
            Assert.IsTrue(description.Required);
            var expected = new CommonDescription("login");

            AssertCommonDescriptionAreEquals(expected, description.ParamDescription);
        }
        public void GetApiMethodParamFullDescription()
        {
            var description = vkApiSpecifier.GetApiMethodParamFullDescription(selectAudioMethodName, "batchSize");

            Assert.IsNotNull(description);
            Assert.AreEqual(1, description.MinValue);
            Assert.AreEqual(100, description.MaxValue);
            Assert.IsTrue(description.Required);
            var expected = new CommonDescription("batchSize", "number of audios to return");

            AssertCommonDescriptionAreEquals(expected, description.ParamDescription);
        }
        public void GetApiMethodParamFullDescriptionWhenRandomParamName()
        {
            var paramName   = Guid.NewGuid().ToString();
            var description = vkApiSpecifier.GetApiMethodParamFullDescription(authorizeMethodName, paramName);

            Assert.IsNotNull(description);
            Assert.IsNull(description.MinValue);
            Assert.IsNull(description.MaxValue);
            Assert.IsFalse(description.Required);
            var expected = new CommonDescription(paramName);

            AssertCommonDescriptionAreEquals(expected, description.ParamDescription);
        }
Ejemplo n.º 4
0
        public ApiParamDescription GetApiMethodParamFullDescription(string methodName, string paramName)
        {
            var method = GetMethodInfo(typeof(T), methodName);
            var param  = GetParameterInfo(method, paramName);
            var attrs  = param?.GetCustomAttributes(false);

            return(new ApiParamDescription
            {
                MinValue = attrs?.OfType <ApiIntValidationAttribute>()
                           .FirstOrDefault()?.MinValue,
                MaxValue = attrs?.OfType <ApiIntValidationAttribute>()
                           .FirstOrDefault()?.MaxValue,
                ParamDescription = new CommonDescription(paramName, attrs?.OfType <ApiDescriptionAttribute>()
                                                         .FirstOrDefault()?.Description),
                Required = attrs?.OfType <ApiRequiredAttribute>().
                           FirstOrDefault() is null ? false
                    : attrs.OfType <ApiRequiredAttribute>().FirstOrDefault().Required
            });
Ejemplo n.º 5
0
 public ApiParamDescription GetApiMethodParamFullDescription(string methodName, string paramName)
 {
     if (GetParameterInfo(GetMethodInfo(typeof(T), methodName), paramName) == null)
     {
         return(null);
     }
     else
     {
         var fullDiscription = GetParameterInfo(GetMethodInfo(typeof(T), methodName), paramName)
                               .GetCustomAttributes(false);
         return(new ApiParamDescription
         {
             MinValue = fullDiscription?.OfType <ApiIntValidationAttribute>()
                        .FirstOrDefault()?.MinValue,
             MaxValue = fullDiscription?.OfType <ApiIntValidationAttribute>()
                        .FirstOrDefault()?.MaxValue,
             ParamDescription = new CommonDescription(paramName, fullDiscription?.OfType <ApiDescriptionAttribute>()
                                                      .FirstOrDefault()?.Description),
             Required = fullDiscription?.OfType <ApiRequiredAttribute>().
                        FirstOrDefault() is null ? false
                 : fullDiscription.OfType <ApiRequiredAttribute>().FirstOrDefault().Required
         });
 private static void AssertCommonDescriptionAreEquals(CommonDescription expected, CommonDescription actual)
 {
     Assert.AreEqual(expected?.Name, actual?.Name);
     Assert.AreEqual(expected?.Description, actual?.Description);
 }