Esempio n. 1
0
        protected override void Context()
        {
            _view                            = A.Fake <IEditTableFormulaWithOffsetFormulaView>();
            _mapper                          = A.Fake <ITableFormulaWithOffsetToTableFormulaWithOffsetDTOMapper>();
            _context                         = A.Fake <IMoBiContext>();
            _mobiFormulaTask                 = A.Fake <IMoBiFormulaTask>();
            _displayUnitRetriever            = A.Fake <IDisplayUnitRetriever>();
            _applicationController           = A.Fake <IApplicationController>();
            _selectReferencePresenterFactory = A.Fake <ISelectReferencePresenterFactory>();
            _timeDimension                   = DomainHelperForSpecs.TimeDimension;
            A.CallTo(() => _context.DimensionFactory.Dimension(Constants.Dimension.TIME)).Returns(_timeDimension);

            sut = new EditTableFormulaWithOffsetFormulaPresenter(_view, _mapper, _context, _mobiFormulaTask, _displayUnitRetriever, _applicationController, _selectReferencePresenterFactory);

            _commandCollector = A.Fake <ICommandCollector>();
            _buildingBlock    = A.Fake <IBuildingBlock>();

            sut.InitializeWith(_commandCollector);
            sut.BuildingBlock = _buildingBlock;
            _formula          = new TableFormulaWithOffset();
            _usingFormula     = new Parameter();
            _dto = new TableFormulaWithOffsetDTO();

            _selectFormulaUsablePathPresenter = A.Fake <ISelectFormulaUsablePathPresenter>();
            A.CallTo(() => _applicationController.Start <ISelectFormulaUsablePathPresenter>()).Returns(_selectFormulaUsablePathPresenter);

            _selectReferenceAtParameterPresenter = A.Fake <ISelectReferenceAtParameterPresenter>();
            A.CallTo(_selectReferencePresenterFactory).WithReturnType <ISelectReferenceAtParameterPresenter>().Returns(_selectReferenceAtParameterPresenter);

            A.CallTo(() => _selectFormulaUsablePathPresenter.Init(A <Func <IObjectBase, bool> > ._, _usingFormula, A <IEnumerable <IObjectBase> > ._, A <string> ._, _selectReferenceAtParameterPresenter))
            .Invokes(x => _predicate = x.GetArgument <Func <IObjectBase, bool> >(0));
        }
 protected override void Context()
 {
     _oldPath                = A.Fake <IFormulaUsablePath>();
     _oldPath.Alias          = AppConstants.TABLE_ALIAS;
     _tableFormulaWithOffset = new TableFormulaWithOffset();
     _tableFormulaWithOffset.AddTableObjectPath(_oldPath);
     _context = A.Fake <IMoBiContext>();
     sut      = new ChangeTableFormulaWithOffsetTableObjectPathCommand(_tableFormulaWithOffset, null, A.Fake <IBuildingBlock>());
 }
Esempio n. 3
0
        protected override void Context()
        {
            base.Context();
            _equalFormula1 = new TableFormulaWithOffset().WithName("Equal");
            _equalFormula2 = new TableFormulaWithOffset().WithName("Equal");
            var offsetObjectPath = new FormulaUsablePath(new[] { "X" }).WithAlias("Offset");

            _equalFormula1.AddOffsetObjectPath(offsetObjectPath);
            _equalFormula2.AddOffsetObjectPath(offsetObjectPath);
            var tableObjectPath = new FormulaUsablePath(new[] { "Y" }).WithAlias("Table");

            _equalFormula1.AddTableObjectPath(tableObjectPath);
            _equalFormula2.AddTableObjectPath(tableObjectPath);

            _unequalFormula = new TableFormulaWithOffset().WithName("Equal");
            _unequalFormula.AddOffsetObjectPath(new FormulaUsablePath(new[] { "A" }).WithAlias("Offset"));
            _unequalFormula.AddTableObjectPath(new FormulaUsablePath(new[] { "B" }).WithAlias("Table"));
        }
Esempio n. 4
0
        public TableFormulaWithOffsetDTO MapFrom(TableFormulaWithOffset tableFormulaWithOffset)
        {
            var dto = Map <TableFormulaWithOffsetDTO>(tableFormulaWithOffset);

            var offsetPath = getPathByAlias(tableFormulaWithOffset, tableFormulaWithOffset.OffsetObjectAlias);

            if (offsetPath != null)
            {
                dto.OffsetObjectPath = _mapper.MapFrom(offsetPath, tableFormulaWithOffset);
            }

            var tableObjectPath = getPathByAlias(tableFormulaWithOffset, tableFormulaWithOffset.TableObjectAlias);

            if (tableObjectPath != null)
            {
                dto.TableObjectPath = _mapper.MapFrom(tableObjectPath, tableFormulaWithOffset);
            }

            return(dto);
        }
Esempio n. 5
0
 private static IFormulaUsablePath getPathByAlias(TableFormulaWithOffset input, string pathAlias)
 {
     return(input.ObjectPaths.SingleOrDefault(x => x.Alias.Equals(pathAlias)));
 }
Esempio n. 6
0
        public IMoBiCommand ChangeTableObject(TableFormulaWithOffset formula, IFormulaUsablePath path, IBuildingBlock buildingBlock)
        {
            var command = new ChangeTableFormulaWithOffsetTableObjectPathCommand(formula, path, buildingBlock).Run(_context);

            return(withUpdatedDefaultStateAndValueOrigin(command, formula, buildingBlock));
        }
 public bool AreEqualTableFormulaWithOffset(TableFormulaWithOffset formula, TableFormulaWithOffset allreadyUsedFormula)
 {
     return(areEqualObjectPathCollection(formula.ObjectPaths, allreadyUsedFormula.ObjectPaths));
 }