Esempio n. 1
0
        public void CombineObjects()
        {
            var obj = new Airplane {
                Engine = new Engine {
                    FuelType = "type1", FuelTypeTest = true, HasFuel = true
                }
            }
            .Combine(new Engine
            {
                FuelType     = "None",
                FuelTypeTest = false,
                HasFuel      = false
            });

            Assert.Equal("type1", obj.Item1.Engine.FuelType);
            Assert.Equal("None", obj.Item2.FuelType);
            Assert.False(obj.Item2.FuelTypeTest);
            Assert.False(obj.Item2.HasFuel);

            Assert.True(true);
        }
Esempio n. 2
0
        public void IncludeObjectsFunc()
        {
            var obj = new Airplane {
                Engine = new Engine {
                    FuelType = "type1", FuelTypeTest = true, HasFuel = true
                }
            }
            .Combine(a => new Engine
            {
                FuelType     = a.Engine.FuelType,
                FuelTypeTest = a.Engine.FuelTypeTest,
                HasFuel      = a.Engine.HasFuel
            });

            Assert.Equal("type1", obj.Item1.Engine.FuelType);
            Assert.Equal("type1", obj.Item2.FuelType);
            Assert.True(obj.Item2.FuelTypeTest);
            Assert.True(obj.Item2.HasFuel);

            Assert.True(true);
        }
Esempio n. 3
0
        public void Do()
        {
            var airplane = new Airplane {
                Engine = new Engine {
                    FuelType = "123", HasFuel = true
                }
            };

            Assert.Equal("correct fuel", airplane.With(x => airplane)
                         .With(x => x.Engine)
                         .Do(FillupAndTestFuelGrade())
                         .If(x => x.FuelTypeTest)
                         .Return(x => "correct fuel", "bad fuel"));

            airplane.Engine.FuelType = "999";
            Assert.Equal("bad fuel", airplane.With(x => airplane)
                         .With(x => x.Engine)
                         .Do(FillupAndTestFuelGrade())
                         .If(x => x.FuelTypeTest)
                         .Return(x => "correct fuel", "bad fuel"));

            Assert.True(true);
        }