2020-04-21 17:50:21 +03:00
|
|
|
package mediator
|
|
|
|
|
2020-04-28 06:10:03 +03:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
)
|
2020-04-21 17:50:21 +03:00
|
|
|
|
|
|
|
func TestMediator(t *testing.T) {
|
|
|
|
|
2020-04-28 06:10:03 +03:00
|
|
|
med := &Mediator{}
|
2020-04-27 18:36:39 +03:00
|
|
|
landlord := &Landlord{}
|
2020-04-28 06:10:03 +03:00
|
|
|
//登记房源信息
|
|
|
|
med.RegisterRoom(landlord)
|
|
|
|
tenant := &Tenant{}
|
|
|
|
//向中介租房
|
|
|
|
med.RentOutRoom(tenant)
|
2020-04-21 17:50:21 +03:00
|
|
|
|
2020-04-28 06:10:03 +03:00
|
|
|
//房东收租
|
|
|
|
landlord.CollectRent(med)
|
|
|
|
//租客要求修理
|
|
|
|
tenant.AskRepair(med)
|
2020-04-21 17:50:21 +03:00
|
|
|
|
2020-04-28 06:10:03 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestClassCompose(t *testing.T) {
|
|
|
|
|
|
|
|
med := &Mediator{Person: Person{Name: "mediator", WalletAssets: 1001}}
|
|
|
|
|
|
|
|
landlord := &Landlord{Person: Person{Name: "landlord", WalletAssets: 2000}, RentAccout: 500}
|
|
|
|
|
|
|
|
tenant := &Tenant{Person: Person{Name: "tenant", WalletAssets: 500}, furniture: "desk"}
|
2020-04-21 17:50:21 +03:00
|
|
|
|
2020-04-28 06:10:03 +03:00
|
|
|
fmt.Println("mediator", med)
|
|
|
|
fmt.Println("landlord", landlord.Name)
|
|
|
|
fmt.Println("tenant", tenant.furniture)
|
2020-04-21 17:50:21 +03:00
|
|
|
}
|