
358 N.W.2d 716 (1984)
TWIN CITY CONSTRUCTION COMPANY OF FARGO, N.D., Respondent,
v.
ITT INDUSTRIAL CREDIT COMPANY, Appellant.
No. C4-84-1113.
Court of Appeals of Minnesota.
December 11, 1984.
Ronald H. McLean, Tenneson, Serkland, Lundberg, Erickson & Marcil, Ltd., Fargo, N.D., for respondent. *717 Brian Leonard, O'Neill, Burke & O'Neill, St. Paul, for appellant.
Heard, considered, and decided by LESLIE, P.J., and LANSING and WOZNIAK, JJ.

OPINION
WOZNIAK, Judge.
This is an appeal from a summary judgment, granting Twin City Construction Company final payment due from lender, ITT Industrial Credit Company, based on principles of third party beneficiary and unjust enrichment. ITT claims Twin City is not a third party beneficiary of the loan agreement and, further, that it has not been unjustly enriched. We affirm.

FACTS
Twin City contracted with Bridge Street Partnership for the construction of a Holiday Inn in New Ulm, Minnesota, in June 1979.
Construction began immediately, but halted in November after Twin City had completed $600,000 worth of work, and Bridge Street had failed to make progress payments. Twin City then perfected a mechanic's lien for the full amount.
Bridge Street sought a rescue loan from ITT in order to complete the Holiday Inn.
As part of its bargain with Bridge Street, ITT demanded the release of the mechanic's lien. Further, it required Twin City to subordinate its interest in the sum of $650,000 during the pendency of the construction. Twin City also agreed to complete the Holiday Inn project despite any default by Bridge Street of any payments due Twin City. Finally, it agreed that it would not be entitled to any lien rights on its own behalf or on behalf of any subcontractors or materialmen. Essentially, Twin City was to complete the construction project without any recourse whatsoever against the Holiday Inn project. A subordination agreement detailing these promises was signed by Twin City and Bridge Street.
Having secured these concessions from Twin City through Bridge Street, ITT finalized the loan of $3,450,000 in a written agreement dated August 7, 1980. In the agreement, ITT committed $2,900,000 specifically for construction costs to complete the Holiday Inn, which it was to pay directly to Twin City. In addition, ITT took an assignment of the original construction agreement between Bridge Street and Twin City. Finally, a disclaimer was written into the agreement which reads: "No third party is entitled to rely on any provisions in this agreement."
Twin City resumed construction on August 15, 1980. During the period of construction, ITT made progress payments directly to Twin City upon Bridge Street's approval.
Each payment was made after request by Twin City, but the final request of $34,000, made on November 13, 1981, was not honored. Twin City had completed all the steps necessary to receive the final funds. ITT refused to make the final payment, claiming Bridge Street was in default of the loan agreement. The request for final payment was prior in time to the default, which occurred on March 10, 1982.
Twin City commenced suit, claiming that ITT was required to advance the remaining $34,000 under the theories of express and implied contract, third party beneficiary, and the equitable principle of unjust enrichment.
The trial court granted Twin City's motion for summary judgment, based on theories of third party beneficiary and unjust enrichment. ITT appeals.

ISSUE
Was Twin City Construction entitled to judgment as a matter of law?
A. As a third party beneficiary?
B. Under the theory of unjust enrichment?

ANALYSIS
Under Minnesota procedure, summary judgment is proper when:

*718 [T]he pleadings, depositions, answers to interrogatories, and admissions on file, together with the affidavits, if any, show that there is no genuine issue as to any material fact and that either party is entitled to judgment as a matter of law.
Minn.R.Civ.P. 56.03. Viewing the facts from the light most favorable to the losing party, the prevailing party must show there is clearly no genuine issue of material fact. Rients v. International Harvester Co., 346 N.W.2d 359 (Minn.Ct.App.1984).
When contract terms are not patently ambiguous, summary judgment is appropriate. Matter of Turners Crossroad Development Co., 277 N.W.2d 364 (Minn. 1979). Furthermore, where the intent of the parties may be determined entirely from the writing, the construction of the contract is for the court. Id.
Here, the dispute is over the legal effect of the loan agreement between ITT and Bridge Street. The terms of the contract are not ambiguous and no extrinsic evidence is necessary to interpret it. Summary judgment was appropriate.

