Ejemplo n.º 1
0
        public void CreateDictionarySchema_Empty()
        {
            var mock = new Mock <JsonDictionaryContract>(typeof(Dictionary <int, int>));
            var mockJsonSerializer = new Mock <JsonSerializerSettings>();

            var opt    = new SwaggerGeneratorOptions();
            var schema = new SchemaRegistry(mockJsonSerializer.Object, opt);

            Assert.DoesNotThrow(() => schema.CreateDictionarySchema(mock.Object));
        }
Ejemplo n.º 2
0
        public void CreateDictionarySchema_Null()
        {
            var mockContract = new Mock <JsonDictionaryContract>(typeof(Dictionary <int, int>));
            //mockContract.Setup(x => x.DictionaryKeyType).Returns((Type)null);
            var mockJsonSerializer = new Mock <JsonSerializerSettings>();

            var schema = new SchemaRegistry(mockJsonSerializer.Object, null);

            Assert.Throws <NullReferenceException>(() => schema.CreateDictionarySchema(mockContract.Object));
        }
Ejemplo n.º 3
0
        public void CreateDictionarySchema_Null()
        {
            var mockContract = new Mock <JsonDictionaryContract>(typeof(Dictionary <int, int>));
            //mockContract.Setup(x => x.DictionaryKeyType).Returns((Type)null);
            var mockJsonSerializer = new Mock <JsonSerializerSettings>();

            bool hasError = false;

            try
            {
                var schema = new SchemaRegistry(mockJsonSerializer.Object, null);
                schema.CreateDictionarySchema(mockContract.Object);
            }
            catch
            {
                hasError = true;
            }
            Assert.IsTrue(hasError);
        }