Ejemplo n.º 1
0
        public void LacledeGasvAmocoOil()
        {
            var testContract = new ComLawContract <Promise>
            {
                Offer      = new OfferSupplyPropane(),
                Acceptance = o => o is OfferSupplyPropane ? new AcceptanctSupplyPropane() : null,
                Assent     = new MutualAssent
                {
                    IsApprovalExpressed = lp => true,
                    TermsOfAgreement    = lp =>
                    {
                        switch (lp)
                        {
                        case LacledeGas _:
                            return(((LacledeGas)lp).GetTerms());

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

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

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

            var testResult = testContract.IsValid(new LacledeGas(), new AmocoOil());

            Assert.IsTrue(testResult);

            var testSubject = new SpecificPerformance <Promise>(testContract)
            {
                IsDifficultToSubstitute = lp => lp is LacledeGas
            };

            testResult = testSubject.IsValid(new LacledeGas(), new AmocoOil());
            Console.WriteLine(testSubject.ToString());
            Assert.IsTrue(testResult);
        }
Ejemplo n.º 2
0
        public void VanWagnervSmEnterprises()
        {
            var testContract = new ComLawContract <Promise>
            {
                Offer      = new OfferAdvertiseOnBuilding(),
                Acceptance = o => o is OfferAdvertiseOnBuilding ? new AcceptanctAdvertiseOnBuilding() : null,
                Assent     = new MutualAssent
                {
                    IsApprovalExpressed = lp => true,
                    TermsOfAgreement    = lp =>
                    {
                        switch (lp)
                        {
                        case VanWagner _:
                            return(((VanWagner)lp).GetTerms());

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

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

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

            var testResult = testContract.IsValid(new VanWagner(), new SmEnterprises());

            Assert.IsTrue(testResult);

            var testSubject = new SpecificPerformance <Promise>(testContract)
            {
                IsDifficultToProveDmg = lp => lp is VanWagner
            };

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