How to unitest a call to IUIVisualizerService has been made - catel

I am trying to verify that a call to IUiVisualizerService.ShowAsync(dialog) has been made. I am using machine specifications as my testing framework with FakeItEasy. Any insight would be helpful.
thanks

In previous versions of Catel, it was shipped with a test implementation of the services (such as IUIVisualizerService), but due to low usage it has been removed. You could try to copy that implementation, or you could simply mock the service and return the expected call (in the end, that's all you need to do).

Related

Replaying RPC calls for testing purposes

We are using a 3rd party library (Google Spanner) that uses gRPC in a node application. One of pain points we have is ability to easily mock responses from this library for testing purposes.
If anyone had similar issues, were you able to solve it? I was thinking of a tool that could record/replay rpc calls (there are many great libraries for recording/replaying HTTP calls) but couldn't find anything similar for RPC. I came up across Google's rpcreplay (https://github.com/GoogleCloudPlatform/google-cloud-go/tree/master/rpcreplay) but to my understanding it's intended to be used in Go applications.
At Traffic Parrot we have been working on a solution to your problem in our service virtualization tool which includes a user interface that can be used to define the mock behaviour.
We have recently added a tutorial on how to mock gRPC responses over the wire given a proto file.
You can also find information on how to record and replay over the wire in the documentation.

Do we really need to import Corda's code for RPC ? How in the future?

I know that Corda is in the process of removing its web server module and in the documentation they suggest the use of other frameworks.
In one example ("spring-observable-stream") they use Spring Boot for the server-side APIs and use an RPC call to the actual running Corda node. That's fine and comparable with what I have to do.
In that example, the author import the specific Corda's RPC code, along with the code of the actual flow (and states) needed.
What I want to ask here is if it's possible to avoid that tangle and keep the web server APIs independent from the actual Corda/CordApp's code by using a general RPC library (any advice ?).
If, instead, I must import the Corda-specific code (there is a reason ?), I'd like to ask you:
What is the minimum necessary to do so from a Gradle perspective ?
Is it possible to implement some sort of plugin on the CordApp to reduce that tangle ?
To be honest, I'm interested in a more general way for interacting with the CordApp (e.g. from Python), but I know that due to the AMQP integration not yet ready, we have to stay on the JVM for now. So, feel free to answer just about what we need to do as of today from Kotlin (which I have to use for a short-term PoC)…
Thank you in advance!
Currently, your server has to depend on the Corda RPC library to interact with nodes via RPC. Corda doesn't yet expose an independent format for sending and receiving messages via RPC.
Your server also needs to depend on any CorDapps that contain flows that the server will start via RPC, or that contain types that will be returned via RPC. Otherwise, your server will not be able to start the flows or deserialise the returned types.
If you're using Gradle, here's what a minimal dependencies block might look like:
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"
cordaCompile "net.corda:corda-rpc:$corda_release_version"
compile "com.github.corda:cordapp-example:release-V1-SNAPSHOT"
}
Here, we're depending on the corda-rpc library, and also using JitPack to depend on the CorDapp where we define the flows and states that we want to start/return via RPC.
If you want, you can modularise the CorDapp so that all the classes you need to depend on for RPC are included in a separate module, and only depend on that module.

Mocking API responses with C# Selenium WebDriver

I am trying to figure out how (or even if) I can replace the API calls made by my app when running a Webdriver test to return stubbed output. The app uses a lot of components that are completely dependent on a time frame or 3rd party info that will not be consistent or reliable for testing. Currently I have no way to test these elements without using 'run this test if...' as an approach which is far from ideal.
My tests are written in C#.
I have found a Javascript library called xhr-mock which seems to kind of do what I want but I can't use that with my current testing solution.
The correct answer to this question may be 'that's not possible' which would be annoying but, after a whole day reading irrelevant articles on Google I fear that may be the outcome.
WebDriver tests are End to End, Black Box, User Interface tests.
If your page depends on an external gateway,
you will have a service and models to wrap that gateway for use throughout your system,
and you will likely already be referencing your models in your tests.
Given the gateway is time dependent, you should use the service consumed by your api layer in your tests as-well, and simply check that the information returned by the gateway at any time is displayed on the as page as you would expect it to be. You'll have unit tests to check the responses model correctly.
As you fear, the obligatory 'this may not be possible': Given the level of change your are subject to from your gateway, you may need to reduce your accuracy or introduce some form of refresh in your tests, as the two calls will arrive slightly apart.
You'll likely have a mock or stub api in order to develop the design, given the unpredictable gateway. It would then be up to you if you used the real or fake gateway for tests in any given environment. These tests shouldn't be run on production, so I would use a fake gateway for a ci-test environment and the real gateway for a manual-test environment, where BBT failures don't impact your release pipeline.

Nodejs API code coverage based on actual production traffic

I'm working on a quite large nodejs code base which have been refactored and migrated from legacy to new service version several times and I highly suspect that some code is not used any more.
This dead code is still well tested, but I would like to get rid of it.
I had the idea to run 1 API server using Istanbul, put in in the production pool for some time (few minutes/hours/days) and see what code is actually useful (and identify probable dead code).
According to its documentation, Istanbul cover can handle long-lived processes, so this seems not to be an issue.
My concern is about memory overhead and potential slowness due to the instrumentation of the code, and more globally any thoughts, feedback and recommandation about getting code coverage based on real traffic would be very helpful.
Thanks!
Your best bet to do what you want would be to run your app on
SmartOS, OmniOS or some other illumos/OpenSolaris distro and use DTrace.
See:
http://dtrace.org/blogs/about/
https://en.wikipedia.org/wiki/DTrace
https://wiki.smartos.org/display/DOC/DTrace

How do I use the Asterisk Audiohooks API?

I have an VOIP application i'd like to implement, that requires me to process the audio from a call in real time during the call.
Currently, I'm using Asterisk to handle my calls, and it looks like there's a functionality built in called Audiohooks which is designed to let me access the audiostream, and process it from the dialplay
However, I can not find any documentation whatsoever on how to actually create my own audio hook, nor any recent examples on how it should be done. Are there resources that show how I could use this?
Thanks
That api is availible when you do c/c++ modules for asterisk. No external API.
For examples you can check MixMonitor,func_volume,app_conference and other similar application already developed.
Hint: after work done, you have test for memory leaks and hi-load/concurrent load. Code must be thread-safe.

Resources