A reference architecture (part 7)

…continued from part 6

The infrastructure layer (Tests)

By now we have setup all layers and finally we can write some integration tests to see if everything works.

Note that we will just create some simple tests that calls the service, checks if it returns something and allows you to debug it, as testing is not the scope of this series.

Add a test project called ArchitectureExample.Infrastructure.IntegrationTests to the Infrastructure Layer solution folder, and put it physically in the \Trunk\Sources\ folder:

p7_1

Add a ArchitectureExampleServiceTests test file and the following test:

[TestMethod]
public void AddBlogEntryTest()
{
using (var architectureExampleServiceAgent = new ArchitectureExampleServiceAgent("BasicHttpBinding_IArchitectureExampleService"))
{
var response = architectureExampleServiceAgent.AddBlogEntry(new AddBlogEntryRequest()
{
Title = "Blog entry title",
Body = "Blog entry body"
});
Assert.IsTrue(response.BlogEntryId>0);

}
}

Before you can execute this, add an app.config to the ArchitectureExample.Infrastructure.IntegrationTests project:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IArchitectureExampleService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:82/ArchitectureExampleService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IArchitectureExampleService"
contract="ArchitectureExample.Service.Contracts.IArchitectureExampleService" name="BasicHttpBinding_IArchitectureExampleService" />
</client>
</system.serviceModel>

</configuration>

Also, in IIS create a new web site that points to \Trunk\Sources\ArchitectureExample.Service.WebHost at port 82.

Now you can start the test and verify if the blog entry is successfully added in the database.

Next time we will implement the query side.

Advertisements

5 thoughts on “A reference architecture (part 7)

  1. Teresa Cherian says:

    Ludwig,
    I’ve a question: for presentation layer, if I create an MVC project, I suppose, that I need to add a service reference to the Service.WebHost project. Then what is the need for the Service.Agent project.
    I’m confused about how I would use this layer from my MVC application.
    Please could you throw some light into it.

    Thank you so much.

    Teresa

  2. Teresa says:

    Thank you so much.
    I’m new to architecting. I’ll definitely use your sample application as rererence in order to layout my architecture.
    Thank you so much for sharing this excellent piece of work.
    It would have been much easier for a person like me if there were to be a sample presentation layer project attached to the sample.
    Thanks
    Teresa

    • Ludwig Stuyck says:

      Well this series was about backend architecture, and presentation layer is front-end architecture… there are already a lot of MVC resources available I guess… just make sure that you understand the principles of MVC.

  3. Teresa Cherian says:

    Hi Ludwig,
    I’m having a tough time to get this sample application working with the latest version of structuremap – could you please help.
    Thanks
    Teresa Cherian

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s