1+ using DrawTogether . Entities ;
2+ using DrawTogether . Entities . Drawings ;
3+ using DrawTogether . Entities . Users ;
4+ using FluentAssertions ;
5+ using Xunit ;
6+
7+ namespace DrawTogether . Tests ;
8+
9+ public class SingleDotStrokeTests
10+ {
11+ [ Fact ]
12+ public void Should_Detect_Single_Point_Stroke ( )
13+ {
14+ // Arrange
15+ var strokeId = new StrokeId ( 1 ) ;
16+ var point = new Point ( 100 , 200 ) ;
17+ var strokeWidth = new GreaterThanZeroInteger ( 5 ) ;
18+ var color = new Color ( "#FF0000" ) ;
19+
20+ var singlePointStroke = new ConnectedStroke ( strokeId )
21+ {
22+ Points = [ point ] ,
23+ StrokeWidth = strokeWidth ,
24+ StrokeColor = color
25+ } ;
26+
27+ // Act & Assert
28+ singlePointStroke . Points . Should ( ) . HaveCount ( 1 ) ;
29+ singlePointStroke . Points [ 0 ] . Should ( ) . Be ( point ) ;
30+ singlePointStroke . StrokeWidth . Should ( ) . Be ( strokeWidth ) ;
31+ singlePointStroke . StrokeColor . Should ( ) . Be ( color ) ;
32+ }
33+
34+ [ Fact ]
35+ public void Should_Distinguish_Single_Point_From_Multi_Point_Strokes ( )
36+ {
37+ // Arrange
38+ var strokeId1 = new StrokeId ( 1 ) ;
39+ var strokeId2 = new StrokeId ( 2 ) ;
40+
41+ var singlePointStroke = new ConnectedStroke ( strokeId1 )
42+ {
43+ Points = [ new Point ( 100 , 200 ) ] ,
44+ StrokeWidth = new GreaterThanZeroInteger ( 3 ) ,
45+ StrokeColor = new Color ( "#00FF00" )
46+ } ;
47+
48+ var multiPointStroke = new ConnectedStroke ( strokeId2 )
49+ {
50+ Points = [ new Point ( 100 , 200 ) , new Point ( 150 , 250 ) ] ,
51+ StrokeWidth = new GreaterThanZeroInteger ( 3 ) ,
52+ StrokeColor = new Color ( "#0000FF" )
53+ } ;
54+
55+ // Act & Assert
56+ singlePointStroke . Points . Should ( ) . HaveCount ( 1 ) ;
57+ multiPointStroke . Points . Should ( ) . HaveCount ( 2 ) ;
58+
59+ // This simulates the rendering logic decision
60+ var shouldRenderAsCircle1 = singlePointStroke . Points . Count == 1 ;
61+ var shouldRenderAsCircle2 = multiPointStroke . Points . Count == 1 ;
62+
63+ shouldRenderAsCircle1 . Should ( ) . BeTrue ( ) ;
64+ shouldRenderAsCircle2 . Should ( ) . BeFalse ( ) ;
65+ }
66+
67+ [ Fact ]
68+ public void Should_Calculate_Correct_Circle_Radius_For_Single_Point_Stroke ( )
69+ {
70+ // Arrange
71+ var strokeWidth = new GreaterThanZeroInteger ( 10 ) ;
72+ var expectedRadius = strokeWidth . Value / 2.0 ;
73+
74+ var singlePointStroke = new ConnectedStroke ( new StrokeId ( 1 ) )
75+ {
76+ Points = [ new Point ( 50 , 75 ) ] ,
77+ StrokeWidth = strokeWidth ,
78+ StrokeColor = new Color ( "#FFFF00" )
79+ } ;
80+
81+ // Act
82+ var actualRadius = singlePointStroke . StrokeWidth . Value / 2.0 ;
83+
84+ // Assert
85+ actualRadius . Should ( ) . Be ( expectedRadius ) ;
86+ actualRadius . Should ( ) . Be ( 5.0 ) ;
87+ }
88+ }
0 commit comments