Categorized list of AutoFixture questions on Stack Overflow

june 9, 2013 – autofixture

The complete list can be found here.

AutoFixture.Auto[Moq/RhinoMocks/FakeItEasy/NSubstitute]

AutoFixture.Idioms

AutoFixture.Xunit

Customizations

Freeze, Inject

Likeness, Likeness as Resemblance

Refactoring

The GitHub way of blog discussion and commenting

april 28, 2013 – software

Using the underlying power of GitHub, blog authors often take a step further and roll their own discussion and commeting systems.

The best examples are:

With the evolution of blog-aware static site generators, like Jekyll, GitHub is becoming a central part for hosting both blog content and comments.

Hackers, Developers, Programmers

april 18, 2013 – software

The definitions about Hackers, Developers, and Programmers, that I like best are:

“Hackers are generally loners who don’t care if others can figure out their code (at least while they are in the mode or role of hacking). Thus, they build their own little world in it that fits themselves nicely so that they can hack fast, but the rest of the world be damned.” — c2.com/wiki

“On the ‘programmer’ vs. ‘developer’ debate: ‘Programmer’ focuses on the ‘craft’. ‘Developer’ focuses on the business. Both are valuable.” — @ploeh on twitter

I am a programmer — You?

xUnit.net Attributes Execution Order

march 10, 2013 – unit testing

The test below uses the xUnit.net framework and executes twice, since it is decorated with two data sources. The first data source is the built-in [InlineData] and the second data source is the custom [StringData].

[Theory]
[InlineData("foo", "bar")]
[StringData]
[Intercept]
public void Test(string a, string b)
{
}

xUnit.net invokes in exact order:

Initialization

  1. [InlineData] consturctor
  2. [StringData] consturctor
  3. [InlineData] IEnumerable<object[]> GetData(MethodInfo, Type[])
  4. [StringData] IEnumerable<object[]> GetData(MethodInfo, Type[])

1st Run

  1. [Intercept] consturctor
  2. [Intercept] void Before(MethodInfo)
  3. [Theory] supplying values for a and b taken from either [InlineData] or [StringData]
  4. [Intercept] void After(MethodInfo)

2nd Run

  1. [Intercept] consturctor
  2. [Intercept] void Before(MethodInfo)
  3. [Theory] supplying values for a and b taken from either [InlineData] or [StringData]
  4. [Intercept] void After(MethodInfo)

Remarks

[Intercept] is defined as:

internal class InterceptAttribute : BeforeAfterTestAttribute
{
    public override void Before(MethodInfo methodUnderTest)
    {
    }

    public override void After(MethodInfo methodUnderTest)
    {
    }
}

It allows code to be run before and after each test is run.

[StringData] is defined as:

internal class StringDataAttribute : DataAttribute
{
    public override IEnumerable<object[]> GetData(
        MethodInfo methodUnderTest,
        Type[] parameterTypes)
    {
        yield return new object[] { "cow", "zoo" };
    }
}

XCOPY deployment for Code Contracts

march 4, 2013 – microsoft visual studio

If you don’t wish to install Code Contracts through the Windows Installer:

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <CodeContractsInstallDir Condition="'$(CodeContractsInstallDir)'==''">CONTRACTS_PATH</CodeContractsInstallDir>
  </PropertyGroup>
  <Import Condition="'$(CodeContractsImported)' != 'true' AND '$(DontImportCodeContracts)' != 'true'" 
          Project="$(CodeContractsInstallDir)MsBuild\v4.0\Microsoft.CodeContracts.targets" />
</Project>

Legacy Code Risk

march 3, 2013 – legacy code

Taking the risk to adjust the architecture of a legacy system and extend it in a nice and clean way.

Creating a context:

(All the above yield sad customers, bugs, and slow performance.)

Against messy, tightly coupled, legacy code.

Why it is a risk?

The above require a few changes in the system architecture (e.g. in order to be possible to not use Service Locators, in order to be possible to use Services to query from the database instead of the Active Record way, etc.).

While the required changes are going to (initially) slow down the development process at the end the overall development is going to be faster.

Would you take the risk?

« previous entries