public void Given_tags_is_not_null_When_WithTags_is_called_Then_Tags_should_be_set() { // Arrange. IClock clock = ConstantClockStub.Create(0); BlogPostBuilder builder = BlogPostBuilder.Create(clock); IImmutableSet <Tag> tags = ImmutableHashSet.Create(Tag.Create("name")); // Act. builder = builder.WithTags(tags); // Assert. builder.Tags.Should().BeEquivalentTo(tags); }
public void Given_two_sets_of_tags_When_WithTags_is_called_Then_Tags_should_be_last_set_of_tags() { // Arrange. IClock clock = ConstantClockStub.Create(0); BlogPostBuilder builder = BlogPostBuilder.Create(clock); IImmutableSet <Tag> tags = ImmutableHashSet.Create(Tag.Create("name"), Tag.Create("pizza")); IImmutableSet <Tag> otherTags = ImmutableHashSet.Create(Tag.Create("name"), Tag.Create("age")); // Act. builder = builder.WithTags(tags) .WithTags(otherTags); // Assert. builder.Tags.Should().BeEquivalentTo(otherTags); }
public void Given_tags_is_null_When_WithTags_is_called_Then_an_ArgumentNullException_should_be_thrown() { // Arrange. IClock clock = ConstantClockStub.Create(0); BlogPostBuilder builder = BlogPostBuilder.Create(clock); IImmutableSet <Tag> tags = null; // Act. Action testCode = () => builder.WithTags(tags); // Assert. testCode.Should() .Throw <ArgumentNullException>() .WithMessage("*cannot be null*tags*"); }