Skip to content

Commit 68810c9

Browse files
committed
Adding a ctor-set readonly property to the MixedAccessibilityDto
1 parent f26d418 commit 68810c9

File tree

5 files changed

+19
-25
lines changed

5 files changed

+19
-25
lines changed

TestStack.Dossier.Tests/Factories/AllPropertiesFactoryTests.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,11 @@ public void GivenAllPropertiesFactory_WhenBuilding_ThenAllPropertiesSet()
1313
{
1414
MixedAccessibilityDto dto = Builder<MixedAccessibilityDto>.CreateNew(new AllPropertiesFactory());
1515

16-
// ctor properties
16+
dto.SetByCtorNoPropertySetter.ShouldNotBe(null);
1717
dto.SetByCtorWithPrivateSetter.ShouldNotBe(null);
1818
dto.SetByCtorWithPublicSetter.ShouldNotBe(null);
19-
20-
// public properties
21-
dto.NotSetByCtorWithPublicSetter.ShouldNotBe(null);
22-
23-
// private properties
2419
dto.NotSetByCtorWithPrivateSetter.ShouldNotBe(null);
20+
dto.NotSetByCtorWithPublicSetter.ShouldNotBe(null);
2521
}
2622
}
2723
}

TestStack.Dossier.Tests/Factories/AutoFixtureFactoryTests.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public void GivenAutoFixtureFactory_WhenBuilding_ThenOnlyConstructorAndPublicPro
1313
{
1414
MixedAccessibilityDto dto = Builder<MixedAccessibilityDto>.CreateNew(new AutoFixtureFactory());
1515

16+
dto.SetByCtorNoPropertySetter.ShouldNotBe(null);
1617
dto.SetByCtorWithPrivateSetter.ShouldNotBe(null);
1718
dto.SetByCtorWithPublicSetter.ShouldNotBe(null);
1819
dto.NotSetByCtorWithPrivateSetter.ShouldBe(null);
@@ -24,11 +25,13 @@ public void GivenAutoFixtureFactoryAgainstBuilderWithModifications_WhenBuilding_
2425
{
2526
MixedAccessibilityDto dto = Builder<MixedAccessibilityDto>
2627
.CreateNew(new AutoFixtureFactory())
28+
.Set(x => x.SetByCtorNoPropertySetter, "0")
2729
.Set(x => x.SetByCtorWithPrivateSetter, "1")
2830
.Set(x => x.SetByCtorWithPublicSetter, "2")
2931
.Set(x => x.NotSetByCtorWithPrivateSetter, "3")
3032
.Set(x => x.NotSetByCtorWithPublicSetter, "4");
3133

34+
dto.SetByCtorNoPropertySetter.ShouldNotBe("0");
3235
dto.SetByCtorWithPrivateSetter.ShouldNotBe("1");
3336
dto.SetByCtorWithPublicSetter.ShouldNotBe("2");
3437
dto.NotSetByCtorWithPrivateSetter.ShouldNotBe("3");

TestStack.Dossier.Tests/Factories/CallConstructorFactoryTests.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,11 @@ public void GivenConstructorFactory_WhenBuilding_ThenOnlyConstructorPropertiesSe
1313
{
1414
MixedAccessibilityDto dto = Builder<MixedAccessibilityDto>.CreateNew(new CallConstructorFactory());
1515

16-
// ctor properties
16+
dto.SetByCtorNoPropertySetter.ShouldNotBe(null);
1717
dto.SetByCtorWithPrivateSetter.ShouldNotBe(null);
1818
dto.SetByCtorWithPublicSetter.ShouldNotBe(null);
19-
20-
// public properties
21-
dto.NotSetByCtorWithPublicSetter.ShouldBe(null);
22-
23-
// private properties
2419
dto.NotSetByCtorWithPrivateSetter.ShouldBe(null);
20+
dto.NotSetByCtorWithPublicSetter.ShouldBe(null);
2521
}
2622
}
2723
}

TestStack.Dossier.Tests/Factories/PublicPropertySettersFactoryTests.cs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,13 @@ public class PublicPropertySettersFactoryTests
1010
[Fact]
1111
public void GivenPublicPropertiesFactory_WhenBuilding_ThenOnlyConstructorAndPublicPropertiesSet()
1212
{
13-
MixedAccessibilityDto instructor = Builder<MixedAccessibilityDto>.CreateNew(new PublicPropertySettersFactory());
13+
MixedAccessibilityDto dto = Builder<MixedAccessibilityDto>.CreateNew(new PublicPropertySettersFactory());
1414

15-
// ctor properties
16-
instructor.SetByCtorWithPrivateSetter.ShouldNotBe(null);
17-
instructor.SetByCtorWithPublicSetter.ShouldNotBe(null);
18-
19-
// public properties
20-
instructor.NotSetByCtorWithPublicSetter.ShouldNotBe(null);
21-
22-
// private properties
23-
instructor.NotSetByCtorWithPrivateSetter.ShouldBe(null);
15+
dto.SetByCtorNoPropertySetter.ShouldNotBe(null);
16+
dto.SetByCtorWithPrivateSetter.ShouldNotBe(null);
17+
dto.SetByCtorWithPublicSetter.ShouldNotBe(null);
18+
dto.NotSetByCtorWithPublicSetter.ShouldNotBe(null);
19+
dto.NotSetByCtorWithPrivateSetter.ShouldBe(null);
2420
}
2521
}
2622
}

TestStack.Dossier.Tests/TestHelpers/Objects/Examples/MixedAccessibilityDto.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22
{
33
public class MixedAccessibilityDto
44
{
5-
public MixedAccessibilityDto(string setByCtorWithPrivateSetter, string setByCtorWithPublicSetter)
5+
private readonly string _setByCtorNoPropertySetter;
6+
7+
public MixedAccessibilityDto(string setByCtorWithPrivateSetter, string setByCtorWithPublicSetter, string setByCtorNoPropertySetter)
68
{
79
SetByCtorWithPrivateSetter = setByCtorWithPrivateSetter;
810
SetByCtorWithPublicSetter = setByCtorWithPublicSetter;
11+
_setByCtorNoPropertySetter = setByCtorNoPropertySetter;
912
}
1013

1114
public string SetByCtorWithPrivateSetter { get; private set; }
@@ -15,9 +18,9 @@ public MixedAccessibilityDto(string setByCtorWithPrivateSetter, string setByCtor
1518
public string NotSetByCtorWithPrivateSetter { get; private set; }
1619
public string NotSetByCtorWithPublicSetter { get; set; }
1720

18-
public string CalculatedProperty
21+
public string SetByCtorNoPropertySetter
1922
{
20-
get { return SetByCtorWithPrivateSetter + " " + SetByCtorWithPublicSetter; }
23+
get { return _setByCtorNoPropertySetter; }
2124
}
2225
}
2326
}

0 commit comments

Comments
 (0)