public void Then_SuccessFull_ActionOnSupplementedValAndVal() { var carInit = Pipe.Init <Car, Storage>(_ => new Storage()) .Then(c => c.SetMark(Car.HondaMark)) .Then(carAndStorage => StorageExt.SetOnStorage(carAndStorage.Val, carAndStorage.SupplementVal)); var pipelineResult = (Option <Car, Storage>)carInit(new Car()); Assert.IsInstanceOfType(pipelineResult.SupplementVal, typeof(Storage)); Assert.IsInstanceOfType(pipelineResult.Val, typeof(Car)); Assert.IsTrue(pipelineResult.Val.IsHonda()); Assert.IsInstanceOfType(pipelineResult.SupplementVal.State.First(), typeof(Car)); Assert.IsTrue(((Car)pipelineResult.SupplementVal.State.First()).IsHonda()); }
public void Then_SuccessFull_FuncOnSupplementedStateToValState() { var carInit = Pipe.Init <Storage, Car>(_ => new Car()) .Then(c => c.SetMark(Car.HondaMark)) .Then(CarExt.Validate) .Then(x => StorageExt.SetOnStorageAndReturnState(x.SupplementVal, x.Val)) .Then(CarExt.DriveFast); var pipelineResult = (Option <Storage, Car>)carInit(new Storage()); Assert.IsTrue(pipelineResult.GetOptionType == OptionType.Some); Assert.IsInstanceOfType(pipelineResult.SupplementVal, typeof(Car)); Assert.IsInstanceOfType(pipelineResult.Val, typeof(Storage)); Assert.IsTrue(pipelineResult.Val.State.Count == 1); Assert.IsInstanceOfType(pipelineResult.Val.State.First(), typeof(Car)); Assert.IsTrue(((Car)pipelineResult.Val.State.First()).Speed == Car.SpeedFast); }