-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPatternTest.java
More file actions
24 lines (20 loc) · 964 Bytes
/
Copy pathPatternTest.java
File metadata and controls
24 lines (20 loc) · 964 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package com.hanserwei.patterns.bridge;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import org.junit.jupiter.api.Test;
/** 验证本模式的协作契约与边界行为. */
public final class PatternTest {
/** 两个业务类型可以分别搭配两种实现,无需四个组合子类. */
@Test
void combinesIndependentDimensions() {
assertEquals("INFO: ready", new InfoNotice(new TextRenderer()).display("ready"));
assertEquals("## INFO\nready", new InfoNotice(new MarkdownRenderer()).display("ready"));
assertEquals("ALERT: ready", new AlertNotice(new TextRenderer()).display("ready"));
assertEquals("## ALERT\nready", new AlertNotice(new MarkdownRenderer()).display("ready"));
}
/** 业务抽象不接受缺失的实现对象. */
@Test
void rejectsMissingRenderer() {
assertThrows(NullPointerException.class, () -> new AlertNotice(null));
}
}