Statement: Bridge.QUnit.QUnit.Test("valid arguments"), not working when at different project from client - qunit

Why would the statement :
Bridge.QUnit.QUnit.Test("valid arguments");
placed as instruction for a method of a class would work fine ONLY IF such class is declared at the same Project which uses it?
I have a Bridge class library with the aforementioned class and an entry point which instantiates it and calls the method, it works fine. Yet, when I moved the class in question to a different proJect I get:
"Message: Diff suppressed as the expected and actual results have an equivalent serialization."
and
"Uncaught TypeError: QUnit.Test is not a function"
on the web page running the compiled .cs to js code and on chrome developer tools respectively. Why is that?
References are fine, double checked.

Related

SwiftAutomation custom record compiler error

I'm using the SwiftAutomation framework to drive a scriptable app that searches for lyrics and returns a AS record. Everything was working correctly, until...
I mapped the AppleScript record to a custom Swift structure according to the SwiftAutomation documentation. The code in the xxxGlue.swift file looks correct, but the compiler complains about SwiftAutomation.SelfUnpacking, with several follow-on errors, when building the MacOSGlues framework.
public struct LFBLyricsInfoRecord: SwiftAutomation.SelfPacking, SwiftAutomation.SelfUnpacking { ... }
--> .../MacOSGlues/LyricsFBAGlue.swift:700:81: No type named 'SelfUnpacking' in module 'SwiftAutomation'
The SelfPacking public protocol is defined in SwiftAutomation, and SelfUnpacking protocol is defined right under it, but without the public keyword. Is that the cause of the compiler error, and if so, how do I fix it?
OK, I finally found a resolution. Seems you have to use different options for the aeglue utility when generating the glue file for the MacOSGlues framework and for the swift file where you actually use your automation, such as in the test project. In my case, where my scriptable app is named LyricsFBA.app, these were:
aeglue -S LyricsFBA.app
for MacOSGlues (generates a LyricsFBAGlue.swift that references SwiftAutomation, but does not include the custom record structure definition), and
aeglue -D -s 'LyricsInfo:lyricsInfo=score:Int+title:String+artist:String+composer:String+link:String+lyrics:String' LyricsFBA.app
for the test program (generatea a LyricsFBAGlue.swift that does not reference SwiftAutomation, but does include the custom record structure definition).

Unable to run tests in Visual Studio

I created a solution with 2 projects, FSharpCalled (which contains a method "disBonjour", transforming a string in another), an F# library, and FSharpTest shown below :
Here's FSharpCalled :
The problem is that I can't run the tests; as shown in the first screenshot, I get an error message saying the "principal module is empty, so nothing will happen at execution".
I tried to modify some properties but without success.
EDIT:
here's the result... damn!
Classes
When you use a let binding inside of a class, the let binding is private (i.e. not publicly accessible). Therefore, you can't use it as a test method.
If you want to use NUnit with a class in F#, you'll have to adorn a method with the [<Test>] attribute:
[<TestFixture>]
type TestClass() =
[<Test>]
member this.SomeTest () =
// Test goes here
()
Last time I used NUnit, you also had to add the [<TestFixture>] attribute to the class itself, so I added that as well. Normally, I don't use NUnit, so I don't know if it's still required.
Modules
You can also write your tests in modules, in which case you can adorn a let bound function with the [<Test>] attribute, since in that case it compiles to a public, static member:
module MyTests =
[<Test>]
let ``a function in a module that works as a test`` () =
// Test goes here
()
At least, the test runner that I use (TestDriven.net) discovers and runs that test as well. I don't know if all other test runners will also do that.
For a general introduction to unit testing with F#, plus much more, you may consider watching my Pluralsight course called Unit Testing with F#.
principal module is empty, so nothing will happen at execution
occurs when you have a console project without an [<EntryPoint>]. So you'd need to either declare such a main method or change the project to be a library project.
Update
Do you use any 3rd party test runner (TestDriven, ReSharper with nUnit integration, ...) or the nUnit VS Test Adapter? VS won't recognize nUnit tests out of the box.

Trying to access common Typescript enums from both Client and NodeJS server

