overriding

OverrideComponent with TestBed

倾然丶 夕夏残阳落幕 提交于 2019-12-04 11:33:15
I have MainComponent that uses ChildComponentA as a @ViewChild . MainComponent is calling a method on ChildComponentA . I want to write an unit test case mocking ChildComponentA . How can I do this using TestBed (in Angular 2 RC5)? Before I used to use overrideDirective(MainComponentName, ChildComponentA, MockChildComponentA); Is there an equivalent to this using TestBed ? I tried using TestBed.overrideComponent(ChildComponentA,{ set: { template: '<div></div>' } }); which just sets the template, but I want to mock the methods in the component as well. I think in this case you can try and

ArrayList not using the overridden equals

寵の児 提交于 2019-12-04 11:13:09
问题 I'm having a problem with getting an ArrayList to correctly use an overriden equals. the problem is that I'm trying to use the equals to only test for a single key field, and using ArrayList.contains() to test for the existence of an object with the correct field. Here is an example public class TestClass { private static class InnerClass{ private final String testKey; //data and such InnerClass(String testKey, int dataStuff) { this.testKey =testKey; //etc } @Override public boolean equals

Determining if a method overrides another at runtime

时光怂恿深爱的人放手 提交于 2019-12-04 10:23:37
问题 I was wondering if there was any way to determine if a method represented by given java.lang.Method object overrides another methods represented by another java.lang.Method object? I'm working on Stronlgy typed javascript, and I need to be able to be able to know if a method overrides another one in order to be able to rename both of them to a shorter name. In this case, I am talking about the extended definition of overriding, as supported by the @Override annotation, which includes

Spree overriding helper method

你说的曾经没有我的故事 提交于 2019-12-04 10:10:33
问题 I'm trying to overriding a helper method of base_helper.rb by using this: module Spree module BaseHelper.class_eval do def taxons_tree(root_taxon, current_taxon, max_level = 1) ..... end end end It's not working for me. Anyone know what I am missing here? Thank you! Fixed: I should use: Spree::BaseHelper.module_eval do def taxons_tree(root_taxon, current_taxon, max_level = 1) ... end end instead. 回答1: Re-opening the module will work just as well: module Spree module BaseHelper def taxons_tree

How can I override a setter from a SuperClass in Swift with Xcode 6.3 Beta2?

浪尽此生 提交于 2019-12-04 10:10:10
问题 My SuerClass is UICollectionViewCell which has a property: var selected: Bool My class is MyClass : UICollectionViewCell { func setSelected(selected: Bool) { super.selected = selected // do something } } The former worked well in Xcode 6.2 but in Xcode 6.3Beta2 it raises an error: Method 'setSelected' with Objective-C selector 'setSelected:' conflicts with setter for 'selected' from superclass 'UICollectionViewCell' with the same Objective-C selector How can I fix this to work with Xcode 6.3

Override the enter key, but keep default behavior for other keys in a wpf datagrid

倖福魔咒の 提交于 2019-12-04 09:55:21
It really bothers me that the pressing the enter key in a Datagrid moves the selection down one item, I'd like to be able to decide what it does in a normal keydown event. So what I did was create a new class that inherits DataGrid and override the OnKeyDown event and use that as my datagrid. This creates a whole new set of problems, since I apparently have to rewrite all the other keypresses (arrow key navigation, shift+arrow key selection, pgup/pgdn, etc..). I've been trying to hack it, but it just seems so pointless spending time rewriting something that has already been written and

Include a TextView and override the text

佐手、 提交于 2019-12-04 09:54:38
问题 I have a TextView I use as the headline of my menu page: <TextView android:id="@+id/menuTextView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Menu" android:textColor="@color/white" android:textSize="25sp" android:textStyle="bold" /> Now I need a TextView with the same color, size and style on every sub menu in my app. Instead of copy pasting the whole TextView to every layout and just change the text in each one I thought I'd make one layout with the

Django Model: How to use mixin class to override django model for function likes save

十年热恋 提交于 2019-12-04 09:43:19
I want to validate value before every model save. So, I must override the save function. The code is nearly just the same on, and I want to write it in a mixin class. But failed for I don't know how to write super func. I'm poor of of English, so sorry. class SyncableMixin(object): def save(self, *args, **kwargs): try: res = validate(*args, **kwargs) except Exception: raise ValidateException() super(?, self).save(*args, **kwargs) class SomeModel(SyncableMixin, models.Model): pass You always refer to the current class in a super call. super(SyncableMixin, self).save(*args, **kwargs) This is

how to overwrite a builtin method of javascript native objects

梦想与她 提交于 2019-12-04 09:31:45
Lets say we have alert method of window object. I would like to enhance it with nice alertbox. Also I want to save the existing alert method so that we can switch back once our application is over. Something like this, but its throwing error in firefox console. window.prototype.alert = function(){ } You can; var base = window.alert; window.alert = function(message) { document.getElementById("myalertwidget").innerHTML = message; return base.apply(this, arguments); }; There is no window.prototype object. window is a global object of javascript context and it is not created from the prototype.

why do we actually have virtual functions?

南楼画角 提交于 2019-12-04 09:19:39
问题 I am new to C++. Could anybody tell me the difference between method overriding and virtual function concepts in c++. The functionality of virtual functions can be over-ridden in its derived classes. Redefining a function in a derived class is called function overriding. why do we actually have virtual functions? 回答1: ABSTRACT In this paper, we discuss virtual functions in C++. Part zero explains how virtual functions are declared and overridden. Part one attempts (and perhaps fails) to