public void Create_should_create_method_name_from_name() { var a = PropertyName.Create("Hello"); var b = PropertyName.Parse("Hello"); Assert.Equal(a, b); }
public void Parse_should_throw_on_errors(string text) { var ex = Record.Exception(() => PropertyName.Parse(text)); Assert.IsInstanceOf(typeof(ArgumentException), ex); Assert.Contains("instance of type `Carbonfrost.Commons.DotNet.PropertyName'", ex.Message); }
public void SetMethod_should_generate_from_property_or_indexer(string name, string expected) { var pn = PropertyName.Parse(name); var setter = MethodName.Parse(expected); Assert.Equal(setter, pn.SetMethod); }
public void Parse_should_handle_parameter_list_type_only(string name) { var pn = PropertyName.Parse(name); Assert.Equal("Chars", pn.Name); Assert.Equal(string.Empty, pn.IndexParameters[0].Name); Assert.Equal("int", pn.IndexParameters[0].ParameterType.Name); }
public void Parse_should_handle_parameter_list_type_and_name(string name) { var pn = PropertyName.Parse(name); Assert.Equal("Chars", pn.Name); Assert.Equal("int", pn.IndexParameters[0].ParameterType.Name); Assert.Equal("index", pn.IndexParameters[0].Name); Assert.Equal(0, pn.IndexParameters[0].Position); }
public void Parse_should_handle_pointer_parameter(string text) { var pn = PropertyName.Parse(text); Assert.Equal("Chars", pn.Name); Assert.Equal(1, pn.IndexParameters.Count); Assert.Equal("Int64*", pn.IndexParameters[0].ParameterType.Name); Assert.True(pn.IndexParameters[0].ParameterType.IsPointer); }
public void Parse_should_handle_anonymous_parameter_list(string name, int count) { var pn = PropertyName.Parse(name); Assert.Equal("Chars", pn.Name); Assert.Equal(count, pn.IndexParameters.Count); if (count > 0) { Assert.Equal(string.Empty, pn.IndexParameters[0].Name); Assert.Equal(null, pn.IndexParameters[0].ParameterType); } }
public void AssociatedMember_creates_property_name_semantics() { var getter = MethodName.Parse("System.Array.get_Length()"); var setter = MethodName.Parse("System.Array.set_Length(value:Int32)"); var prop = PropertyName.Parse("System.Array.Length:Int32"); Assert.Equal(prop, getter.AssociatedProperty); Assert.Equal(prop, setter.AssociatedProperty); Assert.Equal(getter, prop.GetMethod); Assert.Equal(setter, prop.SetMethod); Assert.Equal(prop, getter.AssociatedMember); Assert.Equal(prop, setter.AssociatedMember); }
public void Parse_should_handle_declaring_type() { var pn = PropertyName.Parse("System.String.Length"); Assert.Equal(TypeName.Parse("System.String"), pn.DeclaringType); }
public void Parse_should_handle_assembly() { var pn = PropertyName.Parse("System.String.Length, mscorlib, Version=1.0.0.0"); Assert.Equal(pn.Assembly.FullName, "mscorlib, Version=1.0.0.0"); }
public void Parse_assumes_that_bare_property_names_are_properties_not_indexers() { var pn = PropertyName.Parse("String.Length"); Assert.False(pn.IsIndexer); }
public void IsIndexer_should_be_false_for_simple_names(string name) { var pn = PropertyName.Parse(name); Assert.False(pn.IsIndexer); }
public void IsIndexer_should_be_implied_by_parameters(string name, bool expected) { var pn = PropertyName.Parse(name); Assert.Equal(expected, pn.IsIndexer); }
public void IsIndexer_should_be_true_for_indexer(string name) { var pn = PropertyName.Parse(name); Assert.True(pn.IsIndexer); }
public void Parse_should_handle_return_type(string name) { var pn = PropertyName.Parse(name); Assert.Equal("System.Char", pn.PropertyType.FullName); }
public void Parse(Stream hs) { NumFiles = hs.ReadDecodedUInt64(); while (true) { PropertyID propertyID = GetPropertyID(this, hs); if (propertyID == PropertyID.kEnd) { break; } FileProperty property = null; switch (propertyID) { case PropertyID.kEmptyStream: property = new PropertyEmptyStream(NumFiles); property.Parse(hs); NumEmptyStreams = (property as PropertyEmptyStream).NumEmptyStreams; break; case PropertyID.kEmptyFile: property = new PropertyEmptyFile(NumFiles, NumEmptyStreams); property.Parse(hs); break; case PropertyID.kAnti: property = new PropertyAnti(NumFiles, NumEmptyStreams); property.Parse(hs); break; case PropertyID.kCTime: case PropertyID.kATime: case PropertyID.kMTime: property = new PropertyTime(propertyID, NumFiles); property.Parse(hs); break; case PropertyID.kName: property = new PropertyName(NumFiles); property.Parse(hs); break; case PropertyID.kWinAttributes: property = new PropertyAttributes(NumFiles); property.Parse(hs); break; case PropertyID.kDummy: property = new PropertyDummy(); property.Parse(hs); break; default: throw new NotImplementedException(propertyID.ToString()); } if (property != null) { Properties.Add(property); } } }
public void Components(string text, PropertyNameComponents expected) { Assert.Equal(expected, PropertyName.Parse(text).Components); }