コード例 #1
0
        private static async Task StringPropertyTest <T>() where T : StringProp, new()
        {
            var binder = new TestPathModelBinder <T>("controller/action/Name/Dmitry");
            await binder.BindModelAsync(new Mock <ModelBindingContext>().Object);

            binder.Model.Name.Should().Be("Dmitry");
        }
コード例 #2
0
        private static async Task NumericPropertyTest <T>() where T : new()
        {
            var binder = new TestPathModelBinder <NumericProp <T> >("controller/action/Id/88");
            await binder.BindModelAsync(new Mock <ModelBindingContext>().Object);

            dynamic dynamicModel = binder.Model;
            T       id           = (T)dynamicModel.Id;

            id.Should().Be(88);
        }