public void EnumSize(ModelValueType baseType, int expectedSize) { // Arrange var model = new ClassModel("Dummy"); model.Properties.Add(new PropertyModel("Enum") { ElementType = "SomeEnum", ValueType = ModelValueType.Class, Attributes = new List <AttributeModel> { new AttributeModel("DataMember") } }); model.References = new List <CodeElementModel> { new EnumModel("SomeEnum") { BaseType = baseType } }; // Act var size = BinarySize.OfClass(model, new BinarySerializer()); // Assert Assert.AreEqual(expectedSize, size); }
public void CollectionSizes() { // Arrange var model = new ClassModel("Dummy"); model.Properties.Add(new PropertyModel("Dim1") { IsCollection = true, CollectionType = "List", Dimensions = 1, Attributes = new List <AttributeModel> { new AttributeModel("DataMember") } }); model.Properties.Add(new PropertyModel("Dim2") { IsCollection = true, CollectionType = "Array", Dimensions = 2, Attributes = new List <AttributeModel> { new AttributeModel("DataMember") } }); // Act var size = BinarySize.OfClass(model, new BinarySerializer()); // Assert Assert.AreEqual(6, size); }
public void ValueTypeSize(ModelValueType type, int expectedSize) { // Arrange var model = new ClassModel("Dummy"); model.Properties.Add(new PropertyModel("Property") { ValueType = type, ElementType = type.ToString("G"), Attributes = new List <AttributeModel> { new AttributeModel("DataMember") } }); // Act var size = BinarySize.OfClass(model, new BinarySerializer()); // Assert Assert.AreEqual(expectedSize, size); }
public CollectionMemberContext(T collection, TMember value, Int32 index, BinaryOffset position, BinarySize length) : base(collection, value, position, length) { Index = index; }
public IMemberBuilder <T, TMember> SizeOf(BinarySize size) { return(SizeOf(c => size)); }
public Context(T o, BinaryOffset position, BinarySize length) { StreamPosition = position; Object = o; StreamLength = length; }
public MemberContext(T o, TMember value, BinaryOffset position, BinarySize length) : base(o, position, length) { Value = value; }
public ISkippedMemberBuilder <T, TMember> SizeOf(BinarySize sizeInBytes) { return(SizeOf(context => sizeInBytes)); }