public void CreatesCodeEditorInstance(int kind, string fileName, string fixedArguments, Type expectedType, params string[] expectedArguments) { var descriptor = new CodeEditorDescriptor((CodeEditorKind)kind, fileName, fixedArguments); var editor = descriptor.ToEditor(); Assert.That(editor, Is.InstanceOf(expectedType)); var fileNameField = expectedType.GetField("FileName", BindingFlags.Instance | BindingFlags.NonPublic); Assert.That(fileNameField.GetValue(editor), Is.EqualTo(fileName)); var fixedArgumentsField = expectedType.GetField("FixedArguments", BindingFlags.Instance | BindingFlags.NonPublic); Assert.That(fixedArgumentsField.GetValue(editor), Is.EquivalentTo(expectedArguments)); }
public void ValidatesNullArguments() { Assert.Throws <ArgumentNullException>(() => new CodeEditorDescriptor(CodeEditorKind.Other, null, null)); Assert.Throws <ArgumentNullException>(() => new CodeEditorDescriptor(CodeEditorKind.Other, null, "")); Assert.Throws <ArgumentNullException>(() => new CodeEditorDescriptor(CodeEditorKind.Other, "", "")); Assert.Throws <ArgumentNullException>(() => new CodeEditorDescriptor(CodeEditorKind.Other, "", null)); Assert.Throws <ArgumentNullException>(() => new CodeEditorDescriptor(CodeEditorKind.Other, "foo", null)); var editor = new CodeEditorDescriptor(CodeEditorKind.Other, "foo", ""); Assert.Throws <ArgumentNullException>(() => editor.FileName = null); Assert.Throws <ArgumentNullException>(() => editor.FileName = ""); Assert.Throws <ArgumentNullException>(() => editor.FixedArguments = null); editor.FixedArguments = ""; }