A useful article to any SharePoint developer

http://madhurahuja.blogspot.com/2008/01/reveal-unknown-error-on-sharepoint-2007.html

finally find out what the actaul error is!!

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

NHibernate in Dec MSDN

Published 12/7/2009 by Dave in alt.net | Database

Ayende never ceases to amaze me, I just wonder where he finds the free time (must be cloning). Anyway, he has written a simple TODO list article which uses

  • Object Relational Mapper
  • Presenter View View-Model
  • Number of Design Patterns

By the looks of this, Ayende has tried to use a minimal number of 3rd party tools, to try and show principals.

Well worth a look!

(Thank you Ayende)

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

The list of TDD anti patterns

Published 12/4/2009 by Dave in Test
Tags:

when writting unit tests you may wonder, what im i actually doing? I follow the AAA pattern, well try to ;).

 anyway I found this link on StackOverflow, which has a list of anti patterns for TDD (Unit testing)

http://blog.james-carr.org/2006/11/03/tdd-anti-patterns/

well worth a look, just incase you think your test is not doing what it should be.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Unit testing presentation

Published 11/26/2009 by Dave in General | Test
Tags:

A small presentation to show how unit testing can be used to show/identify poor design (strong coupling).

Downloads:
Presentation: Unit testing.rar (2.89 mb) <BTW, screenshots which show the startbar are actually videos, just click on the video to make it run>
Code (before & after): UnitTesting Examples.rar (150.51 kb)

It covers

  • Simple shopping cart system
  • Simple unit test
  • Redesign
  • Unit test using Mocking

A generic simple domain, so the concept can be shown.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

a number of articles by a development team whom implemented a web site using Sharp Architecture

Bill's link

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

I fnd it fun to look at Architecture, as when it comes to building web applications you do not want to re invent the wheel every time. before recently there where not many designs for using .Net in a n-tier approach which did not contain DataSets. If you are like me and come from a OO back ground you may see DataSets to be DataCentric and not easy to apply domain rules to the data (neatly).

With the Alt.Net movement promoting a clean OO approch there has been a nice shift from the DataSet designs to Domain Driven technques. The first publised example framework was Patterns in Action. This is quite nice in the sence it promotes the Gang of Four patterns along with some of Martin Fowlers Pattern of Enterprise Application Architecture (PEAA, one of my faviourte books). I have the .Net 2.0 copy (there is a .Net 3.5 one now), which i would reconmned just so you can see how things fit together.

However, there has been another Architecture I have been following, its S#arp Architecture. This is where all my friends woudl know go, "he mentioning it again", at the same time they will think "but he is right this is worth a look". the SA has just released its version 1 RTM release, of which im partictually found of the WCF addition. If you have not been keeping an eye on this I would reconmend downloading the RC2 (just for the word document) and the RTM (for the updated code). I found this Architcture to be extremely impressive. Its easy to understand and its easer to extend. The best thing is the price tag (its FREE). 

Before you consider looking at an architecture in .Net I would highly reconmend reading the Foundations of Programming, then looking at S#arp Architecture. you will note between these 2 you will have knowlegde of some extremely good tools and patterns.

thats it for my rant,,, go look at the new S#arp Arhicture now!

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Resharper Cheet Sheets

Published 7/2/2009 by Dave in General

The tool to rule them all Laughing

Link to the Documents - this page has 2 links to the Keyboard mappings, to find out which setting you have in Visual Studio 2008

ReSharper -> Options

in the "ReSharper - Options" window, choose the "General" tab, and you will see under the "visual studio intergration" area which mapping you have set

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Community Choice awards

Published 6/30/2009 by Dave in General

Looks like source forge have opened the voting for your favorite projects/programs.

Place your vote

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Rowtest with MbUnit

Published 6/30/2009 by Dave in Test
Tags:

I wrote a test which used the Row test attribute, which is a nice feature. This test looks at different states of a form and then tests if the correct email call is made. very similar to the previos post

