public void ResolveResource_EmptyResourceName_ArgumentException()
        {
            var ex = Assert.Throws <ArgumentException>(() =>
                                                       ResourceTypeResolver.ResolveResource <string>(typeof(Resources), string.Empty));

            Assert.That(ex.ParamName, Is.EqualTo(ResolveResourceResourceNameParam));
        }
        public void ResolveResource_NullResourceType_ArgumentNullException()
        {
            var ex = Assert.Throws <ArgumentNullException>(() =>
                                                           ResourceTypeResolver.ResolveResource <string>(null, ResourceName));

            Assert.That(ex.ParamName, Is.EqualTo(ResolveResourceResourceTypeParam));
        }
        public void ResolveResource_ResourceFound()
        {
            var resource =
                ResourceTypeResolver.ResolveResource <string>(typeof(Resources), ResourceName);

            Assert.That(resource, Is.Not.Null);
            Assert.That(resource, Is.EqualTo("This is a test resource."));
        }
Beispiel #4
0
        public static void Setup()
        {
            var mockResolver = new Mock <ResourceTypeResolver> {
                CallBase = true
            };

            var type = typeof(OicCoreResource);

            mockResolver.Setup(c => c.TryGetResourseType("oic.r.core", out type)).Returns(true);
            type = typeof(ResourceTypes.Audio);
            mockResolver.Setup(c => c.TryGetResourseType("oic.r.audio", out type)).Returns(true);
            type = typeof(CoreResources.OicResourceDirectory);
            mockResolver.Setup(c => c.TryGetResourseType("oic.wk.res", out type)).Returns(true);

            _resolver = mockResolver.Object;
        }
        public CommandParameterAttribute(
            int index,
            string name,
            Type resourceType,
            string helpTextResourceName)
        {
            ParameterValidation.IsGreaterThanOrEqualTo(index, 0, nameof(index));
            ParameterValidation.IsNotNull(name, nameof(name));
            ParameterValidation.IsNotEmpty(name, nameof(name));
            ParameterValidation.IsFalse(
                name.Contains(" "),
                "Value cannot contain spaces.",
                nameof(name));
            ParameterValidation.IsNotNull(resourceType, nameof(resourceType));
            ParameterValidation.IsNotNull(helpTextResourceName, nameof(helpTextResourceName));
            ParameterValidation.IsNotEmpty(helpTextResourceName, nameof(helpTextResourceName));

            this.Index    = index;
            this.Name     = name;
            this.HelpText =
                ResourceTypeResolver.ResolveResource <string>(resourceType, helpTextResourceName);
        }
        public CommandAttribute(
            string group,
            string name,
            Type resourceType,
            string helpTextResourceName)
        {
            ParameterValidation.IsNotNull(group, nameof(group));
            ParameterValidation.IsNotEmpty(group, nameof(group));
            ParameterValidation.IsNotNull(name, nameof(name));
            ParameterValidation.IsNotEmpty(name, nameof(name));
            ParameterValidation.IsFalse(
                name.Contains(" "),
                "Value cannot contain spaces.",
                nameof(name));
            ParameterValidation.IsNotNull(resourceType, nameof(resourceType));
            ParameterValidation.IsNotNull(helpTextResourceName, nameof(helpTextResourceName));
            ParameterValidation.IsNotEmpty(helpTextResourceName, nameof(helpTextResourceName));

            this.Group    = group;
            this.Name     = name;
            this.HelpText =
                ResourceTypeResolver.ResolveResource <string>(resourceType, helpTextResourceName);
        }
 public void ResolveResource_ResourceNotFound()
 {
     Assert.Throws <InvalidOperationException>(() =>
                                               ResourceTypeResolver.ResolveResource <string>(typeof(Resources), "InvalidResource"));
 }