public void SetUp() { _modelLoader = Substitute.For <ILoadModel>(); _modelSaver = Substitute.For <ISaveModel>(); _apiClient = Substitute.For <IApiClient>(); _sut = new CurrentSupplyController(_modelLoader, _modelSaver, _apiClient); _currentSuppliesResourceJson = GetCurrentSuppliesJson(); _resourceBuilder = new ResourceBuilder() .WithDataTemplate() .WithGroup("includedFuels") .WithItem("compareGas") .WithItem("compareElec") .WithGroup("gasTariff") .WithItem("supplier") .WithItem("supplierTariff") .WithItem("paymentMethod") .WithGroup("elecTariff") .WithItem("supplier") .WithItem("supplierTariff") .WithItem("paymentMethod") .WithItem("economy7") .WithLinkedData("/rels/domestic/current-supplies", CurrentSuppliesUri); }
public void SetUp() { var response = Substitute.For <IResponse>(); response.GetNextUrl().Returns("next-url"); _modelLoader = Substitute.For <ILoadModel>(); _modelSaver = Substitute.For <ISaveModel>(); _resource = new ResourceBuilder() .WithDataTemplate() .WithGroup("tariffFilterOptions") .WithItem("tariffFilterOption") .WithGroup("resultsOrder") .WithItem("resultsOrder") .WithGroup("limitToPaymentType") .WithItem("paymentMethod") .Build(); _viewModel = new PreferencesViewModel { PreferencesUri = _url, PaymentMethod = _paymentMethod, ResultsOrder = _resultOrders, TariffFilterOption = _tariffFilterOption }; _model = new PreferencesModel(_resource); _modelLoader.Load <Resource, PreferencesModel>(_viewModel.PreferencesUri).Returns(_model); _modelSaver.Save(_model).Returns(response); _sut = new PreferencesController(_modelLoader, _modelSaver); }
public void SetUp() { _modelLoader = Substitute.For <ILoadModel>(); _modelSaver = Substitute.For <ISaveModel>(); _futureSuppliesResourceBuilder = new FutureSuppliesResourceBuilder(); _futureSupplyResourceBuilder = new ResourceBuilder() .WithLinkedData("/rels/domestic/future-supplies", _futureSuppliesUri); _sut = new FutureSupplyController(_modelLoader, _modelSaver); }
public void SetUp() { _futureTariffDetail = new FutureTariffDetail { Supplies = new[] { new FutureTariffDetailsSupply() } }; _apiClientStub = Substitute.For <IApiClient>(); _apiClientStub.GetAsync <FutureTariffDetail>(Url).Returns(_futureTariffDetail); _modelLoader = new ModelRepository(_apiClientStub, Substitute.For <IConfiguration>()); _futureTariffDetailsController = new FutureTariffDetailsController(_modelLoader); }
public void SetUp() { _resource = new ResourceBuilder() .WithDataTemplate() .WithGroup("gasContractDetails") .WithItem("expiryDate") .WithGroup("elecContractDetails") .WithItem("expiryDate") .Build(); _model = new ContractExpiryDateModel(_resource); _modelLoader = Substitute.For <ILoadModel>(); _modelSaver = Substitute.For <ISaveModel>(); _modelLoader.Load <Resource, ContractExpiryDateModel>(_uri).Returns(_model); _sut = new ContractExpiryDateController(_modelLoader, _modelSaver); }
public void SetUp() { _resource = new ResourceBuilder() .WithDataTemplate() .WithGroup("electricityRegion") .WithItem("region") .WithData("1") .Build(); _model = new RegionModel(_resource); _loader = Substitute.For <ILoadModel>(); _loader.Load <Resource, RegionModel>(_regionUri).Returns(_model); _saver = Substitute.For <ISaveModel>(); _controller = new RegionController(_loader, _saver); }
public void SetUp() { _modelLoader = Substitute.For <ILoadModel>(); _modelSaver = Substitute.For <ISaveModel>(); _viewModel = new PrepareForTransferViewModel { PrepareForTransferUri = "prepare-for-transfer-uri", CallbackUri = "callback url", ThankYouUri = "thankyou url" }; _resourceBuilder = new ResourceBuilder() .WithDataTemplate() .WithGroup("returnURLs") .WithItem("thankYou") .WithItem("callback"); _sut = new PrepareForTransferController(_modelLoader, _modelSaver); }
public void addLoadModel(ILoadModel loadModel) { LoadModels.Add(loadModel); }
public RegionController(ILoadModel loader, ISaveModel saver) { _loader = loader; _saver = saver; }
public FutureSupplyController(ILoadModel modelLoader, ISaveModel modelSaver) { _modelLoader = modelLoader; _modelSaver = modelSaver; }
public ContractExpiryDateController(ILoadModel modelLoader, ISaveModel modelSaver) { _modelLoader = modelLoader; _modelSaver = modelSaver; }
public PrepareForTransferController(ILoadModel modelLoader, ISaveModel modelSaver) { _modelLoader = modelLoader; _modelSaver = modelSaver; }
public CurrentUsageController(ILoadModel modelLoader, ISaveModel modelSaver) { _modelLoader = modelLoader; _modelSaver = modelSaver; }
public void SetUp() { _resource = new ResourceBuilder() .WithDataTemplate() .WithGroup("gasUsageType") .WithItem("usageType") .WithGroup("gasSimpleEstimate") .WithItem("simpleEstimate") .WithData("default-gas-simple-estimate") .WithGroup("elecUsageType") .WithItem("usageType") .WithGroup("elecSimpleEstimate") .WithItem("simpleEstimate") .WithData("default-electricity-simple-estimate") .WithGroup("gasDetailedEstimate") .WithItem("houseType") .WithItem("numberOfBedrooms") .WithItem("mainCookingSource") .WithItem("cookingFrequency") .WithItem("centralHeating") .WithItem("numberOfOccupants") .WithItem("insulation") .WithItem("energyUsage") .WithGroup("elecDetailedEstimate") .WithItem("houseType") .WithItem("numberOfBedrooms") .WithItem("mainCookingSource") .WithItem("cookingFrequency") .WithItem("centralHeating") .WithItem("numberOfOccupants") .WithItem("insulation") .WithItem("energyUsage") .WithGroup("gasSpend") .WithItem("usageAsSpend") .WithGroup("elecSpend") .WithItem("usageAsSpend") .WithGroup("gasKWhUsage") .WithItem("usageAsKWh") .WithGroup("elecKWhUsage") .WithItem("usageAsKWh") .WithGroup("economy7") .WithItem("nightUsagePercentage") .WithGroup("includedFuels") .WithItem("compareGas") .WithData("False") .WithItem("compareElec") .WithData("False") .Build(); var response = Substitute.For <IResponse>(); response.GetNextUrl().Returns("next-url"); _viewModel = new CurrentUsageViewModel { CurrentUsageUri = _uri, ElectricityUsageSimpleEstimator = "electrcicitySimpleEstimateValue", GasUsageSimpleEstimator = "gasSimpleEstimateValue", }; _modelLoader = Substitute.For <ILoadModel>(); _modelSaver = Substitute.For <ISaveModel>(); var model = new CurrentUsageModel(_resource); _modelLoader.Load <Resource, CurrentUsageModel>(_viewModel.CurrentUsageUri).Returns(model); _modelSaver.Save(model).Returns(response); _sut = new CurrentUsageController(_modelLoader, _modelSaver); }
public FutureTariffDetailsController(ILoadModel modelLoader) { _modelLoader = modelLoader; }
public HomeController(ILoadModel modelLoader, ISaveModel modelSaver, IConfiguration configuration) { _modelSaver = modelSaver; _modelLoader = modelLoader; _apiEntryPoint = configuration.GetValue <string>("ApiEntryPoint"); }
private static Result createVisualizationSheets(UIDocument uiDoc, BuildingLoadModel buildingLoadModel, IEnumerable <ILoadModel> levelLiveLoadPerSquareFoots) { //Setup Document _doc = uiDoc.Document; double _concreteDensityPoundsForcePerCubicFoot = 153.0; XYZ _capacityViewCoordinate = new XYZ(2.17649771769026, 0.766954561856788, 0); XYZ _combinedViewCoordinate = new XYZ(0.780872717690263, 0.766954561856788, 0); XYZ _demandViewCoordinate = new XYZ(0.780872717690263, 1.83481042377296, 0); var _levels = Getters.GetLevels(_doc).OrderByDescending(p => p.Elevation).ToList(); var _floors = Getters.GetFloors(_doc).OrderBy(p => p.get_BoundingBox(null)?.Max.Z).ToList(); var _structuralColumns = new FilteredElementCollector(_doc).OfCategory(BuiltInCategory.OST_StructuralColumns).OfType <FamilyInstance>().OrderBy(p => p.get_BoundingBox(null)?.Max.Z).ToList(); var _structuralFraming = new FilteredElementCollector(_doc).OfCategory(BuiltInCategory.OST_StructuralFraming).OfType <FamilyInstance>().OrderBy(p => p.get_BoundingBox(null)?.Max.Z).ToList(); var _walls = new FilteredElementCollector(_doc).OfClass(typeof(Wall)).OfType <Wall>().OrderBy(p => p.get_BoundingBox(null)?.Max.Z).ToList(); BoundingBoxXYZ _modelExtents = GeometryHelpers.GetElementsBBox( new FilteredElementCollector(_doc).WhereElementIsViewIndependent().WhereElementIsNotElementType().ToList()); _modelExtents.Min = new XYZ(_modelExtents.Min.X, _modelExtents.Min.Y, _levels.LastOrDefault().Elevation - 1.0); Category _directShapeCategory = Category.GetCategory(_doc, BuiltInCategory.OST_GenericModel); Level _levelAbove = null; Level _bottomLevel = _levels.LastOrDefault(); Level _topLevel = _levels.FirstOrDefault(); //Begin to generate our VisualizationDeliverables - these are sheets with 3 plan-orientation isometric views. // NOTE - isometric views were used so that semi-transparent color overrides can be overlayed over each other to represent demands vs capacities // ToDo: it would be valuable to scale transparency by percentage of overall demand/capacity List <VisualizationDeliverable> _visualizationDeliverables = new List <VisualizationDeliverable>(); foreach (Level _level in _levels) { if (_levelAbove == null) { _levelAbove = _level; } //Get the elements that are on our current Level List <Floor> _currentLevelFloors = _floors.Where(p => p.LevelId == _level.Id).ToList(); List <FamilyInstance> _currentLevelStructuralColumns = new List <FamilyInstance>(); List <FamilyInstance> _currentLevelStructuralFraming = new List <FamilyInstance>(); List <Wall> _currentLevelWalls = new List <Wall>(); BoundingBoxXYZ _levelBounds = new BoundingBoxXYZ { Min = new XYZ(_modelExtents.Min.X, _modelExtents.Min.Y, _level.Elevation), Max = new XYZ(_modelExtents.Max.X, _modelExtents.Max.Y, _levelAbove.Elevation) }; BoundingBoxIsInsideFilter _withinLevelBoundsFilter = new BoundingBoxIsInsideFilter(new Outline(_levelBounds.Min, _levelBounds.Max)); BoundingBoxIntersectsFilter _intersectsLevelBoundsFilter = new BoundingBoxIntersectsFilter(new Outline(_levelBounds.Min, _levelBounds.Max)); if (_structuralColumns.Count > 0) { _currentLevelStructuralColumns = new FilteredElementCollector(_doc, _structuralColumns.Select(p => p.Id).ToList()).WherePasses(_intersectsLevelBoundsFilter).OfType <FamilyInstance>().ToList(); } else { _currentLevelStructuralColumns = new List <FamilyInstance>(); } if (_structuralFraming.Count > 0) { _currentLevelStructuralFraming = new FilteredElementCollector(_doc, _structuralFraming.Select(p => p.Id).ToList()).WherePasses(_withinLevelBoundsFilter).OfType <FamilyInstance>().ToList(); } else { _currentLevelStructuralFraming = new List <FamilyInstance>(); } if (_walls.Count > 0) { _currentLevelWalls = new FilteredElementCollector(_doc, _walls.Select(p => p.Id).ToList()).WherePasses(_withinLevelBoundsFilter).OfType <Wall>().ToList(); } else { _currentLevelWalls = new List <Wall>(); } //Generate LoadModels to populate a full LevelLoadModel LevelLoadModel _currentLevelLoadModel = LevelLoadModel.Create(_level); foreach (Floor _floor in _currentLevelFloors) { //The "top" floor is where the initial Demand is determined, which is to be supported via reshores propagating down through the building //ToDo: it would be valuable to be able to pick which Level to start from if (_level.Id == _topLevel.Id) { Parameter _floorThicknessParameter = _floor.get_Parameter(BuiltInParameter.FLOOR_ATTR_THICKNESS_PARAM); double _floorThickness = _floorThicknessParameter == null ? 0.0 : _floorThicknessParameter.AsDouble(); _currentLevelLoadModel.addFloorDemandLoadModel(_floor, _concreteDensityPoundsForcePerCubicFoot * _floorThickness); } //Add loads from other sources that are also distributed evenly along a level ILoadModel _floorCapacityLoadModel = levelLiveLoadPerSquareFoots.FirstOrDefault(p => p.Name == _level.Name); if (_floorCapacityLoadModel == null) { continue; } List <LoadModel> _floorLoadModels = _currentLevelLoadModel.addFloorCapacityLoadModel(_floor, _floorCapacityLoadModel.PoundsForcePerSquareFoot); foreach (ILoadModel _loadModel in levelLiveLoadPerSquareFoots.Where(p => p.Name.Equals(_level.Name))) { List <ILoadModel> _otherLoadModels = new List <ILoadModel>(); foreach (LoadModel _floorLoadModel in _floorLoadModels) { LoadModel _otherLoadModel = LoadModel.Create(); _otherLoadModel.Name = _loadModel.Name; _otherLoadModel.LoadType = _loadModel.LoadType; _otherLoadModel.PoundsForcePerSquareFoot = _loadModel.PoundsForcePerSquareFoot; _otherLoadModel.AreaSquareFeetXY = _floorLoadModel.AreaSquareFeetXY; _otherLoadModel.HeightFeetZ = _floorLoadModel.HeightFeetZ; _otherLoadModel.OriginXFeet = _floorLoadModel.OriginXFeet; _otherLoadModel.OriginYFeet = _floorLoadModel.OriginYFeet; _otherLoadModel.Curves = _floorLoadModel.Curves; _otherLoadModel.PlanarFace = _floorLoadModel.PlanarFace; _otherLoadModel.Element = _floorLoadModel.Element; _currentLevelLoadModel.addLoadModel(_otherLoadModel); } } } foreach (FamilyInstance _structuralColumn in _currentLevelStructuralColumns) { _currentLevelLoadModel.addFamilyInstanceLoadModel(_structuralColumn, LoadType.Demand, buildingLoadModel.StructuralColumnWeightPerSquareFoot); _currentLevelLoadModel.addFamilyInstanceLoadModel(_structuralColumn, LoadType.Capacity, buildingLoadModel.StructuralColumnWeightPerSquareFoot); } foreach (FamilyInstance _structuralFrame in _currentLevelStructuralFraming) { _currentLevelLoadModel.addFamilyInstanceLoadModel(_structuralFrame, LoadType.Demand, buildingLoadModel.StructuralBeamWeightPerSquareFoot); } foreach (Wall _wall in _currentLevelWalls) { _currentLevelLoadModel.addWallLoadModel(_wall, LoadType.Demand, buildingLoadModel.StructuralWallWeightPerSquareFoot); _currentLevelLoadModel.addWallLoadModel(_wall, LoadType.Capacity, buildingLoadModel.StructuralWallWeightPerSquareFoot); } //Set the Solid elements that we will project through the building, to represent demands/capacities LoadModel.SetSolids(_currentLevelLoadModel.LoadModels.OfType <LoadModel>(), _level, _topLevel, _bottomLevel); VisualizationDeliverable _visualizationDeliverable = new VisualizationDeliverable(_currentLevelLoadModel) { Floors = _currentLevelFloors, StructuralColumns = _currentLevelStructuralColumns, StructuralFraming = _currentLevelStructuralFraming, Walls = _currentLevelWalls, }; _visualizationDeliverables.Add(_visualizationDeliverable); _levelAbove = _level; } //Now that we've gathered all of our LoadModels, let's read the data about their actual demands/capacities buildingLoadModel.LevelLoadModels = _visualizationDeliverables.Select(p => p.LevelLoadModel as ILevelLoadModel).Where(p => p != null).ToList(); buildingLoadModel.ReadLoads(); foreach (LoadModel _loadModel in _visualizationDeliverables.Select(p => p.LevelLoadModel).SelectMany(p => p.LoadModels)) { _loadModel.SetDirectShapeWithParameters(_doc, _directShapeCategory.Id, _loadModel.Name); } //Update Levels in the model with Load details foreach (LevelLoadModel _levelLoadModel in _visualizationDeliverables.Select(p => p.LevelLoadModel)) { _levelLoadModel.SetLevelParameters(); } //Color our active View for the visualization colorActiveView(_doc, _visualizationDeliverables); //ToDo: something happened which broke colors being correctly applied to these sheets - will need to sort this out //createSheetsAndViews(_doc, _visualizationDeliverables, _modelExtents); // //colorViews(_doc, _visualizationDeliverables); // //createViewports(_doc, _visualizationDeliverables, _capacityViewCoordinate, _combinedViewCoordinate, _demandViewCoordinate); return(Result.Succeeded); }
public PreferencesController(ILoadModel modelLoader, ISaveModel modelSaver) { _modelLoader = modelLoader; _modelSaver = modelSaver; }
public CurrentSupplyController(ILoadModel modelLoader, ISaveModel modelSaver, IApiClient apiClient) { _modelLoader = modelLoader; _modelSaver = modelSaver; _apiClient = apiClient; }
public SwitchController(ILoadModel modelLoader) { _modelLoader = modelLoader; }