Beispiel #1
0
        public void DisplayName_ConstructedWithEnumTypeValueWithResourceDisplayNameAttribute_EqualsToResourceString()
        {
            // Setup
            var wrapper = new EnumDisplayWrapper <TestEnum>(TestEnum.DisplayName);

            // Call
            string displayName = wrapper.DisplayName;

            // Assert
            Assert.AreEqual("Display name", displayName);
        }
Beispiel #2
0
        public void ToString_Always_SameAsDisplayName()
        {
            // Setup
            var wrapper = new EnumDisplayWrapper <TestEnum>(TestEnum.DisplayName);

            // Call
            string wrapperToString = wrapper.ToString();

            // Assert
            Assert.AreEqual(wrapper.DisplayName, wrapperToString);
        }
 /// <summary>
 /// Method that asserts whether <paramref name="expected"/> and <paramref name="actual"/>
 /// are equal.
 /// </summary>
 /// <param name="expected">The expected object.</param>
 /// <param name="actual">The actual object.</param>
 /// <exception cref="AssertionException">Thrown when <paramref name="expected"/> and
 /// <paramref name="actual"/> are not equal.</exception>
 private static void AssertEnumDisplayWrappersAreEqual <T>(IEnumerable <EnumDisplayWrapper <T> > expected,
                                                           IEnumerable <EnumDisplayWrapper <T> > actual)
 {
     Assert.AreEqual(expected.Count(), actual.Count());
     for (var i = 0; i < expected.Count(); i++)
     {
         EnumDisplayWrapper <T> expectedWrapper = expected.ElementAt(i);
         EnumDisplayWrapper <T> actualWrapper   = actual.ElementAt(i);
         Assert.AreEqual(expectedWrapper.Value, actualWrapper.Value);
         Assert.AreEqual(expectedWrapper.DisplayName, actualWrapper.DisplayName);
     }
 }
Beispiel #4
0
        public void DisplayName_ConstructedWithEnumTypeValueWithoutResourceDisplayNameAttribute_EqualsToDefaultStringRepresentation()
        {
            // Setup
            const TestEnum value   = TestEnum.NoDisplayName;
            var            wrapper = new EnumDisplayWrapper <TestEnum>(value);

            // Call
            string displayName = wrapper.DisplayName;

            // Assert
            Assert.AreEqual(value.ToString(), displayName);
        }