Feeds:
文章
评论

I was surprised there is no straight setting to automate unit tests after build for Visual C# projects. (Visual Studio 2010 Professional)

Quick answer: Set the Post-build event command line of the Test Project’s Build Events to the following script:

"$(DevEnvDir)mstest.exe" /runconfig:"$(SolutionDir)\Local.testsetting"s /testcontainer:"$(TargetPath)"

The idea is to use mstest.exe to run the Test Project automatically after build. If any of the unit tests fails, the build fails.

 

Long answer:

Say we have a simple Visual C# Console Application. The template generates a Program class. We add a member function int Program::Foo(int i), as the following:

public int Foo(int i)
{
    return i * 2;
}

We then add unit test(s) for this method, by right clicking on the Foo method, and selecting Create Unit Tests. Accept to create a new Visual C# Test Project.

image

 

Edit the unit test as needed.

Edit the Test Project’s Post-build event property: Project-> TestProject1 Properties … –> Build Events, and add the mstest.ext script from the top of this article.

Now press F7 to build the solution. You may find the following output of executing the unit tests.

Starting execution…
 
  Results               Top Level Tests
  ——-               —————
  Passed                TestProject1.ProgramTest.FooTest
  1/1 test(s) Passed
 
  Summary
  ——-
  Test Run Completed.
    Passed  1
    ———
    Total   1
  Results file:  … 

Test Settings: Local

Build succeeded.

 

Note that, if any of the unit tests fails, the build fails.

Advertisements

Nagios troubleshooting

1. 确认各个plugin单独能执行,往往是因为某些环境相关的设置(例如路径、例如权限)导致脚本本身不能执行。

2. 以非dameon的方式运行nagios,nagios.log的信息就显示在console上了。

bin/nagios etc/nagios.cfg

3. 检查nagios.log,nagios.cfg的log_file配置指定了nagios.log的位置。如果nagios.log并没有出现,可能是运行nagios的用户(在安装nagios时指定)没有对nagios.log所指定的目录的写权限。

4. 加速nagios启动后的查询的执行,在nagios.cfg中有如下配置影响nagios启动后的查询执行。

service_inter_check_delay_method

max_service_check_spread

service_interleave_factor

max_concurrent_checks

5. 设置nagios.cfg的debug_level配置,输出debug信息。debug信息输出到nagios.debug,其配置见debug_file。比较有用的是Macros,可以nagios处理Macros的结果,用于验证命令是否正确执行。

6. 自定义的plugin做好log输出,便于检查是否执行以及是否正确执行。

JavaScript and ActionScript can talk to each other via ExternalInterface API. It would be convenient to make this channel ready in the html-template of Flash Builder.

html-template can be found at {Flash Builder installation root path}/sdks/{Application’s default SDK}/templates/swfobject/index.template.html.

Add the following codes to after <body> tag

   <script type="text/javascript">
        function getSWF()
        {
            if (navigator.appName.indexOf("Microsoft") != -1)
            {
                return window["${application}"];
            }
            else
            {
                return document["${application}"];
            }
        }
        
        function jsLog(param)
        {
            console.log(param);
        }
    </script>

getSWF method returns the loaded SWF object. jsLog method is a default JavaScript method for ActionScript to call.

For example, say we implement a method called asLog in ActionScript, which is registered to ExternalInterface as:

ExternalInterface.addCallback("asLog", asLog); 

So, once the application is fired (we set Firefox as the default browser for Flash Builder), we can type the following code in Firefox Firebug console to call SWF’s asLog method:

swfObj = getSWF();
swfObj.asLog("something");

It’s handy to make this little change to Flash Builder’s default html-template.

Batelco – INFINITY

samurai-vs-zombies-630

I played both Android and iPad version. The Android version comes with many ways to earn free Gold, but it is not the case for the iPad version (Green Diamond). The following facts are for the iPad version, but I believe the tips are universal for this game. I bought no diamond. I did not try to earn free diamond.

Status

Accomplished Wave 50 twice

  Level
Hero 10
Sword 5
Bow 6
Sacred Gate Max
Warding Bell 2
Village Bowman Max
Lethargy 6
   
Farmer Max
Bowman 5
Frostie the Bowman 5
Assassin unlocked 5
Nobunaga unlocked
Swordsmith unlocked
Rifleman unlocked
Spear Horseman unlocked

Tips

Maximum level of Farmer is the key.

Restart the wave before 100% to earn coins, to earn a lot of coins, until Farmer reaches the maximum level.

Spend no money to upgrade those allies or abilities will not use later.

Play the minigame

Maximum level of Farmer is the key.

I did not use Daily Reward cheats.

Strategies

Allies: Farmer and Assassin (for flying things only)

Abilities: Lethargy and Troop trample

Charms: might need Peach Charm, but save them only for final waves.

ToDo

Still missing Takeda Shingen!