diff --git a/LayoutFunctions/ClassroomLayout/test/ClassroomLayoutTests.cs b/LayoutFunctions/ClassroomLayout/test/ClassroomLayoutTests.cs index 56130a82..a029c9e4 100644 --- a/LayoutFunctions/ClassroomLayout/test/ClassroomLayoutTests.cs +++ b/LayoutFunctions/ClassroomLayout/test/ClassroomLayoutTests.cs @@ -19,23 +19,30 @@ public class ClassroomLayoutTests [Fact] public void ClassroomConfigurations() { - // test with one room for each configuration + // Test with one room for each configuration to check that every piece of expected content exists in a room of a matching size var testName = "Configurations"; var configs = LayoutStrategies.GetConfigurations("ClassroomConfigurations.json"); + // Get the result of ClassroomLayout.Execute() var (output, spacePlanningModel) = ClassroomLayoutTest(testName); var elements = output.Model.AllElementsOfType(); + + // Get the rooms created according to the orderedKeys order var boundaries = spacePlanningModel.AllElementsOfType().Where(z => z.Name == "Classroom").OrderBy(b => b.Bounds.Center().Y).ToList(); + // Check each configuration separately for (int i = 0; i < orderedKeys.Count(); i++) { + // Confirm that the size of the room covers the size of the corresponding configuration var boundary = boundaries[i]; var config = configs.FirstOrDefault(c => c.Key == orderedKeys[i]).Value; Assert.True(config.Depth < boundary.Bounds.XSize); + // Look for all the furniture placed within the room var offsetedBox = boundary.Bounds.Offset(0.1); var boundaryElements = elements.Where(e => offsetedBox.Contains(e.Transform.Origin)).ToList(); + // Check that the room has all furniture that are in the appropriate configuration foreach (var contentItem in config.ContentItems) { var boundaryElement = boundaryElements.FirstOrDefault(be => be.Name == contentItem.Name || be.Name == contentItem.Url); @@ -44,7 +51,7 @@ public void ClassroomConfigurations() } } - // room with 3 desks + // room with 9 desks var roomWithDesks = boundaries.Last(); var offsetedBoxWithDesks = roomWithDesks.Bounds.Offset(0.1); var boundaryElementsWithDesks = elements.Where(e => offsetedBoxWithDesks.Contains(e.Transform.Origin)).ToList(); diff --git a/LayoutFunctions/LoungeLayout/test/LoungeLayoutTests.cs b/LayoutFunctions/LoungeLayout/test/LoungeLayoutTests.cs index a52188ac..2f10e482 100644 --- a/LayoutFunctions/LoungeLayout/test/LoungeLayoutTests.cs +++ b/LayoutFunctions/LoungeLayout/test/LoungeLayoutTests.cs @@ -23,23 +23,30 @@ public class LoungeLayoutTests [Fact] public void LoungeConfigurations() { - // test with one room for each configuration + // Test with one room for each configuration to check that every piece of expected content exists in a room of a matching size var testName = "Configurations"; var configs = LayoutStrategies.GetConfigurations("LoungeConfigurations.json"); + // Get the result of LoungeLayout.Execute() var (output, spacePlanningModel) = LoungeLayoutTest(testName); var elements = output.Model.AllElementsOfType(); + + // Get the rooms created according to the orderedKeys order var boundaries = spacePlanningModel.AllElementsOfType().Where(z => z.Name == "Lounge").OrderBy(b => b.Boundary.Perimeter.Center().Y).ToList(); + // Check each configuration separately for (int i = 0; i < orderedKeys.Count(); i++) { + // Confirm that the size of the room covers the size of the corresponding configuration var boundary = boundaries[i]; var config = configs.FirstOrDefault(c => c.Key == orderedKeys[i]).Value; Assert.True(config.Width < boundary.Bounds.YSize); + // Look for all the furniture placed within the room var offsetedBox = boundary.Bounds.Offset(0.1); var boundaryElements = elements.Where(e => offsetedBox.Contains(e.Transform.Origin)).ToList(); + // Check that the room has all furniture that are in the appropriate configuration foreach (var contentItem in config.ContentItems) { var boundaryElement = boundaryElements.FirstOrDefault(be => be.Name == contentItem.Name); diff --git a/LayoutFunctions/MeetingRoomLayout/test/MeetingRoomLayoutTests.cs b/LayoutFunctions/MeetingRoomLayout/test/MeetingRoomLayoutTests.cs index b4afc550..09fb2945 100644 --- a/LayoutFunctions/MeetingRoomLayout/test/MeetingRoomLayoutTests.cs +++ b/LayoutFunctions/MeetingRoomLayout/test/MeetingRoomLayoutTests.cs @@ -18,24 +18,31 @@ public class MeetingRoomLayoutTests [Fact] public void MeetingRoomConfigurations() { - // test with one room for each configuration + // Test with one room for each configuration to check that every piece of expected content exists in a room of a matching size var testName = "Configurations"; var configs = LayoutStrategies.GetConfigurations("ConferenceRoomConfigurations.json"); + // Get the result of MeetingRoomLayout.Execute() var (output, spacePlanningModel) = MeetingRoomLayoutTest(testName); var elements = output.Model.AllElementsOfType(); + + // Get the rooms created according to the orderedKeys order var boundaries = spacePlanningModel.AllElementsOfType().Where(z => z.Name == "Meeting Room").OrderBy(b => b.Boundary.Perimeter.Center().Y).ToList(); + // Check each configuration separately for (int i = 0; i < orderedKeys.Count(); i++) { + // Confirm that the size of the room covers the size of the corresponding configuration var boundary = boundaries[i]; var config = configs.FirstOrDefault(c => c.Key == orderedKeys[i]).Value; Assert.True(config.Width < boundary.Bounds.YSize); + // Look for all the furniture placed within the room var offsetedBox = boundary.Bounds.Offset(0.1); offsetedBox.Extend(new Vector3(offsetedBox.Min.X, offsetedBox.Min.Y, offsetedBox.Min.Z - 1)); var boundaryElements = elements.Where(e => offsetedBox.Contains(e.Transform.Origin)).ToList(); + // Check that the room has all furniture that are in the appropriate configuration foreach (var contentItem in config.ContentItems) { var boundaryElement = boundaryElements.FirstOrDefault(be => be.Name == contentItem.Name || be.Name == contentItem.Url); diff --git a/LayoutFunctions/OpenCollabLayout/test/OpenCollaborationLayoutTests.cs b/LayoutFunctions/OpenCollabLayout/test/OpenCollaborationLayoutTests.cs index 0f3877e8..ebf28ef5 100644 --- a/LayoutFunctions/OpenCollabLayout/test/OpenCollaborationLayoutTests.cs +++ b/LayoutFunctions/OpenCollabLayout/test/OpenCollaborationLayoutTests.cs @@ -18,23 +18,30 @@ public class OpenCollaborationLayoutTests [Fact] public void OpenCollaborationConfigurations() { + // Test with a separate "Space Planning Zones" model for each configuration + // to check that every piece of expected content exists in a room of a matching size var testName = "Configurations"; var configs = LayoutStrategies.GetConfigurations("OpenCollaborationConfigurations.json"); var levelsModel = Model.FromJson(System.IO.File.ReadAllText($"{INPUT}/{testName}/Levels.json")); var circulationModel = Model.FromJson(System.IO.File.ReadAllText($"{INPUT}/{testName}/Circulation.json")); var input = GetInput(testName); + // Check each configuration separately due to the impossibility of predicting a specific order of configurations for multiple rooms in the same building foreach (var config in configs) { + // Get the result of OpenCollaborationLayout.Execute() var (output, spacePlanningModel) = OpenCollaborationLayoutTest(testName, config.Key, levelsModel, circulationModel, input); var elements = output.Model.AllElementsOfType(); + + // Confirm that the size of the room covers the size of the corresponding configuration var boundary = spacePlanningModel.AllElementsOfType().Where(z => z.Name == "Open Collaboration").OrderBy(b => b.Boundary.Perimeter.Center().Y).First(); - Assert.True(config.Value.Depth < boundary.Bounds.XSize && config.Value.Width < boundary.Bounds.YSize); + // Look for all the furniture placed within the room var offsetedBox = boundary.Bounds.Offset(0.1); var boundaryElements = elements.Where(e => offsetedBox.Contains(e.Transform.Origin)).ToList(); + // Check that the room has all furniture that are in the appropriate configuration foreach (var contentItem in config.Value.ContentItems) { var boundaryElement = boundaryElements.FirstOrDefault(be => be.AdditionalProperties.TryGetValue("gltfLocation", out var gltfLocation) && gltfLocation.ToString() == contentItem.Url); @@ -45,9 +52,9 @@ public void OpenCollaborationConfigurations() } private (OpenCollaborationLayoutOutputs output, Model spacePlanningModel) OpenCollaborationLayoutTest( - string testName, - string configName, - Model levelsModel, + string testName, + string configName, + Model levelsModel, Model circulationModel, OpenCollaborationLayoutInputs input) { diff --git a/LayoutFunctions/OpenOfficeLayout/test/OpenOfficeLayoutTests.cs b/LayoutFunctions/OpenOfficeLayout/test/OpenOfficeLayoutTests.cs index 26ca0008..ea060065 100644 --- a/LayoutFunctions/OpenOfficeLayout/test/OpenOfficeLayoutTests.cs +++ b/LayoutFunctions/OpenOfficeLayout/test/OpenOfficeLayoutTests.cs @@ -18,6 +18,8 @@ public class OpenOfficeLayoutTests [Fact] public void OpenOfficeConfigurations() { + // Test to verify the use of all possible desk configurations with some input parameter values + // to check that every piece of expected content exists in a room of a matching desk type var testName = "Configurations"; var configs = LayoutStrategies.GetConfigurations("OpenOfficeDeskConfigurations.json"); var spacePlanningModel = Model.FromJson(System.IO.File.ReadAllText($"{INPUT}/{testName}/Space Planning Zones.json")); @@ -26,36 +28,48 @@ public void OpenOfficeConfigurations() var columnsModel = Model.FromJson(System.IO.File.ReadAllText($"{INPUT}/{testName}/Columns.json")); var input = GetInput(testName); + // Check each value of the ColumnAvoidanceStrategy parameter separately foreach (var columnAvoidanceStrategy in Enum.GetNames(typeof(OpenOfficeLayoutInputsColumnAvoidanceStrategy))) { + // Get the result of OpenOfficeLayout.Execute() var output = OpenOfficeLayoutTest(testName, columnAvoidanceStrategy, spacePlanningModel, levelsModel, circulationModel, columnsModel, input); var elements = output.Model.AllElementsAssignableFromType().Where(e => e.BaseDefinition is not Column).ToList(); + + // "Open Collaboration" type rooms located inside "Open Office" rooms var openCollabBoundaries = output.Model.AllElementsOfType().Where(b => b.Name == "Open Collaboration"); + + // Get rooms with each desk type on the Y axis, and with some variation of other input parameters on the X axis var boundaries = spacePlanningModel.AllElementsOfType().Where(b => b.Name == "Open Office").OrderBy(b => b.Boundary.Perimeter.Center().Y).ThenBy((b => b.Boundary.Perimeter.Center().X)).ToList(); + + // Get data about the expected result for each room for this ColumnAvoidanceStrategy type var expectedResults = GetTestResults(testName, columnAvoidanceStrategy.Replace("_", "")); for (int i = 0; i < boundaries.Count(); i++) { + // Verify that the configuration for the expected desk type exists var boundary = boundaries[i]; var expectedResult = expectedResults[i]; var config = configs.FirstOrDefault(c => c.Key == expectedResult.DeskType).Value; Assert.NotNull(config); + // Look for all the furniture placed within the room var offsetedBox = boundary.Bounds.Offset(0.1); offsetedBox.Min -= new Vector3(0, 0, 0.1); var boundaryElements = elements.Where(e => offsetedBox.Contains(e.Transform.Origin)).ToList(); - // Check items + // Check that the room has the required number of desks of the same type as in the configuration foreach (var contentItem in config.ContentItems) { + // check the number of desks var suitableElements = boundaryElements.Where(be => be.AdditionalProperties.TryGetValue("gltfLocation", out var gltfLocation) && gltfLocation.ToString() == contentItem.Url).ToList(); Assert.True(suitableElements.Count() >= expectedResult.Count); + // delete checked desks var expectedElements = suitableElements.SkipLast(suitableElements.Count() - expectedResult.Count); boundaryElements.RemoveAll(b => expectedElements.Contains(b)); } - // Check open collab areas + // Check that the resulting "Open Collaboration" area for this room is the same as expected var suitableCollabBoundaries = openCollabBoundaries.Where(b => boundary.Boundary.Perimeter.Contains(b.Boundary.Perimeter.Centroid())); Assert.Equal(suitableCollabBoundaries.Count(), expectedResult.CollabCount); Assert.True(suitableCollabBoundaries.Sum(b => b.Area).ApproximatelyEquals(expectedResult.CollabArea, 0.2)); @@ -64,7 +78,7 @@ public void OpenOfficeConfigurations() } private OpenOfficeLayoutOutputs OpenOfficeLayoutTest( - string testName, + string testName, string columnAvoidanceStrategyName, Model spacePlanningModel, Model levelsModel, diff --git a/LayoutFunctions/PantryLayout/test/PantryLayoutTests.cs b/LayoutFunctions/PantryLayout/test/PantryLayoutTests.cs index b7997747..2baffd4c 100644 --- a/LayoutFunctions/PantryLayout/test/PantryLayoutTests.cs +++ b/LayoutFunctions/PantryLayout/test/PantryLayoutTests.cs @@ -23,23 +23,30 @@ public class PantryLayoutTests [Fact] public void PantryConfigurations() { - // test with one room for each configuration + // Test with one room for each configuration to check that every piece of expected content exists in a room of a matching size var testName = "Configurations"; var configs = LayoutStrategies.GetConfigurations("PantryConfigurations.json"); + // Get the result of PantryLayout.Execute() var (output, spacePlanningModel) = PantryLayoutTest(testName); var elements = output.Model.AllElementsOfType(); + + // Get the rooms created according to the orderedKeys order var boundaries = spacePlanningModel.AllElementsOfType().Where(z => z.Name == "Pantry").OrderBy(b => b.Boundary.Perimeter.Center().Y).ToList(); + // Check each configuration separately for (int i = 0; i < orderedKeys.Count(); i++) { + // Confirm that the size of the room covers the size of the corresponding configuration var boundary = boundaries[i]; var config = configs.FirstOrDefault(c => c.Key == orderedKeys[i]).Value; Assert.True(config.Width < boundary.Bounds.XSize); + // Look for all the furniture placed within the room var offsetedBox = boundary.Bounds.Offset(0.02); var boundaryElements = elements.Where(e => offsetedBox.Contains(e.Transform.Origin)).ToList(); + // Check that the room has all furniture that are in the appropriate configuration foreach (var contentItem in config.ContentItems) { var boundaryElement = boundaryElements.FirstOrDefault(be => be.Name == contentItem.Name); diff --git a/LayoutFunctions/PhoneBoothLayout/test/PhoneBoothLayoutTests.cs b/LayoutFunctions/PhoneBoothLayout/test/PhoneBoothLayoutTests.cs index 9f58e48d..32ddabec 100644 --- a/LayoutFunctions/PhoneBoothLayout/test/PhoneBoothLayoutTests.cs +++ b/LayoutFunctions/PhoneBoothLayout/test/PhoneBoothLayoutTests.cs @@ -19,23 +19,30 @@ public class PhoneBoothLayoutTests [Fact] public void PhoneBoothConfigurations() { - // test with one room for each configuration + // Test with one room for each configuration to check that every piece of expected content exists in a room of a matching size var testName = "Configurations"; var configs = LayoutStrategies.GetConfigurations("PhoneBoothConfigurations.json"); + // Get the result of PhoneBoothLayout.Execute() var (output, spacePlanningModel) = PhoneBoothLayoutTest(testName); var elements = output.Model.AllElementsOfType(); + + // Get the rooms created according to the orderedKeys order var boundaries = spacePlanningModel.AllElementsOfType().Where(z => z.Name == "Phone Booth").OrderBy(b => b.Boundary.Perimeter.Center().Y).ToList(); + // Check each configuration separately for (int i = 0; i < orderedKeys.Count(); i++) { + // Confirm that the size of the room covers the size of the corresponding configuration var boundary = boundaries[i]; var config = configs.FirstOrDefault(c => c.Key == orderedKeys[i]).Value; Assert.True(config.Width < boundary.Bounds.YSize); + // Look for all the furniture placed within the room var offsetedBox = boundary.Bounds.Offset(0.1); var boundaryElements = elements.Where(e => offsetedBox.Contains(e.Transform.Origin)).ToList(); + // Check that the room has all furniture that are in the appropriate configuration foreach (var contentItem in config.ContentItems) { var boundaryElement = boundaryElements.FirstOrDefault(be => be.Name == contentItem.Name); diff --git a/LayoutFunctions/PrivateOfficeLayout/test/PrivateOfficeLayoutTests.cs b/LayoutFunctions/PrivateOfficeLayout/test/PrivateOfficeLayoutTests.cs index f387b4cd..b0fe0b3c 100644 --- a/LayoutFunctions/PrivateOfficeLayout/test/PrivateOfficeLayoutTests.cs +++ b/LayoutFunctions/PrivateOfficeLayout/test/PrivateOfficeLayoutTests.cs @@ -19,23 +19,30 @@ public class PrivateOfficeLayoutTests [Fact] public void PrivateOfficeConfigurations() { - // test with one room for each configuration + // Test with one room for each configuration to check that every piece of expected content exists in a room of a matching size var testName = "Configurations"; var configs = LayoutStrategies.GetConfigurations("PrivateOfficeConfigurations.json"); + // Get the result of PrivateOfficeLayout.Execute() var (output, spacePlanningModel) = PrivateOfficeLayoutTest(testName); var elements = output.Model.AllElementsOfType(); + + // Get the rooms created according to the orderedKeys order var boundaries = spacePlanningModel.AllElementsOfType().Where(z => z.Name == "Private Office").OrderBy(b => b.Boundary.Perimeter.Center().Y).ToList(); + // Check each configuration separately for (int i = 0; i < orderedKeys.Count(); i++) { + // Confirm that the size of the room covers the size of the corresponding configuration var boundary = boundaries[i]; var config = configs.FirstOrDefault(c => c.Key == orderedKeys[i]).Value; Assert.True(config.Width < boundary.Bounds.YSize); + // Look for all the furniture placed within the room var offsetedBox = boundary.Bounds.Offset(0.1); var boundaryElements = elements.Where(e => offsetedBox.Contains(e.Transform.Origin)).ToList(); + // Check that the room has all furniture that are in the appropriate configuration foreach (var contentItem in config.ContentItems) { var boundaryElement = boundaryElements.FirstOrDefault(be => be.Name == contentItem.Name); diff --git a/LayoutFunctions/ReceptionLayout/test/ReceptionLayoutTests.cs b/LayoutFunctions/ReceptionLayout/test/ReceptionLayoutTests.cs index a4a10287..d275b059 100644 --- a/LayoutFunctions/ReceptionLayout/test/ReceptionLayoutTests.cs +++ b/LayoutFunctions/ReceptionLayout/test/ReceptionLayoutTests.cs @@ -19,23 +19,30 @@ public class ReceptionLayoutTests [Fact] public void ReceptionConfigurations() { - // test with one room for each configuration + // Test with one room for each configuration to check that every piece of expected content exists in a room of a matching size var testName = "Configurations"; var configs = LayoutStrategies.GetConfigurations("ReceptionConfigurations.json"); + // Get the result of ReceptionLayout.Execute() var (output, spacePlanningModel) = ReceptionLayoutTest(testName); var elements = output.Model.AllElementsOfType(); + + // Get the rooms created according to the orderedKeys order var boundaries = spacePlanningModel.AllElementsOfType().Where(z => z.Name == "Reception").OrderBy(b => b.Boundary.Perimeter.Center().Y).ToList(); + // Check each configuration separately for (int i = 0; i < orderedKeys.Count(); i++) { + // Confirm that the size of the room covers the size of the corresponding configuration var boundary = boundaries[i]; var config = configs.FirstOrDefault(c => c.Key == orderedKeys[i]).Value; Assert.True(config.Width < boundary.Bounds.XSize); + // Look for all the furniture placed within the room var offsetedBox = boundary.Bounds.Offset(0.1); var boundaryElements = elements.Where(e => offsetedBox.Contains(e.Transform.Origin)).ToList(); + // Check that the room has all furniture that are in the appropriate configuration foreach (var contentItem in config.ContentItems) { var boundaryElement = boundaryElements.FirstOrDefault(be => be.Name == contentItem.Name);