public void Defensive() { var root = CodeNamespace.InitRootNamespace(); var method = new CodeMethod(root) { Name = "class", }; Assert.False(method.IsOfKind((CodeMethodKind[])null)); Assert.False(method.IsOfKind(new CodeMethodKind[] { })); }
public void IsOfKind() { var method = new CodeMethod { Name = "class", }; Assert.False(method.IsOfKind(CodeMethodKind.Constructor)); method.Kind = CodeMethodKind.Deserializer; Assert.True(method.IsOfKind(CodeMethodKind.Deserializer)); Assert.True(method.IsOfKind(CodeMethodKind.Deserializer, CodeMethodKind.Getter)); Assert.False(method.IsOfKind(CodeMethodKind.Getter)); }
public void IsOfKind() { var root = CodeNamespace.InitRootNamespace(); var method = new CodeMethod(root) { Name = "class", }; Assert.False(method.IsOfKind(CodeMethodKind.Constructor)); method.MethodKind = CodeMethodKind.Deserializer; Assert.True(method.IsOfKind(CodeMethodKind.Deserializer)); Assert.True(method.IsOfKind(CodeMethodKind.Deserializer, CodeMethodKind.Getter)); Assert.False(method.IsOfKind(CodeMethodKind.Getter)); }
public void Defensive() { var method = new CodeMethod { Name = "class", }; Assert.False(method.IsOfKind((CodeMethodKind[])null)); Assert.False(method.IsOfKind(Array.Empty <CodeMethodKind>())); Assert.Throws <ArgumentNullException>(() => method.AddDiscriminatorMapping(null, new CodeType { Name = "class" })); Assert.Throws <ArgumentNullException>(() => method.AddDiscriminatorMapping("oin", null)); Assert.Throws <ArgumentNullException>(() => method.GetDiscriminatorMappingValue(null)); Assert.Null(method.GetDiscriminatorMappingValue("oin")); Assert.Throws <ArgumentNullException>(() => method.AddErrorMapping(null, new CodeType { Name = "class" })); Assert.Throws <ArgumentNullException>(() => method.AddErrorMapping("oin", null)); Assert.Throws <ArgumentNullException>(() => method.GetErrorMappingValue(null)); Assert.Null(method.GetErrorMappingValue("oin")); }