Ejemplo n.º 1
0
        public void Create_WhenBindingSourceIsNotFromServices_ReturnsNull(BindingSource source)
        {
            // Arrange
            var provider = new ServicesModelBinderProvider();

            var context = new TestModelBinderProviderContext(typeof(IPersonService));
            context.BindingInfo.BindingSource = source;

            // Act
            var result = provider.GetBinder(context);

            // Assert
            Assert.Null(result);
        }
        public void Create_WhenBindingSourceIsFromServices_ReturnsBinder()
        {
            // Arrange
            var provider = new ServicesModelBinderProvider();

            var context = new TestModelBinderProviderContext(typeof(IPersonService));

            context.BindingInfo.BindingSource = BindingSource.Services;

            // Act
            var result = provider.GetBinder(context);

            // Assert
            Assert.IsType <ServicesModelBinder>(result);
        }