Exemplo n.º 1
0
        public void GetSupportedContentTypes_ThrowsInvalidOperationException_IfMediaTypesListIsEmpty()
        {
            // Arrange
            var formatter = new BadConfigurationFormatter();

            // Act & Assert
            Assert.Throws <InvalidOperationException>(
                () => formatter.GetSupportedContentTypes("application/json", typeof(object)));
        }
Exemplo n.º 2
0
        public void CanRead_ThrowsInvalidOperationException_IfMediaTypesListIsEmpty()
        {
            // Arrange
            var formatter = new BadConfigurationFormatter();
            var context   = new InputFormatterContext(
                new DefaultHttpContext(),
                string.Empty,
                new ModelStateDictionary(),
                new EmptyModelMetadataProvider().GetMetadataForType(typeof(object)),
                (s, e) => new StreamReader(s, e));

            // Act & Assert
            Assert.Throws <InvalidOperationException>(() => formatter.CanRead(context));
        }