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)); }
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)); }
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); }