[Test]
[Row(new object[] { "State Changed", "To: 2, from: 1", "bob", "message", 1, 2 })]
[Row(new object[] { "Another State Changed", "To: 3, from: 2", "bob", "message", 2, 3 })]
public void TestOfStateNtoifcation(string emailSubject, string emailMessage, string formName, string formMessage, int fromState, int toState)
{

    //Record
    var mocks = new MockRepository();
    IEmailService emailService = mocks.DynamicMock<IEmailService>();
    Expect.Call(() => emailService.SendEmail(emailSubject, emailMessage));
    mocks.ReplayAll();

    //Arrange
    Form form1 = new Form()
    {
        Name = formName,
        Message = formMessage,
        ProcessedState = (State)fromState,
    };

    IStateNotification sn = new MappedStateNotification();
    sn.SetInitalState(form1);
    sn.EmailService = emailService;

 

    //Action
    form1.ProcessedState = (State)toState;
    sn.Update(); //message was sent

    //Assert
    mocks.VerifyAll();
}

note some examples showed a Row test without the Test attribute, but Resharper does not pick up upon this... so I added it and bingo.

To pass this test, I wanted a flexible solution compared with the privious post (which used a switch statement) and came up with the use of a Dictionary. the Key would contain the To and From states, for example if the form changed from State.One to State.Two the key would look like

1->2

now the new update looks like this:

public void Update()
{
    //no change
    if (currentState == form.ProcessedState)
        return;

    //get the key
    string key = string.Format("{0}->{1}", (int)currentState, (int)form.ProcessedState);


    if (!rules.ContainsKey(key))
        return;


    NotifyRule rule = rules[key];

    EmailService.SendEmail(rule.Subject, string.Format("To: {1}, from: {0}", rule.FromState, rule.ToState));
}

VS2008 project MockingTestPart2.rar (133.36 kb)

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

One thing I wanted to do was to ensure my code was calling a function with the correct inputs. However the function did not return anything (void) and I did not want to write a mock object from scratch which had a verify method was called (that seemed like re-writing the wheel). So I looked a little into Rhino Mocks (Ayende, you are a genius!), low and behold you can do this with this framework (quite easily)

Project Files TestVoidMethodMocking.rar (128.38 kb)  (VS 2008, using MBUnit)

Ok lets quickly look at what I am doing. I have a Interface, for sending emails.

public interface IEmailService
{
    void SendEmail(string subject, string body);
}

And I have a class which has an Update() method, which calls this method (when the State changes from State.One to State.Two), as follows

public void Update()
{
    switch (currentState)
    {
        case State.One:
            if (form.ProcessedState == State.Two)
            {
                EmailService.SendEmail("Status Change", string.Format("Form {0} has entered state 2", form.Name));
            }
            break;
        case State.Two:
            break;
        case State.Three:
            break;
        default:
            break;
    }
}

Within the Test project, I would like to verify that the SendEmail() method is being called with the correct information. So I have used Rhino Mocks Expect.Call to ensure this. For this test I am going to have a form.Name = "test", so I will expect the method call to look like

SendEmail("Status Change", "Form test has entered state 2")

Here is the Unit Test Code: 

[Test]
public void TestIfEmailWasCalledCorrectly()
{
    //Record
    var mocks = new MockRepository();
    IEmailService emailService = mocks.DynamicMock<IEmailService>();
    Expect.Call(() => emailService.SendEmail("Status Change", "Form test has entered state 2"));
    mocks.ReplayAll();

    //Arrange
    Form form1 = new Form()
    {
        Name = "test",
        Message = "test1",
        ProcessedState = State.One,
    };

    StateNotification sn = new StateNotification(form1);
    sn.EmailService = emailService;

    //Action
    form1.ProcessedState = State.Two;
    sn.Update(); //message was sent

    //Assert
    mocks.VerifyAll();
}

 

now when I run the test. I get all green

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5