public MethodArg(string doc, MethodArgType type, string name, object?defaultValue = null) { Doc = doc; Type = type; Name = name; DefaultValue = defaultValue; }
public TestCaseSignature(IEnumerable <ITestCaseCell> cells, MethodArgType type) { foreach (var cell in cells) { this.arguments.Add(MethodArgument.Create(cell, type)); } }
public void MethodArgTest( object value, MethodArgType argumentType, Type expectedType, object expected, string keyword) { var dependency = TestDouble.For <ITestCaseCell>().Stub(x => x.Value, value); var sut = MethodArgument.Create(dependency, argumentType); sut.Type.Should().Be(expectedType, "SUT type was not expected type."); sut.Value.Should().Be(expected, "SUT values was not expected value."); sut.CSharpType.Should().Be(keyword); }
public static bool Is64BitArgument(MethodArgType type) { switch (type) { case MethodArgType.Code: case MethodArgType.Register: case MethodArgType.RepPrefixKind: case MethodArgType.Memory: case MethodArgType.UInt8: case MethodArgType.UInt16: case MethodArgType.Int32: case MethodArgType.UInt32: case MethodArgType.PreferedInt32: case MethodArgType.ByteSlice: case MethodArgType.WordSlice: case MethodArgType.DwordSlice: case MethodArgType.QwordSlice: return(false); case MethodArgType.Int64: case MethodArgType.UInt64: return(true); case MethodArgType.ArrayIndex: case MethodArgType.ArrayLength: // Never used, but if they're used in the future, they should be converted to u32 types if RustJS throw new InvalidOperationException(); case MethodArgType.ByteArray: case MethodArgType.WordArray: case MethodArgType.DwordArray: case MethodArgType.QwordArray: case MethodArgType.BytePtr: case MethodArgType.WordPtr: case MethodArgType.DwordPtr: case MethodArgType.QwordPtr: default: throw new ArgumentOutOfRangeException(nameof(type)); } }
public GenericParameter(MethodArgType placement, Type type, object value) : base(placement) { this.Type = type; this.Value = value; }
protected ArgumentBase(MethodArgType placement) { this.Placement = placement; }
public StringParameter(string value, MethodArgType placement) : base(placement) { this.Value = value.TrimStart('\'').TrimEnd('\''); }
public static IMethodArgument Create(ITestCaseCell cell, MethodArgType placement) { if (placement == MethodArgType.Parameter) { return(new StringParameter(cell.Value.ToString(), placement)); } var v = cell.Value.ToString().Trim(); if (v.StartsWith("'", StringComparison.OrdinalIgnoreCase) && v.EndsWith("'", StringComparison.OrdinalIgnoreCase)) { return(new StringParameter( cell.Value.ToString(), placement)); } var isNullable = v.EndsWith("?"); if (isNullable) { v = v.Substring(0, v.Length - 1); } try { checked { var param = ParameterFactory.Create(v, isNullable); if (param.IsValid()) { return(param); } return(new StringParameter(v, placement)); } } catch (FormatException) { return(new StringParameter(v, placement)); } // ReSharper disable once EmptyGeneralCatchClause catch (Exception) { } if (isNullable) { return(new NumericNull()); } try { return(new NumericParameter(v)); } // ReSharper disable once EmptyGeneralCatchClause catch { } return(new StringParameter(v, placement)); }