public void Init() { _mashing = _factory.Create(StepTypeEnum.Mashing.ToStepType(), DateTime.Now).Value; _boiling = _factory.Create(StepTypeEnum.Boiling.ToStepType(), DateTime.Now).Value; _packaging = _factory.Create(StepTypeEnum.Packaging.ToStepType(), DateTime.Now).Value; _finalized = _factory.Create(StepTypeEnum.Finalized.ToStepType(), DateTime.Now).Value; }
public Result MoveToNextStep(IStepType nextStepType) { return(Result.Ok(CurrentStep) .Ensure(step => step.NextStepTypes.Contains(nextStepType), CannotGoToNextStepMessage + nextStepType.Name) .OnSuccess(step => step.IsFinalized ? Result.Ok() : step.Finalize(DateTime.Now, CurrentSize)) .OnSuccess(() => _stepFactory.Create(nextStepType, DateTime.Now)) .OnSuccess(nextStep => _steps.Add(nextStep))); }
public void SimpleStepCreation() { var now = DateTime.Now; var step = _factory.Create(StepTypeEnum.Aging.ToStepType(), now); Assert.IsTrue(step.IsSuccess); Assert.AreEqual(StepTypeEnum.Aging.ToStepType(), step.Value.Info.Type); Assert.AreEqual(now, step.Value.Info.StartDate); }
public Batch(IBatchMethod method, Quantity initialSize, IIdGenerator idGenerator, IStepFactory stepFactory) { _stepFactory = stepFactory; _steps = new List <IStep>(); Action cannotCreateInitialStep = () => throw new ArgumentException(); _stepFactory.Create(method.InitialStepType, DateTime.Now) .OnFailure(cannotCreateInitialStep) .OnSuccess(step => _steps.Add(step)); Info = new BatchInfo { Method = method, InitialSize = initialSize }; Id = idGenerator.NextId; }