protected override void Context() { base.Context(); _relatedItem = new RelatedItem { Name = "Sim" }; _journalPage.AddRelatedItem(_relatedItem); A.CallTo(_dialogCreator).WithReturnType <ViewResult>().Returns(ViewResult.No); }
protected override void Context() { base.Context(); A.CallTo(() => _journalSessionConnector.IsConnected).Returns(true); _objectBase = A.Fake <IObjectBase>(); _relatedItem = new RelatedItem(); A.CallTo(() => _relatedItemFactory.Create(_objectBase)).Returns(_relatedItem); _journal.Edited = _journalPage; }
protected override void Context() { base.Context(); sut.FileLength = s => 2 * Constants.RELATIVE_ITEM_FILE_SIZE_WARNING_THRESHOLD_IN_BYTES; A.CallTo(_dialogCreator).WithReturnType <string>().Returns(_fileName); A.CallTo(() => _dialogCreator.MessageBoxYesNo(A <string> ._)).Returns(ViewResult.Yes); _relatedItem = new RelatedItem(); A.CallTo(() => _relatedItemFactory.CreateFromFile(_fileName)).Returns(_relatedItem); }
protected override void Context() { base.Context(); _relatedItem = new RelatedItem().WithId("relatedItem"); _relatedItemNode = A.Fake <IRelatedItemNode>().WithId("relatedItem"); _journalPage = new JournalPage(); _journalPage.AddRelatedItem(_relatedItem); _journal.AddJournalPage(_journalPage); }
public void StartComparison(RelatedItem firstItem, RelatedItem secondItem) { if (!loadContent(firstItem)) { return; } var firstRelatedObject = _relatedItemSerializer.Deserialize(firstItem); StartComparison(firstRelatedObject, secondItem); }
protected override void Context() { base.Context(); _relatedItem = new RelatedItem(); A.CallTo(() => _databaseMediator.ExecuteCommand(A <AddRelatedPageToJournalPage> ._)) .Invokes(x => _payload = x.GetArgument <AddRelatedPageToJournalPage>(0)); A.CallTo(() => _eventPublisher.PublishEvent(A <JournalPageUpdatedEvent> ._)) .Invokes(x => _event = x.GetArgument <JournalPageUpdatedEvent>(0)); }
public SuperToolTip ToolTipFor(RelatedItem relatedItem) { var toolTip = CreateToolTip(relatedItem.Display, Captions.Journal.RelatedItem, withIcon: relatedItem); if (relatedItem.IsFile) { return(toolTip); } return(AddSubItemTo(toolTip, Captions.Journal.Project, relatedItem.FullPath)); }
protected override void Context() { base.Context(); _relatedItem = new RelatedItem(); _relatedItem2 = new RelatedItem(); _journalPage.AddRelatedItem(_relatedItem); _journalPage.AddRelatedItem(_relatedItem2); _journal = new Core.Journal.Journal(); _journal.AddJournalPage(_journalPage); A.CallTo(() => _dialogCreator.MessageBoxYesNo(Captions.Journal.ReallyDeleteMultipleRelatedItems, ViewResult.Yes)).Returns(ViewResult.Yes); }
public void AddRelatedItemTo(JournalPage journalPage, RelatedItem relatedItem) { if (relatedItem == null) { return; } _databaseMediator.ExecuteCommand(new AddRelatedPageToJournalPage { JournalPage = journalPage, RelatedItem = relatedItem }); journalPage.AddRelatedItem(relatedItem); _eventPublisher.PublishEvent(new JournalPageUpdatedEvent(journalPage)); }
protected override void Context() { base.Context(); A.CallTo(() => _journalSessionConnector.IsConnected).Returns(true); _objectBase = A.Fake <IObjectBase>(); _relatedItem = new RelatedItem(); A.CallTo(() => _relatedItemFactory.Create(_objectBase)).Returns(_relatedItem); A.CallTo(() => _journalPageFactory.Create()).Returns(_journalPage); _journal.Edited = null; A.CallTo(() => _databaseMediator.ExecuteCommand(A <CreateJournalPage> ._)) .Invokes(x => _payload = x.GetArgument <CreateJournalPage>(0)); }
private void addRelatedItem(JournalPageNode journalPageNode, RelatedItem item, RelatedItemNode lowestRelatedItemNode) { var relatedItemNode = DiagramModel.GetNode <RelatedItemNode>(item.Id); if (relatedItemNode == null) { relatedItemNode = DiagramModel.CreateNode <RelatedItemNode>(item.Id, journalPageNode.GetNextRelatedItemLocation(lowestRelatedItemNode), DiagramModel); } relatedItemNode.SetColorFrom(DiagramOptions.DiagramColors); linkRelatedNodes(journalPageNode, relatedItemNode); relatedItemNode.UpdateAttributesFromItem(item); relatedItemNode.ToolTipText = _toolTipCreator.GetToolTipFor(item); }
protected override void LoadOwnContent(RelatedItem relatedItem) { try { var relatedItemObject = _relatedItemSerializer.Deserialize(relatedItem); this.Visit(relatedItemObject); } catch (NotUniqueIdException) { //Probably trying to load an object that was already loaded. Show a message to the user throw new OSPSuiteException(AppConstants.Exceptions.CannotLoadRelatedItemAsObjectAlreadyExistInProject(relatedItem.ItemType, relatedItem.Name)); } }
public void StartComparisonFor(RelatedItem relatedItem) { _relatedItem = relatedItem; var allComparableItems = _applicationDiscriminator.AllFor(relatedItem.Discriminator); if (!allComparableItems.Any()) { _view.ShowWarning(Captions.Journal.NoObjectAvailableForComparison(relatedItem.ItemType)); return; } bindTo(allComparableItems); }
public virtual void Load(XElement componentElement) { if (componentElement == null) { return; } foreach (XAttribute attribute in componentElement.Attributes()) { SerializableProperty property = null; if (!properties.TryGetValue(attribute.Name.ToString().ToLowerInvariant(), out property)) { continue; } property.TrySetValue(attribute.Value); } List <RelatedItem> prevRequiredItems = new List <RelatedItem>(requiredItems); bool overrideRequiredItems = false; foreach (XElement subElement in componentElement.Elements()) { switch (subElement.Name.ToString().ToLowerInvariant()) { case "requireditem": if (!overrideRequiredItems) { requiredItems.Clear(); } overrideRequiredItems = true; RelatedItem newRequiredItem = RelatedItem.Load(subElement); if (newRequiredItem == null) { continue; } var prevRequiredItem = prevRequiredItems.Find(ri => ri.JoinedNames == newRequiredItem.JoinedNames); if (prevRequiredItem != null) { newRequiredItem.statusEffects = prevRequiredItem.statusEffects; newRequiredItem.Msg = prevRequiredItem.Msg; } requiredItems.Add(newRequiredItem); break; } } }
protected void DumpContentToUserDefinedLocation(RelatedItem relatedItem) { var relatedItemPath = new FileInfo(relatedItem.FullPath); var defaultFileName = FileHelper.FileNameFromFileFullPath(relatedItem.FullPath); var relatedItemFilter = Captions.Journal.ExportRelatedItemToFileFilter(relatedItemPath.Extension); var filePath = _dialogCreator.AskForFileToSave(Captions.Journal.ExportRelatedItemToFile, relatedItemFilter, Constants.DirectoryKey.REPORT, defaultFileName: defaultFileName); if (string.IsNullOrEmpty(filePath)) { return; } exportedRelatedItemToFile(relatedItem, filePath); }
protected override void Context() { _context = A.Fake <IOSPSuiteExecutionContext>(); _applicationConfiguration = A.Fake <IApplicationConfiguration>(); sut = new RelatedItemSerializer(_context, _applicationConfiguration); _relatedItem = new RelatedItem { Name = "toto", Origin = Origins.MoBi, Content = new Content { Data = new byte[] {} } }; }
protected override void Context() { base.Context(); sut.FileLength = s => 100; A.CallTo(_dialogCreator).WithReturnType <string>().Returns(_fileName); _relatedItem = new RelatedItem { Content = new Content { Data = new byte[] { } } }; A.CallTo(() => _relatedItemFactory.CreateFromFile(_fileName)).Returns(_relatedItem); }
protected override void Context() { base.Context(); _relatedItem = new RelatedItem(); _journalPage.AddRelatedItem(_relatedItem); A.CallTo(() => _databaseMediator.ExecuteCommand(A <DeleteRelatedItemFromJournalPage> ._)) .Invokes(x => _payload = x.GetArgument <DeleteRelatedItemFromJournalPage>(0)); A.CallTo(() => _eventPublisher.PublishEvent(A <JournalPageUpdatedEvent> ._)) .Invokes(x => _event = x.GetArgument <JournalPageUpdatedEvent>(0)); A.CallTo(() => _dialogCreator.MessageBoxYesNo(Captions.Journal.ReallyDeleteRelatedItem(_relatedItem.Display), ViewResult.Yes)).Returns(ViewResult.Yes); }
protected override void Context() { base.Context(); _journalPage = new JournalPage().WithId("journalPage"); _relatedItem = new RelatedItem().WithId("relatedItem"); _journalPage.AddRelatedItem(_relatedItem); _relatedItemNode = A.Fake <IRelatedItemNode>().WithId("relatedItem"); _journalPageNode = A.Fake <IJournalPageNode>().WithId("journalPage"); _journal.AddJournalPage(_journalPage); A.CallTo(() => _view.GetSelection()).Returns(new List <IBaseObject> { _relatedItemNode, _journalPageNode }); }
protected override void Context() { _journalComparisonTask = A.Fake <IJournalComparisonTask>(); _applicationDiscriminator = A.Fake <IApplicationDiscriminator>(); _view = A.Fake <IRelatedItemComparableView>(); sut = new RelatedItemComparablePresenter(_view, _applicationDiscriminator, _journalComparisonTask); _relatedItem = new RelatedItem { Discriminator = _simulationDiscriminator, Name = "TOTO", ItemType = "SIM" }; _comparableObjects = new List <IObjectBase>(); A.CallTo(() => _applicationDiscriminator.AllFor(_simulationDiscriminator)).Returns(_comparableObjects); A.CallTo(() => _view.BindTo(A <IEnumerable <ObjectSelectionDTO> > ._)) .Invokes(x => _allObjectSelectionDTO = x.GetArgument <IEnumerable <ObjectSelectionDTO> >(0).ToList()); }
private RelatedItem createRelatedItem(string name, string itemType, byte[] data, Action <RelatedItem> configurationFunc) { var relatedItem = new RelatedItem { CreatedAt = SystemTime.UtcNow(), Name = name, ItemType = itemType, Content = new Content { Data = data }, Version = _applicationConfiguration.FullVersion, }; configurationFunc(relatedItem); return(relatedItem); }
public void OnItemContained(Item containedItem) { item.SetContainedItemPositions(); RelatedItem ri = containableItems.Find(x => x.MatchesItem(containedItem)); if (ri != null) { foreach (StatusEffect effect in ri.statusEffects) { itemsWithStatusEffects.Add(Pair <Item, StatusEffect> .Create(containedItem, effect)); } } //no need to Update() if this item has no statuseffects and no physics body IsActive = itemsWithStatusEffects.Count > 0 || containedItem.body != null; }
public void OnItemContained(Item containedItem) { item.SetContainedItemPositions(); RelatedItem ri = ContainableItems.Find(x => x.MatchesItem(containedItem)); if (ri != null) { itemsWithStatusEffects.RemoveAll(i => i.First == containedItem); foreach (StatusEffect effect in ri.statusEffects) { itemsWithStatusEffects.Add(new Pair <Item, StatusEffect>(containedItem, effect)); } } //no need to Update() if this item has no statuseffects and no physics body IsActive = itemsWithStatusEffects.Count > 0 || Inventory.Items.Any(it => it?.body != null); }
public void OnItemContained(Item containedItem) { item.SetContainedItemPositions(); RelatedItem ri = ContainableItems.Find(x => x.MatchesItem(containedItem)); if (ri != null) { activeContainedItems.RemoveAll(i => i.Item == containedItem); foreach (StatusEffect effect in ri.statusEffects) { activeContainedItems.Add(new ActiveContainedItem(containedItem, effect, ri.ExcludeBroken)); } } //no need to Update() if this item has no statuseffects and no physics body IsActive = activeContainedItems.Count > 0 || Inventory.AllItems.Any(it => it.body != null); }
public void Load(RelatedItem relatedItem) { _contentLoader.Load(relatedItem); if (RelatedItemBelongsToApplication(relatedItem)) { LoadOwnContent(relatedItem); } else if (RelatedItemCanBeLaunchedBySisterApplication(relatedItem)) { LoadContentInSisterApplication(relatedItem); } else { DumpContentToUserDefinedLocation(relatedItem); } }
private void OverrideRequiredItems(XElement element) { var prevRequiredItems = new Dictionary <RelatedItem.RelationType, List <RelatedItem> >(requiredItems); requiredItems.Clear(); bool returnEmptyRequirements = false; #if CLIENT returnEmptyRequirements = Screen.Selected == GameMain.SubEditorScreen; #endif foreach (XElement subElement in element.Elements()) { switch (subElement.Name.ToString().ToLowerInvariant()) { case "requireditem": case "requireditems": RelatedItem newRequiredItem = RelatedItem.Load(subElement, returnEmptyRequirements, item.Name); if (newRequiredItem == null) { continue; } var prevRequiredItem = prevRequiredItems.ContainsKey(newRequiredItem.Type) ? prevRequiredItems[newRequiredItem.Type].Find(ri => ri.JoinedIdentifiers == newRequiredItem.JoinedIdentifiers) : null; if (prevRequiredItem != null) { newRequiredItem.statusEffects = prevRequiredItem.statusEffects; newRequiredItem.Msg = prevRequiredItem.Msg; newRequiredItem.IsOptional = prevRequiredItem.IsOptional; newRequiredItem.IgnoreInEditor = prevRequiredItem.IgnoreInEditor; } if (!requiredItems.ContainsKey(newRequiredItem.Type)) { requiredItems[newRequiredItem.Type] = new List <RelatedItem>(); } requiredItems[newRequiredItem.Type].Add(newRequiredItem); break; } } }
protected override void Context() { _applicationConfiguration = A.Fake <IApplicationConfiguration>(); _contentLoader = A.Fake <IContentLoader>(); _dialogCreator = A.Fake <IDialogCreator>(); _relatedItemSerializer = A.Fake <IRelatedItemSerializer>(); _simulationTask = A.Fake <InteractionTasksForSimulation>(); _context = A.Fake <IMoBiContext>(); _cloneManager = A.Fake <ICloneManagerForBuildingBlock>(); _taskRetriever = A.Fake <IBuildingBlockTaskRetriever>(); _pkSimExportTask = A.Fake <IPKSimExportTask>(); _simulationLoader = A.Fake <ISimulationLoader>(); _objectIdResetter = A.Fake <IObjectIdResetter>(); _observedDataTask = A.Fake <IObservedDataTask>(); _parameterIdentificationTask = A.Fake <IParameterIdentificationTask>(); _sensitivityAnalysisTask = A.Fake <ISensitivityAnalysisTask>(); sut = new ReloadRelatedItemTask(_applicationConfiguration, _contentLoader, _dialogCreator, _relatedItemSerializer, _context, _cloneManager, _taskRetriever, _pkSimExportTask, _simulationLoader, _observedDataTask, _objectIdResetter, _parameterIdentificationTask, _sensitivityAnalysisTask); _relatedItem = A.Fake <RelatedItem>(); }
protected override void Context() { base.Context(); _relatedItem = new RelatedItem(); _objectToCompare = A.Fake <IObjectBase>().WithName("A"); _relatedObject = A.Fake <IObjectBase>(); _relatedItem.Name = "B"; _data = new byte[] { 12, 56 }; //simulte content loading from dB A.CallTo(() => _contentLoader.Load(_relatedItem)) .Invokes(x => { _relatedItem.Content = new Content { Data = _data }; }); A.CallTo(() => _eventPublisher.PublishEvent(A <StartComparisonEvent> ._)) .Invokes(x => { _event = x.GetArgument <StartComparisonEvent>(0); }); A.CallTo(() => _relatedItemSerializer.Deserialize(_relatedItem)).Returns(_relatedObject); }
public void StartComparison(IObjectBase selectedObject, RelatedItem relatedItem) { if (selectedObject == null) { return; } if (!loadContent(relatedItem)) { return; } var relatedObject = _relatedItemSerializer.Deserialize(relatedItem); _eventPublisher.PublishEvent(new StartComparisonEvent( leftObject: relatedObject, leftCaption: Captions.Journal.CompareRelatedItem(relatedItem.Name), rightObject: selectedObject, rightCaption: Captions.Journal.CompareProjectItem(selectedObject.Name)) ); }
private void OverrideRequiredItems(XElement element) { var prevRequiredItems = new Dictionary <RelatedItem.RelationType, List <RelatedItem> >(requiredItems); bool overrideRequiredItems = false; foreach (XElement subElement in element.Elements()) { switch (subElement.Name.ToString().ToLowerInvariant()) { case "requireditem": if (!overrideRequiredItems) { requiredItems.Clear(); } overrideRequiredItems = true; RelatedItem newRequiredItem = RelatedItem.Load(subElement, item.Name); if (newRequiredItem == null) { continue; } var prevRequiredItem = prevRequiredItems.ContainsKey(newRequiredItem.Type) ? prevRequiredItems[newRequiredItem.Type].Find(ri => ri.JoinedIdentifiers == newRequiredItem.JoinedIdentifiers) : null; if (prevRequiredItem != null) { newRequiredItem.statusEffects = prevRequiredItem.statusEffects; newRequiredItem.Msg = prevRequiredItem.Msg; } if (!requiredItems.ContainsKey(newRequiredItem.Type)) { requiredItems[newRequiredItem.Type] = new List <RelatedItem>(); } requiredItems[newRequiredItem.Type].Add(newRequiredItem); break; } } }