Пример #1
0
        public void SmithvBrady()
        {
            var testContract = new ComLawContract <Promise>
            {
                Offer      = new OfferBuildSomeCottages(),
                Acceptance = o => o is OfferBuildSomeCottages ? new AcceptanceBuildSomeCottages() : null,
                Assent     = new MutualAssent
                {
                    IsApprovalExpressed = lp => true,
                    TermsOfAgreement    = lp =>
                    {
                        switch (lp)
                        {
                        case Smith _:
                            return(((Smith)lp).GetTerms());

                        case Brady _:
                            return(((Brady)lp).GetTerms());

                        default:
                            return(null);
                        }
                    }
                }
            };

            testContract.Consideration = new Consideration <Promise>(testContract)
            {
                IsGivenByOfferee  = (lp, p) => true,
                IsSoughtByOfferor = (lp, p) => true
            };

            var testResult = testContract.IsValid(new Smith(), new Brady());

            Assert.IsTrue(testResult);

            var testSubject = new PerfectTender <Promise>(testContract)
            {
                ActualPerformance = lp =>
                {
                    if (lp is Smith)
                    {
                        return(new AcceptanceBuildSomeCottages {
                            InchesBetweenJoists = 16, InchesBetweenBeams = 24
                        });
                    }
                    if (lp is Brady)
                    {
                        return(new OfferBuildSomeCottages());
                    }
                    return(null);
                }
            };

            testResult = testSubject.IsValid(new Smith(), new Brady());
            Console.WriteLine(testSubject.ToString());
            Assert.IsTrue(testResult);
        }
Пример #2
0
        public void FanokvCarverBoat()
        {
            var testContract = new UccContract <Goods>
            {
                Offer      = new OfferSellMarquisYacht(),
                Acceptance = o => o is OfferSellMarquisYacht ? new AcceptanctSellMarquisYacht() : null,
                Assent     = new Agreement
                {
                    //although Fanok acts as though acceptance is false
                    IsApprovalExpressed = lp => lp is CarverBoat || lp is Fanok,
                    TermsOfAgreement    = lp =>
                    {
                        switch (lp)
                        {
                        case Fanok _:
                            return(((Fanok)lp).GetTerms());

                        case CarverBoat _:
                            return(((CarverBoat)lp).GetTerms());

                        default:
                            return(null);
                        }
                    },
                    IsGoodsInspected = lp => false,
                    IsRejected       = lp => true,
                    //because they acted as the owner, acceptance is assured
                    IsAnyActAsOwner = lp => lp is Fanok
                }
            };

            var testResult = testContract.IsValid(new CarverBoat(), new Fanok());

            Console.WriteLine(testContract.ToString());
            Assert.IsTrue(testResult);
            var testSubject = new PerfectTender <Goods>(testContract)
            {
                ActualPerformance = lp =>
                {
                    if (lp is CarverBoat)
                    {
                        return(new OfferSellMarquisYacht());
                    }
                    if (lp is Fanok)
                    {
                        return(new AcceptanctSellMarquisYacht());
                    }
                    return(null);
                }
            };

            testResult = testSubject.IsValid(new CarverBoat(), new Fanok());
            Console.WriteLine(testSubject.ToString());
            Assert.IsTrue(testResult);
        }