1+ using AutoFixture ;
2+ using FluentAssertions ;
3+ using RealTimeWeatherMonitoringApp . Infrastructure . Configuration ;
4+ using RealTimeWeatherMonitoringApp . Infrastructure . Configuration . Condition ;
5+ using RealTimeWeatherMonitoringApp . Infrastructure . Evaluators ;
6+ using RealTimeWeatherMonitoringApp . Infrastructure . Factory ;
7+ using Xunit ;
8+
9+ namespace RealTimeWeatherMonitoringTest . Infrastructure . Factory ;
10+
11+ public class WeatherEvaluatorFactoryShould
12+ {
13+ private readonly Fixture _fixture = new ( ) ;
14+ private readonly WeatherEvaluatorFactory _weatherEvaluatorFactory = new ( ) ;
15+
16+ [ Fact ]
17+ public void CreateEvaluator_WithTemperatureCondition_CreateWeatherTemperatureEvaluator ( )
18+ {
19+ _fixture . Inject ( ConditionType . Temperature ) ;
20+ var configuration = _fixture . Create < ConditionConfiguration > ( ) ;
21+
22+ var evaluator = _weatherEvaluatorFactory . CreateEvaluator ( configuration ) ;
23+
24+ evaluator . Should ( ) . BeOfType < WeatherTemperatureEvaluator > ( ) ;
25+ }
26+
27+ [ Fact ]
28+ public void CreateEvaluator_WithHumidityCondition_CreateWeatherHumidityEvaluator ( )
29+ {
30+ _fixture . Inject ( ConditionType . Humidity ) ;
31+ var configuration = _fixture . Create < ConditionConfiguration > ( ) ;
32+
33+ var evaluator = _weatherEvaluatorFactory . CreateEvaluator ( configuration ) ;
34+
35+ evaluator . Should ( ) . BeOfType < WeatherHumidityEvaluator > ( ) ;
36+ }
37+
38+ [ Fact ]
39+ public void CreateEvaluator_WithUnknownCondition_ThrowArgumentException ( )
40+ {
41+ _fixture . Inject ( ( ConditionType ) 999 ) ;
42+ var configuration = _fixture . Create < ConditionConfiguration > ( ) ;
43+
44+ var evaluation = ( ) => _weatherEvaluatorFactory . CreateEvaluator ( configuration ) ;
45+
46+ evaluation . Should ( ) . Throw < ArgumentException > ( ) ;
47+ }
48+
49+ [ Fact ]
50+ public void CreateEvaluator_WithUnknownOperator_ThrowArgumentException ( )
51+ {
52+ _fixture . Inject ( ( ConditionOperator ) 999 ) ;
53+ var configuration = _fixture . Create < ConditionConfiguration > ( ) ;
54+
55+ var evaluation = ( ) => _weatherEvaluatorFactory . CreateEvaluator ( configuration ) ;
56+
57+ evaluation . Should ( ) . Throw < ArgumentException > ( ) ;
58+ }
59+ }
0 commit comments