Пример #1
0
        public void TestGetValue_DifferentFormats()
        {
            // Arrange
            Dictionary <FullNameFormat, string> checkValues = new Dictionary <FullNameFormat, string>
            {
                { FullNameFormat.FirstLast, $"{firstName} {lastName}" },
                { FullNameFormat.LastFirst, $"{lastName} {firstName}" },
                { FullNameFormat.FirstMLast, $"{firstName} {firstName[0]}. {lastName}" },
                { FullNameFormat.LastMFirst, $"{lastName} {firstName[0]}. {firstName}" },
                { FullNameFormat.FMLast, $"{firstName[0]}.{firstName[0]}. {lastName}" },
                { FullNameFormat.LastFM, $"{lastName} {firstName[0]}.{firstName[0]}." }
            };
            var columnInfo = new FullNameColumnInfo {
                IsNullable = false
            };
            var strategy = new FullNameColumnValueStrategy(RepoFactory);

            foreach (FullNameFormat fullNameFormat in checkValues.Keys)
            {
                columnInfo.FullNameFormat = fullNameFormat;
                // Act
                string value = strategy.GetValue(columnInfo, EmptyCountry);
                // Assert
                Assert.AreEqual(checkValues[fullNameFormat], value);
            }
        }
Пример #2
0
        public void TestGetValue_WithMaxLengthRestriction()
        {
            // Arrange
            const int maxLength  = 2;
            var       columnInfo = new FullNameColumnInfo
            {
                IsNullable     = false,
                FullNameFormat = FullNameFormat.FirstLast,
                MaxLength      = maxLength
            };
            var strategy = new FullNameColumnValueStrategy(RepoFactory);
            // Act
            string value = strategy.GetValue(columnInfo, EmptyCountry);

            // Assert
            Assert.AreEqual(firstName.Substring(0, maxLength), value);
        }