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

            formatted.Should().BeNull();
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 3
0
        public void FormatValueNameResolveManagerEntityShouldNotThrowNotImplemented()
        {
            TrimSpacesFormatter formatter = new TrimSpacesFormatter();

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

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

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

            act.ShouldNotThrow <NotImplementedException>();
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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.");
        }