private IFigure Figure_Compilation_Helper_Test(Figure str, PropertiesOnlyModel fom) { IFigure rts = str.Combine(); fom.Id = 202; rts[0] = 202; Assert.Equal(fom.Id, rts[0]); rts["Id"] = 404; Assert.NotEqual(fom.Id, rts[nameof(fom.Id)]); rts[nameof(fom.Name)] = fom.Name; Assert.Equal(fom.Name, rts[nameof(fom.Name)]); rts.SerialCode = new Ussn(DateTime.Now.ToBinary()); string hexTetra = rts.SerialCode.ToString(); Ussn ssn = new Ussn(hexTetra); Assert.Equal(ssn, rts.SerialCode); for (int i = 1; i < str.Rubrics.Count; i++) { var r = str.Rubrics[i].RubricInfo; if (r.MemberType == MemberTypes.Field) { var fi = fom.GetType().GetField(((FieldInfo)r).Name); if (fi != null) { rts[r.Name] = fi.GetValue(fom); } } if (r.MemberType == MemberTypes.Property) { var pi = fom.GetType().GetProperty(((PropertyInfo)r).Name); if (pi != null) { rts[r.Name] = pi.GetValue(fom); } } } for (int i = 1; i < str.Rubrics.Count; i++) { var r = str.Rubrics[i].RubricInfo; if (r.MemberType == MemberTypes.Field) { var fi = fom.GetType().GetField(((FieldInfo)r).Name); if (fi != null) { Assert.Equal(rts[r.Name], fi.GetValue(fom)); } } if (r.MemberType == MemberTypes.Property) { var pi = fom.GetType().GetProperty(((PropertyInfo)r).Name); if (pi != null) { Assert.Equal(rts[r.Name], pi.GetValue(fom)); } } } return(rts); }
public void Figure_MemberRubric_PropertiesOnlyModel_Compilation_Test() { Figure referenceType = new Figure(FigureMocks.Figure_MemberRubric_PropertiesOnlyModel(), "Figure_MemberRubric_PropertiesOnlyModel_Reference"); PropertiesOnlyModel fom = new PropertiesOnlyModel(); IFigure figureA = Figure_Compilation_Helper_Test(referenceType, fom); Figure valueType = new Figure(FigureMocks.Figure_MemberRubric_PropertiesOnlyModel(), "Figure_MemberRubric_PropertiesOnlyModel_ValueType", FigureMode.ValueType); fom = new PropertiesOnlyModel(); IFigure figureB = Figure_Compilation_Helper_Test(valueType, fom); }