Thursday, March 31, 2011

Searching good book on Microsoft Business Intelligence Development Studio 2005

Hi,

I'm looking for a good book that about Microsoft Business Intelligence Development Studio 2005. Most interest goes to SSIS, but SSAS and SSRS are also important.

The book explains in a fair, simple and as much hands on way how the Development Studio for BI works (solution, projects, do's and dont's) and all the transformations in SSIS one can use thoroughly explained (like for example how a Derived Columns works). I'm a BI consultant (10 years experience), but not in Microsoft solutions.

Who can suggest me a good book?

From stackoverflow

How to tell if I'm on the last iteration of a for X in Y loop in Objective-C

I have a loop using the for (NSObject *obj in someArray) { } syntax. Is there an easy way to tell if I'm on the last iteration of the loop (ie. without having to use [someArray count])

From stackoverflow
  • Maybe this will work?

    if ( obj == [ someArray lastObject ] ) {
        // ...
    }
    
  • You could use NSArray#lastObject to determine if obj is equal to [NSArray lastObject].

    for (NSObject *obj in someArray) {
        if ([someArray lastObject] == obj) {
            NSLog(@"Last iteration");
        }
    }
    
  • Rather than call into the array at every iteration, it might be better to cache the last object in the array:

    NSObject *lastObject = [someArray lastObject];
    for (NSObject *obj in someArray) {
    
        // Loop code
    
        if (obj == lastObject) {
            // do what you want for the last array item
        }
    }
    
    gclj5 : You're still calling the method in the loop. I think you meant to swap the first two lines. Another tiny typo: uppercase 'F' in "For"
    Abizern : Thanks for pointing that out - I'll edit it.

Using a base class for unit test setup and teardown

Assuming Visual Studio.NET 2008 and MsTest are used to run unit tests. When a system is based on a service container and dependency injection unit testing would naturally require the setting up of services.

Should these services rather be setup in a base class that all unit tests derive from or in each unit test class. If they should be in a base class, is there a way to have the TestInitialize and ClassInitialize methods be executed without requiring them to be called from the derived class, e.g base.Initialise?

From stackoverflow
  • I prefer the Test* and Class* marked methods to be on the actual unit test class. If you define them on a base class, you cannot add test specific activities to them. Instead, use the static and instance constructors and finalizer on your base class.

  • The MSTest framework will search the entire object (all base classes) for the methods marked Test*. Like when you declare them on the unit test class, you do not have to call them explicitly.

    sduplooy : Class* methods will always be marked as static and hence will not be called from derived classes. The Test* methods will be called since they are instance methods.
    Anthony Mastrean : You're right, fixed the answer.
  • With 2008, you should be able to have [TestInitialize] on a base class, and as long as you don't add another [TestInitialize] somewhere down the hierarchy, it should be called. You could also do things with virtual methods.

MSTest.exe not finding app.config

I'm currently trying to run MSTest.exe from NCover, but I believe the question could apply generally to running MSTest.exe from the command line.

If I have the "/noisolation" argument, then MSTest.exe appears to find and use the app.config as expected. Without it, NCover doesn't capture any coverage information. From my research so far, it seems NCover needs /noisolation. So the question is how to get my *.config files to work when that argument is passed.

My NCover settings are:

Application to Profile
C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\MSTest.exe

Working Folder
C:\Documents and Settings\MyProfile\My Documents\Visual Studio 2008\Projects\XYZ\XYZ.CoreTest\bin\Debug

Application arguments
/noisolation /testcontainer:"C:\Documents and Settings\MyProfile\My Documents\Visual Studio 2008\Projects\XYZ\XYZ.CoreTest\bin\Debug\XYZ.CoreTest.dll"



Update: I added a trace showing that my config is (not surprisingly) trying to read from "C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\MSTest.exe.Config".

Update 2: If at all possible, I don't want to edit MSTest.exe.Config. That just isn't terribly portable.

