Esempio n. 1
0
        public void without_monad_at_work()
        {
            Building building = BuildingFactory.AtWorkNotNullBuilding();
            IPhone   phone    = A.Fake <IPhone>();

            if (building != null)
            {
                if (building.Manager != null)
                {
                    Console.WriteLine("Found Manager");
                    if (building.Manager.IsAtWork)
                    {
                        Console.WriteLine("Manager is at work");
                        if (building.Manager.ContactInfo != null)
                        {
                            if (building.Manager.ContactInfo.PhoneNumber != null)
                            {
                                Console.WriteLine("Dialing The Manager");
                                phone.Call(building.Manager.ContactInfo.PhoneNumber);
                            }
                        }
                    }
                }
            }


            A.CallTo(() => phone.Call("1234")).MustHaveHappened();
        }
Esempio n. 2
0
        public void my_strange_monad_3()
        {
            string phoneNumber = BuildingFactory.AtWorkNotNullBuilding()
                                 .GetManager3(b => b.Manager)
                                 .GetContact()
                                 .GetPhoneNumber();

            Assert.AreEqual("1234", phoneNumber);
        }
Esempio n. 3
0
        public void monad_with_not_null()
        {
            string phoneNumber = BuildingFactory.AtWorkNotNullBuilding()
                                 .With(b => b.Manager)
                                 .With(m => m.ContactInfo)
                                 .With(c => c.PhoneNumber);

            Assert.AreEqual("1234", phoneNumber);
        }
Esempio n. 4
0
        public void my_strange_monad()
        {
            IPhone phone = A.Fake <IPhone>();

            BuildingFactory.AtWorkNotNullBuilding()
            .GetManager1()
            .GetContact()
            .GetPhoneNumber()
            .StringDo(phoneNumber => phone.Call(phoneNumber));

            A.CallTo(() => phone.Call("1234")).MustHaveHappened();
        }
Esempio n. 5
0
        public void monad_with_not_null()
        {
            IPhone phone = A.Fake <IPhone>();

            BuildingFactory.AtWorkNotNullBuilding()
            .With(b => b.Manager)
            .With(m => m.ContactInfo)
            .With(c => c.PhoneNumber)
            .Do(phoneNumber => phone.Call(phoneNumber));

            A.CallTo(() => phone.Call("1234")).MustHaveHappened();
        }
Esempio n. 6
0
        public void monad_with_not_null_at_work()
        {
            IPhone phone = A.Fake <IPhone>();

            BuildingFactory.AtWorkNotNullBuilding()
            .With(b => b.Manager)
            .Log("Found Manager")
            .If(m => m.IsAtWork)
            .Log("Manager is at work")
            .With(m => m.ContactInfo)
            .With(c => c.PhoneNumber)
            .Log("Dialing The Manager")
            .Do((p) => phone.Call(p));

            A.CallTo(() => phone.Call("1234")).MustHaveHappened();
        }
Esempio n. 7
0
        public void without_monad()
        {
            Building building    = BuildingFactory.AtWorkNotNullBuilding();
            string   phoneNumber = null;

            if (building != null)
            {
                if (building.Manager != null)
                {
                    if (building.Manager.ContactInfo != null)
                    {
                        if (building.Manager.ContactInfo.PhoneNumber != null)
                        {
                            phoneNumber = building.Manager.ContactInfo.PhoneNumber;
                        }
                    }
                }
            }

            Assert.AreEqual("1234", phoneNumber);
        }
Esempio n. 8
0
        public void without_monad_at_work()
        {
            Building building = BuildingFactory.AtWorkNotNullBuilding();
            IPhone   phone    = A.Fake <IPhone>();

            if (building != null)
            {
                if (building.Manager != null && building.Manager.IsAtWork)
                {
                    if (building.Manager.ContactInfo != null)
                    {
                        if (building.Manager.ContactInfo.PhoneNumber != null)
                        {
                            string phoneNumber = building.Manager.ContactInfo.PhoneNumber;
                            phone.Call(phoneNumber);
                        }
                    }
                }
            }

            A.CallTo(() => phone.Call("1234")).MustHaveHappened();
        }