• Openwave paginates wml cards

    So we were playing around with asp.net 1.1's mobile controls and ran into an interesting little thing. We kept seeing our pages get broken up into seperate wml cards when using openwave. Well after a LOT of troubleshooting and finding the browsercaps in the machine.config and locating the lack of openwave 6 and 7 in there we came to the conclusion that in the end what was causing the pagination was having

     

    browser = "Phone.com"

    in the browsercaps. So we changed it to browser = "Openwave" and that made it stop paginating. Not sure why the Wml Writer does this... maybe i'll open up the reflector and see. For now, i don't give a crap it was just worth blogging about because it took forever to figure it out and i thought i'd save some poor bastard the same trouble.

    Thanks to Shawn for spending long hours on it with me.

    Full story

    Comments (0)

  • Some .net Trivia c# vs VB

    So Chris called me out of the blue and asked me an interesting question...

    "Why is it that in VB.Net you can write a virtual method without declaring a protection level, but in c# you can?"

    Upon further inspection, the simple fact is that when you write this:

    Sub Foo()

    End Sub

    you're saying the same thing as:

    Public Sub Foo()

    End Sub

    Where-as in c# when you do void Foo(){} it's equivalent to

    private void Foo() {}

     

    Our discussion then turned to another interesting attribute of c# and that was it's lack of ability to pass properties by reference in methods.

    For example if you had:

    public object Foo

    {

    get{/*implementation */}

    set{/*implementation */}

    }

    you can't pass that into a method that looks like this:

    public void Action(ref object param){}

     

    I won't go into the details but a nice explanation of it can be found here

     

    Full story

    Comments (0)

  • Still trying to unit test Silverlight pages

    So anyhow, breakfast was good.

     

    I’m suspecting this:

     

            [System.Diagnostics.DebuggerNonUserCodeAttribute()]

            public void InitializeComponent() {

                if (_contentLoaded) {

                    return;

                }

                _contentLoaded = true;

                System.Windows.Application.LoadComponent(this, new System.Uri("/SilverlightApplication1;component/Page.xaml", System.UriKind.Relative));

                this.LayoutRoot = ((System.Windows.Controls.Grid)(this.FindName("LayoutRoot")));

            }

     

     

    Which is inside page.g.cs (generated part of the Page partial class)

     

    So I can’t override it inside of Page, but if I go inherit from it with a test class then I can Hide it via the ‘new’ keyword like so:

     

      public class TestPage : Page

        {

            public new void InitializeComponent()

            {

     

            }

        }

     

    And, well… that didn’t work. I still get 

    ----> System.UnauthorizedAccessException : InvalidCrossThreadAccess

     

     

    So let’s try something else. We have this inside of page:

     

        public partial class Page : UserControl

        {

            public Page()

            {

                InitializeComponent();

            }

        }

     

    Let’s change that to:

       public partial class Page : UserControl

        {

            public Page()

            {

                Init();

            }

            public virtual void Init()

            {

                InitializeComponent();

            }

        }

     

    I ‘think’ this works in c# and java (but wouldn’t work in c++ because you can’t call virtuals from constructors). Let’s see by overriding it in our test page:

        public class TestPage : Page

        {

            public override void Init()

            {

               

            }

        }

     

    Well, I think now we’re dealing with a hidden dependency inside the UserControl constructor in all reality (which reading the stack trace, I should have known) because the Page constructor never even gets called.

     

    I’m really not interested in redefining user control for the sake of constructing this stuff inside a test because I can just use an mvc or mvp pattern (or M_V_VM pattern)

     

    So blah, disappointing that yet another UI technology is hard to construct inside a unit test. (probably not impossible, but I’m bored of trying)

    Full story

    Comments (0)

  • Attempting Unit Test with Silverlight 2.0

     

     

    Steps to get the projects ready:

    Create a silverlight app

    Create a class library project in the same solution for Unit tests.

    Add NUnit.Framework Reference

    Add reference to the silverlight app.

     

     

    Then I got this error when I was trying to reference my silverlight application in a Unit Test assembly.

     

    The type 'System.Windows.Controls.UserControl' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Windows, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'.

     

    According to my installation, the file is in:

    c:\Program Files\Microsoft SDKs\Silverlight\v2.0\Reference Assemblies\System.Windows.dll

     

    Pretty standard really but the GAC didn’t have the assembly surprisingly.

     

    I tried to run a ‘basic test’ to see if the constructor worked.

     

    I got this error:

    Could not load file or assembly 'System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. The system cannot find the file specified.

                System.IO.FileNotFoundException: Could not load file or assembly 'System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. The system cannot find the file specified.

                File name: 'System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'

     

    I tried to add Silverlights System assembly:

    Located here: c:\Program Files\Microsoft SDKs\Silverlight\v2.0\Reference Assemblies\system.dll

     

    I had to remove the regular .net 2.0 System first.

     

    Then when I ran my test, I get this error…

    TestCase 'SilverlightApplication1.UnitTests.PageTests.Constructor_Loads' failed: TestFixtureSetUp failed in PageTests

     

     

    So now I’m kinda angry. I can’t add both system dlls because I get conflicts. I’m sure both use the same namespace too! L

     

    Ok, but that doesn’t deter me.

     

    I get out the nunit.framework.dll source code and I try replacing system.dll with the silverlight system.dll.

     

    I get the same error message.

     

    So… maybe I’m chasing my tail here. I remove the reference to the silverlight Page and just create a new class inside the silverlight app that doesn’t depend on anything.

     

    Whew, now my constructor test worked!

     

    So this means there’s some hidden dependency inside UserControl that’s causing me to fail construction. Hrm what could it be?

     

    I put my test fixture back to inheriting from the Page like so:

        [TestFixture]

        public class PageTests : Page

        {

            [Test]

            public void Constructor_Loads()

            {

                Assert.That(true);

            }

        }

     

    Cool, now let’s see what protected virtuals there are to override because maybe one of them is a seam (see michael feather’s book on legacy code)

     

    image002.jpgWow, quite a few… I guess I’ll just add one at a time and leave them empty (so they don’t do anything)

     

    So I tried each of these one at a time and got no where.

    [TestFixture]

        public class PageTests : Page

        {

            protected override System.Windows.Size ArrangeOverride(System.Windows.Size finalSize)

            {

                return new System.Windows.Size();

            }

            public override void OnApplyTemplate()

            {

               

            }

            protected override System.Windows.Size MeasureOverride(System.Windows.Size availableSize)

            {

                return new System.Windows.Size();

            }

            protected override System.Windows.Automation.Peers.AutomationPeer OnCreateAutomationPeer()

            {

                //i couldn't find a subclass of automationpeer that i could construct, but when i ran the test i didn't get this exception

                throw new NotImplementedException();

            }

            protected override void OnGotFocus(System.Windows.RoutedEventArgs e)

            {

               

            }

            protected override void OnLostFocus(System.Windows.RoutedEventArgs e)

            {

               

            }

            [Test]

            public void Constructor_Loads()

            {

                Assert.That(true);

            }

            

        }

     

    So man, what could it be? Maybe something in the default constructor. So let’s try this:

       [TestFixture]

        public class PageTests

        {

            [Test]

            public void Constructor_Loads()

            {

                Page pg = new Page();

            }

           

        }

     

    I should have done this from the beginning… because now I get a much more sensible error!

      ----> System.UnauthorizedAccessException : InvalidCrossThreadAccess

    at System.Windows.DependencyObject..ctor(UInt32 nativeTypeIndex)

                at System.Windows.Controls.UserControl..ctor()

                C:\Users\James\Documents\Visual Studio 2008\Projects\SilverlightApplication1\SilverlightApplication1\Page.xaml.cs(17,0): at SilverlightApplication1.Page..ctor()

                C:\Users\James\Documents\Visual Studio 2008\Projects\SilverlightApplication1\SilverlightApplication1.UnitTests\PageTests.cs(15,0): at SilverlightApplication1.UnitTests.PageTests.Constructor_Loads()

                --UnauthorizedAccessException

                at MS.Internal.XcpImports.CheckThread()

                at System.Windows.DependencyObject..ctor(UInt32 nativeTypeIndex, IntPtr constructDO)

                at System.Windows.DependencyObject..ctor()

                at System.Windows.DependencyObject.ManagedReferencesToken..ctor()

                at System.Windows.DependencyObject..cctor()

     

    Cross thread access… strange. I don’t see anywhere in my code that I’m using multiple threads. However… does NUnit do something with threads?

     

    Breakfast sounds good right about now.

    Full story

    Comments (0)

  • Jeff Sutherland Google Talks

    Check out this video

    Jeff goes deep into the scrum process and hyper-productivity. He starts talking about distributed teams about after 35minutes... but before that he really sets you up to understand why what Toyota does works so well and why scrum was built the way it is for software and products.

     

     

    Full story

    Comments (0)

  • Cool concept...

    http://www.iftheworldcouldvote.com/

    Obviously, just 'for fun'

    Full story

    Comments (0)

  • Greatest blog i've ever seen

    maybe it's the colorful pictures that mesmorize my simple-mindedness. The simplicity of talking down to me like i'm a third grader. Perhaps it's just the plain "right"ness of everything she says.

    This blog is killer

    Full story

    Comments (0)

  • Rant: Government Tech Catch up please

    Ok, i just have to rant a little bit here:

    why in gods name can we not get electronic voting from the internet?

    ffs we can't even get voter registration to be electronic!

    yes, i'm lazy... so what... everyone is lazy.

    If i can order PIZZA on the internet... then by god we should be able to vote online.

    peace,

     

    Full story

    Comments (0)

  • Scrum value: Commitment

    Scrum has 5 values, one of which is commitment.

    We had just had sprint planning, everyone took on as much as they could take on comfortably based on the estimates we had given. We had set some stretch goals as well to make sure we had something to go to if we finished our initial goals.

    And we began to work.

    a couple weeks in, one of the developers was approached on the side by the functional manager of development with a problem. This issue had to get taken care of, it had to get developed, tested, and finished and out the door immediately.

    Not wanting to disappoint this manager, this "Team player" said "Sure, No problem" as we all do when our boss comes into our cube or office. Do we have a choice?

    How do you think that this developer, who has committed to exactly how much he thinks he can do in a sprint can take on MORE scope during that sprint? How do you think that 'whatever he did' is going to impact the quality of what work he's doing?

    hmm?

    Do you think that impacted THAT developer more than it impacted the rest of his team?

    What sort of message does this give the product owner who is suppose to be the one single source of backlog items for the team?

     

    Full story

    Comments (0)

  • Further Broadening - wscript error handling

       Windows scripting is a powerful tool that I had really not explored (until i had to on Friday).

    What I did pick up though was that error handling is not as robust as .net and pretty much useless error messages when you do use it. So I put something together for it to help me find problems. I'm paraphrasing because i am lazy.

     

    Function Assert(area)

       If Err.Number > 0 Then

          wscript.echo(Err.Description & " in area: "& area & " [Error number: " & Err.Number & " ]"

         wscript.quit(0)

    Function End

     

    then in my code i might have something like this:

    set iisObj = GetObject("IIS:/localhost/w3svc/1/root")

    Assert("Getting IIS")

    Full story

    Comments (0)

  1. 1
  2. 2
  3. Next page