From stackoverflow
  • In visual studio, mark the App.config file to property to CopyAlways. (right click on file, choose properties to get to the property panel)

    Larsenal : Having done so, the (renamed) app.config is in my output folder right next to the assembly... which is what it has been doing. My app is still trying to read the MSTest.exe.config rather than MyAssembly.dll.config. If I omit the /noisolation switch, it reads teh correct file.
  • I've never before used NoIsolation, but if I am understanding it correctly, it literally runs all of your test code in the MSTest class. That being so, it does and should read the App config for MSTest. If you insist on using noisolation, I'm thinking you would have to merge your App.config into MSTest.exe.config. Of course, that is a hack.

    It would probably be better to avoid the noisolation altogether. If it is due to an error, fix the error if possible. Work around the error if reorganizing (major refactoring) your app is not possible. I'm not sure there is an elegant alternative.

    I found "I think we need to find the root cause of this issue in order to avoid the noisolation switch. You might need to modify your applicaton. Is it possible to create a simple solution that repro the same issue?" at this URL.

    Larsenal : If this is the case, then perhaps my real question has to do with how to get NCover to correctly work with MSTest.exe without /noisolation.
    Greg Ogle : Just some ideas; sorry that they sound critical. Not intentional. If you are using team system, maybe you could use code coverage from taht? http://blogs.vertigosoftware.com/teamsystem/archive/2006/02/06/nUnit_and_Team_System_Code_Coverage.aspx
  • There's a technique where you can combine the contents of config files it's detailed here. You could add a fixed file inlcude line to MSTest.exe.Config, and then copy your app's app.config to that fixed file location. It's ugly, but more portable than hacking MSTest.exe.Config for every different eventuality.

  • At http://docs.ncover.com/ref/2-0/whats-new-in-ncover-2-0/release-notes-for-ncover-2-1-0/ under NCover Fixes:

    Running coverage on MSTest no longer requires the "/noisolation" flag. NCover correctly gathers coverage

    If this is indeed fixed, then upgrade NCover to 2.1.0. Perhaps that will work.

    Larsenal : I'll have to look into this.
    Regent : @Greg Ogle: Looks like the link is changed to http://docs.ncover.com/ref/2-0/whats-new-in-ncover-2-0/release-notes-for-ncover-2-1-0/
  • Ok, I'm running the risk that my post will devolve into a unit testing flamewar, but I think the problem is your tests and possibly even your code. You should refactor.

    Unit tests should be atomic. A single test should have no external dependencies and a config file is such a dependency. No test should rely on the config file.

    If you are testing a method that uses information from a config file, refactor your code so that the configured information is read outside of the method and either passed to the method or set as a property before the method is called. That way your test can either pass the value to the method, or set the property during test setup.

    If you need your app.config for a database connection string, you're on your own. DALs are notoriously difficult to unit test. If it's for a web service connection string, don't use it -- mock the interface.

    Larsenal : What I'm doing is probably better characterized as integration testing, not unit testing. In this particular case, I'm having to retroactively add some tests to an existing code base.
    Randolpho : Oh, I hate doing that! Ah, well, I stand by my statement... if you have the opportunity to refactor your code to make it more testable, do it. If your hands are tied, your hands are tied. Also, if you can, look into mocking your integrations, it'll do wonders for you later on.
  • To clear up the confusion: not using /noisolation = if it finds a SameNameAsYourDll.dll.config file, it'll be deployed with the test dll automatically, and will be used for the app config for the app domain that runs the tests in that assembly

    using /noisolation = All the isolation we do between tests, you, the host process, and everything else is out the window. We may still do some isolation, but you don't get the added benefit of the app domain being unique to your test dll. Thus, you dll's config won't help.

  • From Craig Stuntz in a comment at link text

    How to do this with MSTest.

    1. In Solution Explorer, right-click the Solution (not the Project).

    2. Click Add, New Item

    3. In Categories, select Test Run Configuration

    4. Now choose the Test Run Configuration item and add it to your project

    5. In Solution Explorer, double-click the Test Run Configuration you just created

    6. Click the Deployment item

    7. Add your config file as a deployed file (or deploy the entire folder which contains it, if appropriate)

    This took me a little while to figure out, but I'm in a similar situation and it does work for me.

    daub815 : This also only works for Visual Studio 2008 :(

Why does Microsoft.VisualStudio.TestTools.UnitTesting.Assert.Equals() exist?

Description for Assert.Equals() from the MSDN Documentation: Do not use this method.

That's it, the full explanation. Uh.. ok, but then ... why is it there? Is it a deprecated method from an earlier version of the framework? Something that's supposed to be used only by other Microsoft Assemblies?

It just makes me want to use it all the more knowing I'm not supposed to. ;-)

Does anyone know?

From stackoverflow
  • .Equals is inherited from object. It's listed as "Do not use this method" so users won't confuse it with the AreEqual method.

  • All objects in .NET derive from Object.

    Object has a .Equals() method.

    Apparently the .Equals() method for this particular object doesn't do anything useful, so the docs are warning you that it doesn't do anything useful.

  • It was changed in 2008 (Maybe SP1) to fail a test when called, so that people who were using it by accident were told they really shouldn't be using it.

wpf complete reference

Hey

I am looking for a complete wpf tags documentation to use it with wpf controls. Anybody seen something like this?

10x

From stackoverflow
  • The MSDN reference feels a little mechanical, but it's complete.

    Josh G : XAML tags are used for assigning properties on WPF controls. Lookup the WPF control the XAML refers to and read about the properties on the control in MSDN.
  • There is no "Tags" complete documentation for WPF. The markup - XAML - is infinite by it's very nature. If I create a new control, boom, I can use it in XAML. Or, I can use XAML to create my own arbitrary object graph using custom types that are nothing related to UI.

    There is a XAML language spec, but that is not what you looking for. The answer from BC for the MSDN is a start, but vastly incomplete. Look at everything under System.Windows.Controls* for a better idea.

VBScript Compressor / Packer

I'm looking for a VbScript compressor / packer. Basically I want to shorten the VBScript code.

Could you recommend a tool for this?

From stackoverflow
  • I could swear Microsoft had their own tool for VBScript compression/obfuscation a few years back. But now I can't seem to find it.

    Where are you going to use the VBScript? Embedded in a web page or somewhere else?

    dr. evil : It's "script encoder" - http://www.microsoft.com/downloads/details.aspx?familyid=E7877F67-C447-4873-B1B0-21F0626A6329&displaylang=en but it only obfuscates does not shorten the code.
    tyndall : Thanks. I knew I wasn't imagining it. To bad it doesn't compress the code. I also just searched around for VBScript refactoring tools. Couldn't find any. My thought was you could rename the functions (a,b,c,etc...) with this functionality at least.
  • We use http://www.w3compiler.com/ on ASP code - not sure about straight VBScript though, but I'm guessing it is similar so would work.

    dr. evil : I tried with w3compiler but even when I changed the syntax to ASP alike, it can't optimise it for some unknown reasons.