コード例 #1
0
        public void ItShallFailOnUnsetConstructorValueOnly()
        {
            // Given
            var builder = new AnswerToEveryThingBuilder()
                          .WithValue(0)
                          .WithQuestion("test");

            // When
            Action when = () => builder.Build();

            // Then
            when.Should().Throw <InvalidOperationException>()
            .Which.Message.Should().Contain(nameof(AnswerToEveryThing.Author));
        }
コード例 #2
0
        public void ItShallIgnoreDefaultValuesEvenNonNullable()
        {
            // Given
            var builder = new AnswerToEveryThingBuilder()
                          .WithAuthor("UnitTest")
                          .WithCreationDate(DateTime.UtcNow);

            // When
            var answer = builder.Build();

            // Then
            answer.Value.Should().Be(42);
            answer.Question.Should().BeNull();
        }