Syndication

News

     

Archives

Miscelaneous

Programming

June 2012 - Posts

The short answer is: you don’t. You see, having a mocking library at hand (no matter how cool it is) doesn’t automatically make it the best tool for every testing need.

A generic repository is much easier to replace for testing with a simple fake and allows to use simple state-based testing agaist it, rather than mock verifications.

A fairly typical generic repository might look like the following:

public interface IRepository<T> where T : IEntity
{
    T Get(Guid id);
    void SaveOrUpdate(T entity);
    void Delete(T entity);
    IQueryable<T> Query();
}

You might use integer or long for IDs, you might not have an IEntity interface but a base class, you might not have a Query feature there, but that’s beside the point. The point is that such an interface, whatever the variations, is trivial to fake:...

Read full article

Posted by Daniel Cazzulino

For this walk-through, you’ll need the most excelent CloudBerry S3 Explorer. Somehow, these guys manage to support in the UI more stuff than Amazon itself does in its management console Sorpresa. And you only need the free version.

So first the requirements:

  1. You want to have full control of who and for how long accesses the S3 payloads/objects.
  2. You want to automatically leverage Amazon’s CloudFront CDN so that customers get the fastest downloads

 

So here’s how to go about it:

  1. Create a new bucket in S3 that will serve as the origin for CloudFront. At this point, unless you specify something different, the bucket is private.
  2. In the CloudBerry S3 Explorer, right-click the bucket, and select CloudFront –> New CloudFront Distribution Wizard
    • Choose the kind of delivery for the payloads. In my case, I just picked Download....

Read full article

Posted by Daniel Cazzulino

This is a pretty common request, and the simple answer is available in SO: right after the C# targets import, add the following:

<UsingTask TaskName="TransformXml" AssemblyFile="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.Tasks.dll" />
<Target Name="AfterCompile" Condition="exists(\'app.$(Configuration).config\')">
  <!-- Generate transformed app config in the intermediate directory -->
  <TransformXml Source="app.config" Destination="$(IntermediateOutputPath)$(TargetFileName).config" Transform="app.$(Configuration).config" />
  <!-- Force build process to use the transformed configuration file from now on. -->
  <ItemGroup>
    <AppConfigWithTargetPath Remove="app.config" />
    <AppConfigWithTargetPath Include="$(IntermediateOutputPath)$(TargetFileName).config">
      <TargetPath>$(TargetFileName).config</TargetPath>
    </AppConfigWithTargetPath>
  </ItemGroup>
</Target>...

Read full article

Posted by Daniel Cazzulino
Filed under:
More Posts