I am trying to access enums written in a Typescript file from both the server and the client. The file is called SocketEndpoints.ts and contains enum SocketMessages.
enum SocketMessages{
CONNECTION_SUCCESSFUL
}
I am able call the enum from the client side by using typescript reference tags. However, using the reference tag alone from the server side (and not using any import/require) leads to an error:
message: endPointModule.SocketMessages.CONNECTION_SUCCESSFUL
^
TypeError: Cannot read property 'CONNECTION_SUCCESSFUL' of undefined
As mentioned in one of the answers below, I have to use import/require statement in the server program which runs on NodeJS and "export" the enum. However, using the "export" keyword causes the enum to be inaccessible from the client. Please help me figure out a way to keep this enum commonly accessible from server and client with simplicity. I'd prefer to use only reference tags.
As shown in the answer for this question:
stackoverflow.com/questions/14659996/reference-tag-pollutes-modules-using-typescript
The typescript compiler should traverse all referenced files and include its code in the compiled javascript output. But the javascript output for server side programs don't seem to have that.
You can't mix and match reference tags to implementation files with import directives (think about what's going on in the JavaScript runtime - what is loading that script? Nothing.).
Put export in front of the enums and use import/require to load SocketIoEndpoints.ts.

npp_destroy gets called immediately after npp_new

I am trying to make a NPAPI plugin for chrome on Mac. I have written a basic npapi plugin and a basic manifest.json and background.html to load it. My background.html has a embed tag to fetch the plugin by Mimetype.
Now when I load my unpackaged extension from Chrome and try to debug the c++ code (in xcode4), I found that the functions are getting called in following order:
NP_Initialize
NP_GetEntryPoints
NPP_New
NPP_Destroy
After this when I click on the extension icon, the popup.html should get executed. My popup.html has these lines:
line 1:
var pluginObj = document.getElementById("pluginId");
line 2:
pluginObj.Myfunction();
But on line 1, NP_Getvalue() function doesnt get called and so a "scriptable NPObject" is not instantiated. On line 2, the Chrome JavaScript console says:
Error in event handler for 'undefined': Object #<HTMLEmbedElement> has no method 'Myfunction' TypeError: Object #<HTMLEmbedElement> has no method 'Myfunction'
Why does the NPP_Destroy functions gets called immediately after the NPP_New function?
Have you done drawing and event model negotiation in your plugin? Starting with Chrome 22 for Mac, the long-deprecated QuickDraw and Carbon models are no longer supported, and if your plugin doesn't negotiate modern models, it will be destroyed just after init. See here for example code that does this.
(Yes, it's unfortunate that the default models for 32-bit plugins are the old, deprecated models, but there's no way to change that in the spec due to all the existing plugins that expect the old behavior.)

Adding WCF proxy class hides Visual Studio project reference

I have a weird visual studio error which is bugging me.
I am using Visual Studio 2010
My solution is small and contains 2 projects:
Project 1 a class library contains the following classes:
Namespace1.DataClass (a serializable class to hold data)
Namespace2.AccessorClass (a class with a method to pull instances of Namespace1.DataClass from a database via Linq to Sql)
Project 2, a console application contains the following classes:
Namespace3.Program (with main function which pulls data from the database and sends it via a wcf service)
Namespace4.WCFProxy (a wcf proxy generated by svcutil)
The WCF client sends objects to the service in the form of:
[System.Runtime.Serialization.KnownTypeAttribute(typeof(Namespace1.DataClass))]
public class SendItem
{
public object Item { get; set; }
public string Label { get; set; }
}
(This is generated by svcutil, so I am paraphrsing to save space)
So, within my proxy class there is a reference to Namespace1.DataClass.
When building my application I first created the project to access the database, I then created my console app, I added a reference from my console app to my my class library and finally I generated my proxy and added it (un-edited) to the console app project.
Everything looks fine, no VS compile errors BEFORE building.
Then, when I build, VS seems to forget the reference from my console app project to my class library project and I get a heap of compile errors accordingly.
If I exclude my proxy class from the project, VS can see the reference again. If I re-add the proxy everything is still fine (no errors and full intellisense support) but click build and everything goes haywire again.
Has anyone come across this issue before?
Cheers
Shane
It was log4net, beware of this behavior in future.
Just to clarify, this problem had nothing to do with WCF as I though it did.

Resources