Example #1
0
        public void GetBinder_ThrowsArgumentNullException_WhenContextNull()
        {
            // Arrange
            var sut = new ExaminationValidationModelBinderProvider(null);

            // Act
            Action act = () => sut.GetBinder(null);

            // Assert
            act.Should().Throw <ArgumentNullException>();
        }
Example #2
0
        public void GetBinder_ReturnsNull_WhenMetadataModelTypeNotMatched()
        {
            // Arrange
            var sut      = new ExaminationValidationModelBinderProvider(null);
            var metadata = new Mock <ModelMetadata>(ModelMetadataIdentity.ForType(typeof(object)));
            var context  = new Mock <ModelBinderProviderContext>();

            context
            .SetupGet(c => c.Metadata)
            .Returns(metadata.Object);

            // Act
            var result = sut.GetBinder(context.Object);

            // Assert
            result.Should().BeNull();
        }
Example #3
0
        public void GetBinder_ReturnsBinder_WhenConcreteTypeMatches()
        {
            // Arrange
            var modelBinderProvider = new Mock <IModelBinderProvider>(MockBehavior.Strict);

            modelBinderProvider
            .Setup(mbp => mbp
                   .GetBinder(It.IsAny <ModelBinderProviderContext>()))
            .Returns((IModelBinder)null);

            var sut      = new ExaminationValidationModelBinderProvider(modelBinderProvider.Object);
            var metadata = new Mock <ModelMetadata>(ModelMetadataIdentity.ForType(typeof(PutMedicalTeamRequest)));
            var context  = new Mock <ModelBinderProviderContext>();

            context
            .SetupGet(c => c.Metadata)
            .Returns(metadata.Object);

            // Act
            var result = sut.GetBinder(context.Object);

            // Assert
            result.Should().BeOfType <ExaminationValidationModelBinder>();
        }