Ejemplo n.º 1
0
        public void should_ignore_incorrect_codeRRContext()
        {
            var context = new ErrorReporterContext(this, new Exception());

            var sut    = new ModelStateProvider();
            var result = sut.Collect(context);

            result.Should().BeNull();
        }
Ejemplo n.º 2
0
        public void should_not_return_an_empty_collection_when_the_collection_is_empty()
        {
            var httpContext = Substitute.For <HttpContextBase>();
            var context     = new AspNetMvcContext(this, new Exception(), httpContext);

            context.ModelState = new Dictionary <string, ModelState>();

            var sut    = new ModelStateProvider();
            var result = sut.Collect(context);

            result.Should().BeNull();
        }
Ejemplo n.º 3
0
        public void should_include_included_items()
        {
            var httpContext = Substitute.For <HttpContextBase>();
            var context     = new AspNetMvcContext(this, new Exception(), httpContext);
            var items       = new Dictionary <string, ModelState>
            {
                { "MyKey", BuildState("Raw", "Attempted", "Failed") },
                { "NoError", BuildState(5, "5", null) }
            };

            context.ModelState = items;

            var sut    = new ModelStateProvider();
            var result = sut.Collect(context);

            result.Property("MyKey.RawValue").Should().Be("Raw");
            result.Property("MyKey.AttemptedValue").Should().Be("Attempted");
            result.Property("MyKey.Error").Should().Be("Failed");
            result.Properties.ContainsKey("NoError.Error").Should().BeFalse();
        }