Beispiel #1
0
        public void MaybeMonadTest1()
        {
            //Arrange
            Person person   = new Person();
            string expected = "PostalCodeIsEmpty";

            //Act
            var result = person.ToMaybe()
                         .With(x => x.Adress)
                         .Return(x => x.PostalCode, "PostalCodeIsEmpty");

            InnerOutputWriter.WriteLine("result = {0}", result);

            //Assert
            result.Should().Be(expected, "For an empty postalcode we expect the result to be the default value");
            InnerOutputWriter.WriteLine("succes");
        }
Beispiel #2
0
        public void MaybeMonadTest2()
        {
            //Arrange
            string expected = "Blah22";
            Person person   = new Person {
                Adress = new Address {
                    PostalCode = expected
                }
            };

            //Act
            var result = person.ToMaybe()
                         .With(x => x.Adress)
                         .Return(x => x.PostalCode, "PostalCodeIsEmpty");

            InnerOutputWriter.WriteLine("result = {0}", result);

            //Assert
            result.Should().Be(expected, "When the postalcode not is null we expect the result to be the postalcode");
            InnerOutputWriter.WriteLine("succes");
        }
Beispiel #3
0
        public void MaybeMonadTest3()
        {
            //Arrange
            string expected = "PostalCodeIsEmpty";
            Person person   = new Person {
                Adress = new Address {
                    PostalCode = "Blah22"
                }, Name = "NameLongerThanFour"
            };

            //Act
            var result = person.ToMaybe()
                         .Where(x => x.Name.Length < 4)
                         .With(x => x.Adress)
                         .Return(x => x.PostalCode, "PostalCodeIsEmpty");

            InnerOutputWriter.WriteLine("result = {0}", result);

            //Assert
            result.Should().Be(expected, "For a person with a name longer than four characters we expect the postalcode to be the default value");
            InnerOutputWriter.WriteLine("succes");
        }
        public void MaybeMonadTest1()
        {
            //Arrange
            Person person = new Person();
            string expected = "PostalCodeIsEmpty";

            //Act
            var result = person.ToMaybe()
                .With(x => x.Adress)
                .Return(x => x.PostalCode, "PostalCodeIsEmpty");

            InnerOutputWriter.WriteLine("result = {0}", result);

            //Assert
            result.Should().Be(expected, "For an empty postalcode we expect the result to be the default value");
            InnerOutputWriter.WriteLine("succes");
        }
        public void MaybeMonadTest3()
        {
            //Arrange
            string expected = "PostalCodeIsEmpty";
            Person person = new Person { Adress = new Address { PostalCode = "Blah22" }, Name  = "NameLongerThanFour"};

            //Act
            var result = person.ToMaybe()
                .Where(x => x.Name.Length < 4)
                .With(x => x.Adress)
                .Return(x => x.PostalCode, "PostalCodeIsEmpty");

            InnerOutputWriter.WriteLine("result = {0}", result);

            //Assert
            result.Should().Be(expected, "For a person with a name longer than four characters we expect the postalcode to be the default value");
            InnerOutputWriter.WriteLine("succes");
        }
        public void MaybeMonadTest2()
        {
            //Arrange
            string expected = "Blah22";
            Person person = new Person {Adress = new Address { PostalCode = expected}};

            //Act
            var result = person.ToMaybe()
                .With(x => x.Adress)
                .Return(x => x.PostalCode, "PostalCodeIsEmpty");

            InnerOutputWriter.WriteLine("result = {0}", result);

            //Assert
            result.Should().Be(expected, "When the postalcode not is null we expect the result to be the postalcode");
            InnerOutputWriter.WriteLine("succes");
        }