Example #1
0
        public void LeevFoote()
        {
            var testContract = new ComLawContract <Promise>
            {
                Offer      = new OfferCarpentry(),
                Acceptance = o => o is OfferCarpentry ? new AcceptanctDoPlumingWork() : null,
                Assent     = new MutualAssent
                {
                    IsApprovalExpressed = lp => true,
                    TermsOfAgreement    = lp =>
                    {
                        switch (lp)
                        {
                        case Lee _:
                            return(((Lee)lp).GetTerms());

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

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

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

            var testResult = testContract.IsValid(new Lee(), new Foote());

            Assert.IsTrue(testResult);

            var testSubject = new Restitution <Promise>(testContract)
            {
                CalcUnjustGain = lp => lp is Lee ? 1m : 0m,
            };

            testResult = testSubject.IsValid(new Lee(), new Foote());
            Console.WriteLine(testSubject.ToString());
            Assert.IsTrue(testResult);
        }
        public void CoastalSteelvAlgernon()
        {
            var testContract = new ComLawContract <Promise>
            {
                Offer      = new OfferSubContractSteelWork(),
                Acceptance = o => o is OfferSubContractSteelWork ? new AcceptanctSubContractSteelWork() : null,
                Assent     = new MutualAssent
                {
                    IsApprovalExpressed = lp => true,
                    TermsOfAgreement    = lp =>
                    {
                        switch (lp)
                        {
                        case CoastalSteel _:
                            return(((CoastalSteel)lp).GetTerms());

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

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

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

            var testResult = testContract.IsValid(new CoastalSteel(), new Algernon());

            Assert.IsTrue(testResult);

            var testSubject = new Restitution <Promise>(testContract)
            {
                CalcUnjustGain = lp => lp is CoastalSteel ? 256m : 0m,
            };

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