A. THIRD PARTY BENEFICIARY
A third party beneficiary is one to whom the promisee owes or is believed to owe a duty which is discharged by the promisor's performance, and the contractual right the third party beneficiary acquires is to enforce a promise made for his benefit which he otherwise would not be able to enforce.
Crow & Crow, Inc. v. St. Paul-Mercury Indemnity Co., 247 Minn. 426, 428-429, 77 N.W.2d 429, 431 (1956).
The Minnesota Supreme Court recently set forth the criteria for the recognition of third party beneficiary rights in Cretex Companies, Inc. v. Construction Leaders, Inc., 342 N.W.2d 135 (Minn.1984).
The Cretex court adopted the intended beneficiary approach of the Restatement (Second) of Contracts § 302 (1979). It provides that a third party intended beneficiary can enforce a contract if it is appropriate and either the duty owed or the intent to benefit test is met. Id. at 139. Contrary to ITT's contention, it is not necessary to satisfy both tests.
The duty-owed test is met if the promisor's performance under the contract discharges a duty otherwise owed the third party by the promisee. The intent to benefit test is met if the contract expresses some intent by the parties to benefit the third party through contractual performance.

Duty Owed
In the instant case, Twin City agreed to construct a Holiday Inn for Bridge Street. The duty owed by Bridge Street to Twin City was the obligation to pay for the Holiday Inn. That duty was assumed by ITT when it committed itself to the construction loan. Having assumed the obligation, it proceeded to discharge the duty owed by Bridge Street by paying Twin City the progress payments as the work progressed. Thus, the promisor's (ITT) performance under the contract discharged a duty owed the third party (Twin City) by the promisee (Bridge Street); the duty-owed test was met.

Intent to Benefit
ITT argues that the intent to benefit test cannot be satisfied in light of the disclaimer, a clear expression of an intent not to benefit any third party.
In determining whether ITT intended to benefit Twin City by its loan agreement with Bridge Street, it is necessary to read the contract in light of all the circumstances at the time of contracting. The pertinent inquiry is "to whom is performance to be rendered?" Buchman Plumbing Co., Inc. v. Regents of the University of Minnesota, 298 Minn. 328, 335, 215 N.W.2d 479, 484 (Minn.1974).
This court may examine the contract language to ascertain the real exchange of promises. Trans-Bay Engineers and Builders Inc. v. Hills, 551 F.2d 370 (D.C. Cir.1976).
Considering all the circumstances and all the documents, it is clear that Twin City is an intended beneficiary of the loan *719 agreement. ITT insisted that Twin City vacate its enforceable lien in the amount of $600,000, and further required that it subordinate its interest in the sum of $650,000 during the pendency of the construction. These were clear preconditions by ITT to the commitment of its funds for the completion of the Holiday Inn. In return for these commitments by Twin City, ITT agreed that it would, and did, in fact, make progress payments as the work on the Holiday Inn progressed. It did this until a final sum of $34,000 in retainage remained to be paid. We conclude that ITT, regardless of the disclaimer, intended to benefit Twin City.

The Default
ITT claims, however, that even if Twin City is a third party beneficiary under the contract, Twin City is barred from recovery because Bridge Street defaulted.
It is true that as a third party beneficiary, Twin City was not entitled to payment once Bridge Street defaulted. Trans-Bay, 551 F.2d at 379, 380. However, Bridge Street was not in default until it failed to make an interest payment due on March 10, 1982. Default on a loan agreement does not constitute a bar to recovery by a third party beneficiary when that default occurs after substantial completion of the project.
ITT was informed in November 1981 that Twin City had substantially completed performance under the contract. Default was noted five months later, in March 1982. Thus, at the time of substantial completion of the project, Bridge Street was not in default and Twin City was entitled to recovery.

B. UNJUST ENRICHMENT
If ITT were permitted to benefit from the work performed by Twin City and also to avoid paying out the complete funds relied upon by Twin City for its performance, it would be unjustly enriched. As the Trans-Bay court pointed out, it would be inequitable to permit the financier of a construction project to retain funds committed to a project after completion of the work by the contractor. Id. at 382.
As part of the consideration for the project, Twin City had to release its mechanic's lien and waive any other recourse against the project for construction costs not covered by the funds promised by ITT. Such a requirement, written at the insistence of ITT, was done for ITT's benefit, and as a practical matter, it is unlikely that the loan would have been granted without that condition. Under these facts, recovery is proper to prevent ITT from unjustly benefitting from the work completed by Twin City.

DECISION
Whether viewed from the standpoint of a third party beneficiary or from the standpoint of unjust enrichment, Twin City is clearly entitled to recover in this factual setting. After substantially completing a construction project, contractor was entitled to recover from lender final payment due as a third party beneficiary of the loan agreement between owner and lender. The parties to the loan agreement intended to benefit contractor despite the disclaimer prohibiting third party reliance on the agreement.
Affirmed.
