Unit tests for a simple composite I do a lot of unit testing(tdd) and would like some comments about my style. Here is a simple example from a composite.

Is there anything I could improve?

public class ChangedClaimsServiceComposite : IChangedClaimsService
{
    private readonly IChangedClaimsService[] changedClaimsServices;

    public ChangedClaimsServiceComposite(params IChangedClaimsService[] changedClaimsServices)
    {
        if (changedClaimsServices == null) throw new ArgumentNullException("changedClaimsServices");
        this.changedClaimsServices = changedClaimsServices;
    }

    public List&lt;IChangedClaim&gt; GetChangedClaims()
    {
        return changedClaimsServices.SelectMany(x =&gt; x.GetChangedClaims()).ToList();
    }

    public void SetClaimUpdated(IChangedClaim changedClaim)
    {
        foreach (var changedClaimsService in changedClaimsServices)
        {
            changedClaimsService.SetClaimUpdated(changedClaim);
        }
    }
}

[TestFixture]
public class ChangedClaimsServiceCompositeTests
{
    [Test]
    public void GetChangedClaimsSouldCombineResultsFromDependedServices()
    {
        //Arrange
        var changedClaimService1 = new Mock&lt;IChangedClaimsService&gt;();
        var changedClaimService2 = new Mock&lt;IChangedClaimsService&gt;();

        var changedClaim1 = CreateAnyChangedClaim();
        var changedClaim2 = CreateAnyChangedClaim();
        var changedClaim3 = CreateAnyChangedClaim();
        var changedClaim4 = CreateAnyChangedClaim();

        changedClaimService1.Setup(x =&gt; x.GetChangedClaims())
            .Returns(new List&lt;IChangedClaim&gt;() {changedClaim1, changedClaim2});
        changedClaimService2.Setup(x =&gt; x.GetChangedClaims())
            .Returns(new List&lt;IChangedClaim&gt;() { changedClaim3, changedClaim4 });

        var sut = new ChangedClaimsServiceComposite(
            changedClaimService1.Object, 
            changedClaimService2.Object);

        //Act
        var result = sut.GetChangedClaims();

        //Assert
        var expectedResult = new List&lt;IChangedClaim&gt;()
        {
            changedClaim1,
            changedClaim2,
            changedClaim3,
            changedClaim4
        };
        Assert.That(result, Is.EqualTo(expectedResult), "result");
    }

    [Test]
    public void SetClaimUpdatedShouldCallSameMethodOnDependedServices()
    {
        //Arrange
        var changedClaimService1 = new Mock&lt;IChangedClaimsService&gt;();
        var changedClaimService2 = new Mock&lt;IChangedClaimsService&gt;();

        var changedClaim = CreateAnyChangedClaim();

        var sut = new ChangedClaimsServiceComposite(
            changedClaimService1.Object,
            changedClaimService2.Object);

        //Act
        sut.SetClaimUpdated(changedClaim);

        //Assert
        changedClaimService1.Verify(x =&gt; x.SetClaimUpdated(changedClaim), "changedClaimService1");
        changedClaimService2.Verify(x =&gt; x.SetClaimUpdated(changedClaim), "changedClaimService2");
    }

    private IChangedClaim CreateAnyChangedClaim()
    {
        return new Mock&lt;IChangedClaim&gt;().Object;
    }
}
If you rename these:


    var changedClaim1 = CreateAnyChangedClaim();
    var changedClaim2 = CreateAnyChangedClaim();
    var changedClaim3 = CreateAnyChangedClaim();
    var changedClaim4 = CreateAnyChangedClaim();



Like this:

    var service1changedClaim1 = CreateAnyChangedClaim();
    var service1changedClaim2 = CreateAnyChangedClaim();
    var service2changedClaim1 = CreateAnyChangedClaim();
    var service2changedClaim1 = CreateAnyChangedClaim();


Then it will be more obvious that these will be used in two different services. These names will carry more meaning than just an arbitrary list of IChangedClaim objects.



What is "sut" ? A more meaningful name would be better.



In this assert:


    Assert.That(result, Is.EqualTo(expectedResult), "result");



The comment message is not very useful.
Either make it something more meaningful, or delete it.