Exemple #1
0
        public void NullStringValue()
        {
            // passing null to format should return null
            TrimSpacesFormatter formatter = new TrimSpacesFormatter();
            var formatted = formatter.Format(null);

            formatted.Should().BeNull();
        }
Exemple #2
0
        public void EmptyOrWhitespacesValueShouldReturnEmptyString(string inValue)
        {
            TrimSpacesFormatter formatter = new TrimSpacesFormatter();
            // expecting a string other than null is always returned
            var formatted = formatter.Format(inValue) as string;

            formatted.Length.Should().Be(0);
        }
Exemple #3
0
        public void FormatValueNameResolveManagerEntityShouldNotThrowNotImplemented()
        {
            TrimSpacesFormatter formatter = new TrimSpacesFormatter();

            Action act = () => formatter.Format("something", "somename", null, null);

            act.ShouldNotThrow <NotImplementedException>();
        }
Exemple #4
0
        public void FormatValueNameShouldNotThrowNotImplemented()
        {
            TrimSpacesFormatter formatter = new TrimSpacesFormatter();

            Action act = () => formatter.Format("something", "somename");

            act.ShouldNotThrow <NotImplementedException>();
        }
Exemple #5
0
        public void ValuesToTrim(string inValue)
        {
            TrimSpacesFormatter formatter = new TrimSpacesFormatter();
            // expecting a string other than null is always returned
            var formatted = formatter.Format(inValue) as string;

            // all test cases have atleast one whitespace to trim
            formatted.Length.Should().BeLessOrEqualTo(inValue.Length - 1);
        }
Exemple #6
0
        public void ValidValuesNothingToTrim(string inValue)
        {
            TrimSpacesFormatter formatter = new TrimSpacesFormatter();
            // expecting a string other than null is always returned
            var formatted = formatter.Format(inValue) as string;

            // expecting same reference as the string shouldn't be modified
            formatted.Should().BeSameAs(inValue);
        }
Exemple #7
0
        public void TestWithObject()
        {
            // the formatter expects the value to be string
            TrimSpacesFormatter formatter = new TrimSpacesFormatter();
            SomeDemoObject      obj       = new SomeDemoObject()
            {
                Integer = 100,
                String  = "Some text",
                Type    = "Demo"
            };

            Action act = () => formatter.Format(obj);

            act.ShouldThrowExactly <PtvArgumentException>($"Expected value is string! Value {obj.ToString()} of type SomeDemoObject is not valid.");
        }