コード例 #1
0
        public void GetLocalizedString_ThrowsIfGetPropertyIsNotAvalible()
        {
            // Arrage
            Type resourceType = typeof(MockResourceType);

            // Act & Assert
            ExceptionAssert.Throws <InvalidOperationException>(() => CommandLineUtility.GetLocalizedString(resourceType, "NoGet"),
                                                               "The resource type 'NuGet.Test.NuGetCommandLine.CommandLineUtilityTests+MockResourceType' does not have an accessible get for the 'NoGet' property.");
        }
コード例 #2
0
        public void GetLocalizedString_ThrowsIfPropertyIsNotOfStringType()
        {
            // Arrage
            Type resourceType = typeof(MockResourceType);

            // Act & Assert
            ExceptionAssert.Throws <InvalidOperationException>(() => CommandLineUtility.GetLocalizedString(resourceType, "NotValid"),
                                                               "The property 'NotValid' on resource type 'NuGet.Test.NuGetCommandLine.CommandLineUtilityTests+MockResourceType' is not a string type.");
        }
コード例 #3
0
        public void GetLocalizedString_ThrowsIfNoPropteryByResourceName()
        {
            // Arrage
            Type resourceType = typeof(MockResourceType);

            // Act & Assert
            ExceptionAssert.Throws <InvalidOperationException>(() => CommandLineUtility.GetLocalizedString(resourceType, "DoesntExist"),
                                                               "The resource type 'NuGet.Test.NuGetCommandLine.CommandLineUtilityTests+MockResourceType' does not have an accessible static property named 'DoesntExist'.");
        }
コード例 #4
0
        public void GetLocalizedString_ReturnsResourceWithValidName()
        {
            // Arrange
            Type resourceType = typeof(MockResourceType);
            // Act
            var actual = CommandLineUtility.GetLocalizedString(resourceType, "Message");

            // Assert
            Assert.AreEqual("This is a Message.", actual);
        }
コード例 #5
0
 public void GetLocalizedString_ThrowsArgumentExceptionForEmptyName()
 {
     // Act & Assert
     ExceptionAssert.ThrowsArgNullOrEmpty(() => CommandLineUtility.GetLocalizedString(typeof(string), ""), "resourceName");
 }
コード例 #6
0
 public void GetLocalizedString_ThrowsArgumentExceptionForNullType()
 {
     // Act & Assert
     ExceptionAssert.ThrowsArgNull(() => CommandLineUtility.GetLocalizedString(null, "foo"), "resourceType");
 }