11using Incoding . Core . Block . Scheduler . Command ;
22using Incoding . Core . Block . Scheduler . Persistence ;
33using Incoding . Core . Block . Scheduler . Query ;
4+ using Incoding . Core . Extensions ;
45
56namespace Incoding . UnitTest
67{
@@ -17,37 +18,68 @@ namespace Incoding.UnitTest
1718 [ Subject ( typeof ( ChangeSchedulerStatusCommand ) ) ]
1819 public class When_change_delay_to_schedule_to_success
1920 {
20- Establish establish = ( ) =>
21+ private Establish establish = ( ) =>
2122 {
2223 var command = Pleasure . Generator . Invent < ChangeSchedulerStatusCommand > ( dsl => dsl . Tuning ( s => s . Status , DelayOfStatus . Success ) ) ;
2324
2425 var instance = Pleasure . Generator . Invent < ChangeSchedulerStatusCommand > ( ) ;
2526 DateTime ? nextDt = Pleasure . Generator . DateTime ( ) ;
2627 lastStartOn = Pleasure . Generator . DateTime ( ) ;
28+ recurrency = Pleasure . Generator . Invent < GetRecurrencyDateQuery > ( dsl => dsl . Tuning ( s => s . NowDate , lastStartOn )
29+ . Tuning ( r => r . StartDate , lastStartOn ) ) ;
2730 delay = Pleasure . MockStrict < DelayToScheduler > ( mock =>
2831 {
2932 mock . SetupGet ( r => r . StartsOn ) . Returns ( lastStartOn ) ;
3033 mock . SetupGet ( r => r . Priority ) . Returns ( Pleasure . Generator . PositiveNumber ( ) ) ;
3134 mock . SetupSet ( r => r . Status = command . Status ) ;
3235 mock . SetupSet ( r => r . Description = command . Description ) ;
3336 mock . SetupGet ( r => r . Recurrence ) . Returns ( recurrency ) ;
37+ mock . SetupGet ( r => r . Command ) . Returns ( instance . ToJsonString ( ) ) ;
38+ mock . SetupGet ( r => r . Type )
39+ . Returns ( typeof ( ChangeSchedulerStatusCommand ) . AssemblyQualifiedName ) ;
3440 mock . SetupGet ( r => r . UID ) . Returns ( Guid . NewGuid ( ) . ToString ) ;
3541 } ) ;
3642
37- recurrency = Pleasure . Generator . Invent < GetRecurrencyDateQuery > ( dsl => dsl . Tuning ( s => s . NowDate , lastStartOn ) ) ;
3843
3944 Action < ICompareFactoryDsl < ScheduleCommand , ScheduleCommand > > compare
4045 = dsl => dsl . ForwardToAction ( r => r . Recurrency , schedulerCommand => schedulerCommand . Recurrency . ShouldEqualWeak ( recurrency ,
4146 factoryDsl => factoryDsl . ForwardToValue ( r => r . NowDate , null )
4247 . ForwardToValue ( r => r . RepeatCount , recurrency . RepeatCount - 1 )
4348 . ForwardToValue ( r => r . StartDate , lastStartOn ) ) ) ;
49+ var newRecurrency = new GetRecurrencyDateQuery
50+ {
51+ EndDate = recurrency . EndDate ,
52+ RepeatCount = recurrency . RepeatCount - 1 ,
53+ RepeatDays = recurrency . RepeatDays ,
54+ RepeatInterval = recurrency . RepeatInterval ,
55+ StartDate = lastStartOn ,
56+ Type = recurrency . Type ,
57+ NowDate = lastStartOn
58+ } ;
59+ var lastRecurrency = new GetRecurrencyDateQuery
60+ {
61+ EndDate = recurrency . EndDate ,
62+ RepeatCount = recurrency . RepeatCount - 1 ,
63+ RepeatDays = recurrency . RepeatDays ,
64+ RepeatInterval = recurrency . RepeatInterval ,
65+ StartDate = nextDt ,
66+ Type = recurrency . Type ,
67+ NowDate = lastStartOn
68+ } ;
4469 mockCommand = MockCommand < ChangeSchedulerStatusCommand >
45- . When ( command )
46- . StubGetById ( command . Id , delay . Object )
47- . StubQuery ( recurrency , nextDt )
48- . StubPush ( dsl => dsl . Tuning ( r => r . UID , delay . Object . UID )
49- . Tuning ( r => r . Command , instance )
50- . Tuning ( r => r . Priority , delay . Object . Priority ) , compare ) ;
70+ . When ( command )
71+ . StubGetById ( command . Id , delay . Object )
72+ . StubQuery ( newRecurrency , nextDt )
73+ . StubPush ( new ScheduleCommand ( delay . Object )
74+ {
75+
76+ UID = delay . Object . UID ,
77+ Priority = delay . Object . Priority ,
78+ Recurrency = lastRecurrency
79+ } ) ;
80+ //.StubPush(dsl => dsl.Tuning(r => r.UID, delay.Object.UID)
81+ // .Tuning(r => r.Command, instance)
82+ // .Tuning(r => r.Priority, delay.Object.Priority), compare);
5183 } ;
5284
5385 Because of = ( ) => mockCommand . Execute ( ) ;
0 commit comments