public void TestFieldStruct() { var model = new SharpRemote.TypeModel(); var type = model.Add <FieldStruct>(); type.AssemblyQualifiedName.Should().Be(typeof(FieldStruct).AssemblyQualifiedName); type.SerializationType.Should().Be(SerializationType.ByValue); type.Properties.Should().BeEmpty("because the type doesn't have any properties"); type.Methods.Should().BeEmpty("because the methods of DataContract types are uninteresting"); type.IsClass.Should().BeFalse("because the type is a struct"); type.IsEnum.Should().BeFalse("because the type is a struct"); type.IsValueType.Should().BeTrue("because the type is a struct"); type.IsInterface.Should().BeFalse("because the type is a struct"); type.IsSealed.Should().BeTrue("because structs are always sealed"); type.Fields.Should().HaveCount(3); var field1 = type.Fields[0]; field1.Name.Should().Be(nameof(FieldStruct.A)); field1.FieldType.AssemblyQualifiedName.Should().Be(typeof(double).AssemblyQualifiedName); field1.FieldType.SerializationType.Should().Be(SerializationType.ByValue); field1.FieldType.IsBuiltIn.Should().BeTrue(); ((FieldDescription)field1).FieldTypeId.Should().Be(model.GetId <double>()); var field2 = type.Fields[1]; field2.Name.Should().Be(nameof(FieldStruct.B)); field2.FieldType.AssemblyQualifiedName.Should().Be(typeof(int).AssemblyQualifiedName); field2.FieldType.SerializationType.Should().Be(SerializationType.ByValue); field2.FieldType.IsBuiltIn.Should().BeTrue(); ((FieldDescription)field2).FieldTypeId.Should().Be(model.GetId <int>()); var field3 = type.Fields[2]; field3.Name.Should().Be(nameof(FieldStruct.C)); field3.FieldType.AssemblyQualifiedName.Should().Be(typeof(string).AssemblyQualifiedName); field3.FieldType.SerializationType.Should().Be(SerializationType.ByValue); field3.FieldType.IsBuiltIn.Should().BeTrue(); ((FieldDescription)field3).FieldTypeId.Should().Be(model.GetId <string>()); model.Types.Should().Contain(new object[] { type, //< FieldStruct field1.FieldType, //< double field2.FieldType, //< int field3.FieldType //< string }); }
public void TestAddVoid() { var model = new SharpRemote.TypeModel(); var description = model.Add(typeof(void)); description.Should().NotBeNull(); description.AssemblyQualifiedName.Should().Be(typeof(void).AssemblyQualifiedName); ((TypeDescription)description).Id.Should().BeGreaterThan(0); model.GetId(typeof(void)).Should().Be(((TypeDescription)description).Id); model.Types.Should().Contain((TypeDescription)description); }
public void TestAddIVoidMethodNoParameters() { var model = new SharpRemote.TypeModel(); var description = model.Add <IVoidMethodNoParameters>(assumeByReference: true); description.Should().NotBeNull(); description.AssemblyQualifiedName.Should().Be(typeof(IVoidMethodNoParameters).AssemblyQualifiedName); description.Methods.Should().HaveCount(1); var method = description.Methods[0]; method.Should().NotBeNull(); method.Parameters.Should().HaveCount(0); var returnParameter = method.ReturnParameter; returnParameter.ParameterType.Should().NotBeNull(); returnParameter.ParameterType.Type.Should().Be(typeof(void)); model.Contains(typeof(void)).Should().BeTrue(); model.GetId(typeof(void)).Should().Be(((TypeDescription)returnParameter.ParameterType).Id); }