public void ToStringOutputCopyIsEqual() { Assert.All(SharedParameterFiles.Where(f => f.StartsWith(PathToValidFiles, StringComparison.InvariantCulture)), sharedParamFilePath => { var sharedParamFile1 = new SharedParameterFile(sharedParamFilePath); var sharedParamFile2 = new SharedParameterFile(sharedParamFile1.ToString()); Assert.True(sharedParamFile1.Equals(sharedParamFile2)); } ); }
public void FileIsSerializedProperly() { var simpleSharedFromDisk = File .ReadAllText(SharedParameterFiles.FirstOrDefault(f => f.EndsWith(@"SimpleShared_1.txt", StringComparison.InvariantCulture))); var simpleSharedFromBuilt = new SharedParameterFile(new Dictionary <string, int> { { "Identity Data", 100 } }); #region Identity Data simpleSharedFromBuilt.Parameters.Add( new Guid("61ff3d56-09d7-4049-8c78-4abe745e4e5a"), "EquipmentName", "Identity Data", // Passing group by name ParameterType.Text ); simpleSharedFromBuilt.Parameters.Add( new Guid("758c97dc-6b88-4fbd-9570-4affdc32f08d"), "EquipmentNumber", simpleSharedFromBuilt.Groups.FirstOrDefault(g => "Identity Data".Equals(g.Name)), // Finding group dynamically ParameterType.Text ); simpleSharedFromBuilt.Parameters.Add( new Guid("b5a53ea4-55d9-497c-8488-6607faa11e5f"), "EquipmentServed", new SharedParameterFile.Group("Identity Data", 100), // Creating group as object ParameterType.Text ); simpleSharedFromBuilt.Parameters.Add( new Guid("d4fa8765-86f3-4472-860c-a906aff18593"), "EquipmentType", "Identity Data", ParameterType.Text ); #endregion #region Dimensions var dimensionsGroup = new SharedParameterFile.Group("Dimensions", 101); simpleSharedFromBuilt.Parameters.Add( new Guid("90850b08-3b50-4c46-95d6-24558d1f7800"), "Depth", dimensionsGroup, ParameterType.Length ); simpleSharedFromBuilt.Parameters.Add( new Guid("00acc8ba-6168-415b-8570-0264a70a3053"), "Length", dimensionsGroup, ParameterType.Length ); simpleSharedFromBuilt.Parameters.Add( new Guid("2ceb290a-55c6-40b4-a91b-0df3681f6520"), "Width", dimensionsGroup, ParameterType.Length ); #endregion #region Electrical var electricalGroup = new SharedParameterFile.Group("Electrical", 102); simpleSharedFromBuilt.Parameters.Add( new Guid("5031db93-bb19-454e-bea4-0f77d60f15e6"), "ApparentPower", electricalGroup, ParameterType.ElectricalApparentPower ); simpleSharedFromBuilt.Parameters.Add( new Guid("963abdb6-372f-496c-b99e-f11d8e0e5d20"), "Current", electricalGroup, ParameterType.ElectricalCurrent ); simpleSharedFromBuilt.Parameters.Add( new Guid("c006d4d6-0b12-42ad-8078-fe38ab8b1eff"), "Phases", electricalGroup, ParameterType.NumberOfPoles ); simpleSharedFromBuilt.Parameters.Add( new Guid("bce04092-fe19-476a-a652-4903bb02081e"), "Power", electricalGroup, ParameterType.ElectricalPower ); simpleSharedFromBuilt.Parameters.Add( new Guid("ecebf138-86d6-4868-879c-bdc5a0b7d746"), "PowerFactor", electricalGroup, ParameterType.Number ); simpleSharedFromBuilt.Parameters.Add( new Guid("ab0a5903-6625-482f-9e6b-f3bffb38dd13"), "Voltage", electricalGroup, ParameterType.ElectricalPotential ); simpleSharedFromBuilt.Parameters.Add( new Guid("7dfc1be1-c5d2-471a-b341-7532d2d1627c"), "Wiring", "Electrical", ParameterType.Text ); #endregion #region Plumbing var plumbingGroup = new SharedParameterFile.Group("Plumbing", 103); simpleSharedFromBuilt.Parameters.Add( new Guid("99e06fdb-82cc-41fe-9fa2-9c524fec6f0f"), "Cold Water Size", plumbingGroup, ParameterType.PipeSize ); simpleSharedFromBuilt.Parameters.Add( new Guid("a0030f64-4f46-4c02-a88e-a7e72a36611c"), "Cold Water Consumption", plumbingGroup, ParameterType.PipingFlow ); simpleSharedFromBuilt.Parameters.Add( new Guid("b96ead64-4cb4-459e-aec0-787140811551"), "Cold Water Temperature", plumbingGroup, ParameterType.PipingTemperature ); simpleSharedFromBuilt.Parameters.Add( new Guid("c031fafc-ce7b-423b-84a1-b87f48f89abf"), "Hot Water Size", plumbingGroup, ParameterType.PipeSize ); simpleSharedFromBuilt.Parameters.Add( new Guid("6b2ae170-1a20-4bcc-a214-0fabb349dd8f"), "Hot Water Consumption", plumbingGroup, ParameterType.PipingFlow ); simpleSharedFromBuilt.Parameters.Add( new Guid("66b5367d-78cd-477a-9fd3-0e04f8459d5a"), "Hot Water Supply Temperature", plumbingGroup, ParameterType.PipingTemperature ); #endregion // Remove any difference in terms of line endings var simpleSharedFromBuiltText = simpleSharedFromBuilt .ToString() .Replace("\r\n", "\n").Replace("\r", "\n").Replace("\n", "\n") .TrimEnd('\n'); simpleSharedFromDisk = simpleSharedFromDisk .Replace("\r\n", "\n").Replace("\r", "\n").Replace("\n", "\n") .TrimEnd('\n'); Assert.Equal(simpleSharedFromBuiltText, simpleSharedFromDisk); }