コード例 #1
0
        public void ShouldReturnFalseWhenComparingNonEmptyTextsWithDifferentValue()
        {
            var firstText  = NonEmptyText.Create(SampleTextValue).Value;
            var secondText = NonEmptyText.Create("another").Value;

            Assert.AreNotEqual(firstText, secondText);
        }
コード例 #2
0
        public void SholdReturnTrueWhenComparingNonEmptyTextsWithSameValue()
        {
            var firstText  = NonEmptyText.Create(SampleTextValue).Value;
            var secondText = NonEmptyText.Create(SampleTextValue).Value;

            Assert.AreEqual(firstText, secondText);
        }
コード例 #3
0
        public void ShouldCreateNonEmptyTextWithNonEmptyValueCorrectly()
        {
            const string textValue = SampleTextValue;

            var textResult = NonEmptyText.Create(textValue);

            Assert.IsTrue(textResult.IsSuccess);
            Assert.AreEqual(textValue, textResult.Value);
        }
コード例 #4
0
        public static ValueResult <Student> Create(string name)
        {
            var nameResult = NonEmptyText.Create(name);

            if (nameResult.IsFailure)
            {
                return(ValueResult <Student> .Fail(nameResult.Error));
            }

            return(ValueResult <Student> .Ok(new Student(nameResult.Value)));
        }
コード例 #5
0
        public void ShouldReturnResultFailWhenCreatingNonEmptyTextWithWhitespacesOnly()
        {
            var textResult = NonEmptyText.Create("     ");

            Assert.IsTrue(textResult.IsFailure);
        }
コード例 #6
0
        public void ShouldReturnResultFailWhenCreatingNonEmptyTextWithEmptyValue()
        {
            var textResult = NonEmptyText.Create(string.Empty);

            Assert.IsTrue(textResult.IsFailure);
        }