Exemple #1
0
        public void ExtractLocalizedNameFromDisplayAttribute()
        {
            // Arrange
            var csProjectProcessor          = new FakeCSharpProjectProcessor();
            var localizableStringCollection = new LocalizableStringCollection();

            // Act
            csProjectProcessor.Process(string.Empty, string.Empty, localizableStringCollection);

            // Assert
            var localizedStrings = localizableStringCollection.Values.Select(s => s.Text).ToList();

            Assert.Contains(localizedStrings, s => s == "First name");
        }
Exemple #2
0
        public void DataAnnotationsExtractorShouldRespectErrorMessageOrder()
        {
            // Arrange
            var csProjectProcessor          = new FakeCSharpProjectProcessor();
            var localizableStringCollection = new LocalizableStringCollection();

            // Act
            csProjectProcessor.Process(string.Empty, string.Empty, localizableStringCollection);

            // Assert
            var localizedStrings = localizableStringCollection.Values.Select(s => s.Text).ToList();

            Assert.Contains(localizedStrings, s => s == "Age should be in the range [15-45].");
        }
Exemple #3
0
        public void ExtractlocalizedStringsFromDataAnnotations()
        {
            // Arrange
            var csProjectProcessor          = new FakeCSharpProjectProcessor();
            var localizableStringCollection = new LocalizableStringCollection();

            // Act
            csProjectProcessor.Process(string.Empty, string.Empty, localizableStringCollection);

            // Assert
            var localizedStrings = localizableStringCollection.Values.Select(s => s.Text).ToList();

            Assert.NotEmpty(localizedStrings);
            Assert.Equal(2, localizedStrings.Count());
            Assert.Contains(localizedStrings, s => s == "The username is required.");
        }