public void MistletoevLocke()
        {
            var testContract = new ComLawContract <Promise>
            {
                Offer      = new OfferDeliveryService(),
                Acceptance = o => o is OfferDeliveryService ? new AcceptanctDeliveryService() : null,
                Assent     = new MutualAssent
                {
                    IsApprovalExpressed = lp => true,
                    TermsOfAgreement    = lp =>
                    {
                        switch (lp)
                        {
                        case Mistletoe _:
                            return(((Mistletoe)lp).GetTerms());

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

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

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

            var testResult = testContract.IsValid(new Mistletoe(), new Locke());

            Assert.IsTrue(testResult);

            var testSubject = new Reliance <Promise>(testContract)
            {
                CalcPrepExpenditures = lp =>
                {
                    var locke = lp as Locke;
                    if (locke == null)
                    {
                        return(0m);
                    }

                    return(locke.AmountOfTheLoan - locke.AmountRecoveredFromVehicleSales + locke.CostOfDirtWork +
                           locke.LossFromMaterialsOfRamp);
                }
            };

            testResult = testSubject.IsValid(new Mistletoe(), new Locke());
            Console.WriteLine(testSubject.ToString());
            Assert.IsTrue(testResult);
        }
        public void SullivanvOconnor()
        {
            var testContract = new ComLawContract <Promise>
            {
                Offer      = new OfferNoseJob(),
                Acceptance = o => o is OfferNoseJob ? new AcceptanctNoseJob() : null,
                Assent     = new MutualAssent
                {
                    IsApprovalExpressed = lp => true,
                    TermsOfAgreement    = lp =>
                    {
                        switch (lp)
                        {
                        case Sullivan _:
                            return(((Sullivan)lp).GetTerms());

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

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

            testContract.Consideration = new Consideration <Promise>(testContract)
            {
                IsGivenByOfferee  = (lp, p) => true,
                IsSoughtByOfferor = (lp, p) => true
            };
            var testResult = testContract.IsValid(new Sullivan(), new Oconnor());

            Assert.IsTrue(testResult);

            var testSubject = new Reliance <Promise>(testContract)
            {
                CalcPrepExpenditures = lp => lp is Sullivan ? 2m : 0m,
                CalcLossAvoided      = lp => lp is Sullivan ? 1m : 0m,
            };

            testResult = testSubject.IsValid(new Sullivan(), new Oconnor());
            Console.WriteLine(testSubject.ToString());
            Assert.IsTrue(testResult);
        }
Exemple #3
0
        public void HollywoodFanvGabor()
        {
            var testContract = new ComLawContract <Promise>
            {
                Offer      = new OfferMakeAppearance(),
                Acceptance = o => o is OfferMakeAppearance ? new AcceptanctMakeAppearance() : null,
                Assent     = new MutualAssent
                {
                    IsApprovalExpressed = lp => true,
                    TermsOfAgreement    = lp =>
                    {
                        switch (lp)
                        {
                        case HollywoodFan _:
                            return(((HollywoodFan)lp).GetTerms());

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

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

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

            var testResult = testContract.IsValid(new HollywoodFan(), new Gabor());

            Assert.IsTrue(testResult);

            var testSubject = new Reliance <Promise>(testContract)
            {
                CalcPrepExpenditures = lp => (lp as HollywoodFan)?.TotalExpense ?? 0m
            };

            testResult = testSubject.IsValid(new HollywoodFan(), new Gabor());
            Console.WriteLine(testSubject.ToString());
            Assert.IsTrue(testResult);
        }
        public void DoeringvJohnDeere()
        {
            var testContract = new ComLawContract <Promise>
            {
                Offer      = new OfferActAsDistributor(),
                Acceptance = o => o is OfferActAsDistributor ? new AcceptanctActAsDistributor() : null,
                Assent     = new MutualAssent
                {
                    IsApprovalExpressed = lp => true,
                    TermsOfAgreement    = lp =>
                    {
                        switch (lp)
                        {
                        case Doering _:
                            return(((Doering)lp).GetTerms());

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

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

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

            var testResult = testContract.IsValid(new Doering(), new JohnDeere());

            Assert.IsTrue(testResult);

            var testSubject = new Reliance <Promise>(testContract)
            {
            };

            testResult = testSubject.IsValid(new Doering(), new JohnDeere());
            Console.WriteLine(testSubject.ToString());
            Assert.IsFalse(testResult);
        }