Where to get implementations of Timeouts methods? - selenium

I want to understand how methods - implicitlyWait, setScriptTimeout and pageLoadTimeout of Timeouts interface are implemented. Where can I find their implementations?

These are located under support/ui/ of GitHub public repository
GitHub direct link is this
And, few here

Related

Where are the Forwarding Implementations mentioned in the ByteBuddy tutorial?

The ByteBuddy tutorial says, in part:
The Forwarding implementations allows to simply forward a method call to another instance of the same type as the declaring type of an intercepted method. The same result can be achieved using a MethodDelegation. However, by Forwarding a simpler delegation model is applied which can cover use cases where no target method discovery is required.
I don't see Forwarding in the Javadoc index. Where did it go, or what is it now?
Good catch, the documentation is outdated, unfortunately. The Forwarding instrumentation was resolved into the MethodCall instrumentation which can achieve the same thing whilst being more flexible.

API are only interface for referencing library classes or library classes themselves

I google this topic but I couldn't find the proper answer. I understand API as only Interface class that referencing library files to be used by other applications from other platforms. But someone told me that APIs are library files themselves.
I'm a novice to this topic so that suggest any answers to me, please.
In my opinion, an API is just a collection of interfaces. It is independent from implementation. Of course, usually, a standard implementation exists and is "associated" with the API but if the implementation is linked to the API, the API is not linked to the implementation.
If you take the example of Java, you'll notice that the API ( http://docs.oracle.com/javase/7/docs/api/ ) only show protected and public fields/constructors/methods/... It is not showing private stuff.
The API is reduced to what is visible for the user which is somehow the definition of an interface. The implementation is hidden.
What might be confusing is that the API is generated from the implementation but that doesn't mean that the API is the implementation.
I might be wrong but I think things are usually going like this:
An private API is defined (it is specification, so, it can be source code or any descriptive file)
An implementation is developed based on the private API
A public API is generated from this implementation and is published
The implementation is published as a Framework / Toolbox / or whatever the name
Developers use the public API to build their application and they choose the best implementation (which is generally the one from which it was generated).
Fell free to comment if you disagree ;)

NServiceBus: need to configure channels for my Gateway with code

I'm engaged in building NServiceBus Gateway handler, and I need to avoid config files so that all configuration is defined inside c# classes. As a result I have to convert the following section to c# code
<GatewayConfig>
<Channels>
<Channel Address="http://localhost:25899/SiteB/" ChannelType="Http" Default="true"/>
</Channels>
</GatewayConfig>
I've found GatewayConfig, ChannelCollection and ChannelConfig in a NServiceBus.Config namespace, but I can not link them together, coz GatewayConfig refers to ChannelCollection, but ChannelCollection has nothing to do with ChannelConfig. Please help
Just create a class implementing IProvideConfiguration of GatewayConfig. That gives you a way to provide your own config. Look at the pubsub sample for the exact details on how to do this.
Well, I've found the way to do it as I installed Reflector and looked into the implementation. There is a ChannelCollection.CreateNewElement() method returning back System.Configuration.ConfigurationElement. NServiceBus overriden the method instantiating ChannelConfig inside it, so all I have to do is to cast ConfigurationElement type to ChannelConfig type which is far from intuitive interface. Looks like this NServiceBus.Config.ChannelCollection is kind of unfinished work, because if you look at other collections like NServiceBus.Config.MessageEndpointMappingCollection you can find there all necessary type-safe methods to work with its child elements NServiceBus.Config.MessageEndpointMapping, so I think NServiceBus team was just lazy to make the same for ChannelCollection.
UPDATE: as CreateNewElement() method is protected, I have to implement my own class inherited from ChannelCollection to make a method adding new ChannelConfig element publicly available

Rhino mock a singleton class

I want to test my controller that depends on a hardware C# class, not an interface.
It's configured as a singleton and I just can't figure out how to RhinoMock it.
The hardware metadata (example) for the dependent class:
namespace Hardware.Client.Api
{
public class CHardwareManager
{
public static CHardwareManager GetInstance();
public string Connect(string clientId);
}
}
and in my code I want this something like this to return true, else I get an exception
if( !CHardwareManager.GetInstance().Connect("foo") )
I mock it using:
CHardwareManager mockHardwareMgr MockRepository.GenerateMock<CHardwareManager>();
But the Connect needs a GetInstance and the only combination I can get to "compile" is
mockHardwareMgr.Expect (x => x.Connected ).Return(true).Repeat.Any();
but it doesn't correctly mock, it throws an exception
but this complains about typing the GetInstance
mockHardwareMgr.Expect (x => x.GetInstance().Connected).Return(true).Repeat.Any();
So my problem - I think - is mocking a singleton. Then I have no idea how to make my controller use this mock since I don't pass the mock into the controller. It's a resource and namespace.
90% of my work requires external components I need to mock, most times I don't write the classes or interfaces, and I'm struggling to get them mocked and my code tested.
Any pointers would be welcome.
Thanks in advance (yes, I've been searching through SO and have not seen something like this. But then, maybe my search was not good.
The usual way to avoid problems with mocking external components is not to use them directly in your code. Instead, define an anti-corruption layer (usually through an interface that looks like your external component) and test your code using mocked implementation of this interface. After all, you're testing your own code, not the external one.
Even better way is to adjust this interface to your needs so it only exposes stuff that you actually need, not the whole API the external component provides (so it's actually an Adapter pattern).
External components are tested using different approaches: system testing, in which case you don't really mock them, you use the actual implementation.
Usually when you try to get Rhino Mocks to do something which feels unnatural and Rhino growls, this is a good sign that your approach is not the right one. Almost everything can be done using simple interface mocking.
As Igor said RhinoMocks (and most other free mocking frameworks, e.g. Moq) can only mock interfaces.
For mocking classes try (and pay) TypeMock.
For mocking singletons see my answer to:
How to Mock a Static Singleton?
Yes, I'm somewhat undermining the common understanding of what's deemed testable and thus "good" code. However I'm starting to resent answers like "You're doing it wrong. Make everything anew." for those answers don't solve the problem at hand.
No, this is not pointing at Igor, but at many others in similar threads, who answered "Singletons are unmockable. (Make everything anew.)".

Unity and NHibernate

I am looking for the best way to configure Microsoft.Practices.Unity.IUnityContainer to manage the lifetime of an nHibernate ISessionFactory for an asp.net application. I would also like unity to inject my IDataLayer implementation which takes an instance of NHibernate.ISession by calling GetCurrentSession on its managed ISessionFactory.
Please include code in your answer :-)
You can also use a direct dependency to ISession and use some NHConversationLifetimeManager. Or look at Spring's ISession management (the Java one for instance). I think they already worked on this subject (ie Hibernate ISession & Dependency Injection).
Sorry, no code!