コード例 #1
0
        public static IOperable <T> AreConstructedWith <T>(this IOperable <T> operable, params object[] args)
        {
            var declaration = GetDeclaration(operable);

            declaration.ObjectBuilder.WithConstructorArgs(args);
            return((IOperable <T>)declaration);
        }
コード例 #2
0
        /// <summary>
        /// Sets the value of one of the type's public properties
        /// </summary>
        public static IOperable <T> With <T, TFunc>(this IOperable <T> operable, Func <T, TFunc> func)
        {
            var declaration = GetDeclaration(operable);

            declaration.ObjectBuilder.With(func);
            return((IOperable <T>)declaration);
        }
コード例 #3
0
        /// <summary>
        /// Specify the constructor for the type like this:
        ///
        /// WithConstructor( () => new MyType(arg1, arg2) )
        /// </summary>
        public static IOperable <T> WithConstructor <T>(this IOperable <T> operable, Expression <Func <T> > constructor)
        {
            var declaration = GetDeclaration(operable);

            declaration.ObjectBuilder.WithConstructor(constructor);
            return((IOperable <T>)declaration);
        }
コード例 #4
0
 public static IOperable <T> WithConstructor <T>(this IOperable <T> operable, Func <T> constructor)
 {
     return(operable.WithFactory(constructor));
     //var declaration = GetDeclaration(operable);
     //declaration.ObjectBuilder.WithConstructor(constructor);
     //return (IOperable<T>)declaration;
 }
コード例 #5
0
        /// <summary>
        /// Specify the constructor for the type like this:
        ///
        /// WithFactory( () => new MyType(arg1, arg2) )
        /// </summary>
        public static IOperable <T> WithFactory <T>(this IOperable <T> operable, Func <T> factory)
        {
            var declaration = GetDeclaration(operable);

            declaration.ObjectBuilder.WithFactory(factory);
            return((IOperable <T>)declaration);
        }
コード例 #6
0
        /// <summary>
        /// Performs an action for each item in a list.
        /// </summary>
        public static IOperable <T> DoForEach <T, U>(this IOperable <T> operable, Action <T, U> action, IList <U> list)
        {
            var declaration = GetDeclaration(operable);

            declaration.ObjectBuilder.DoMultiple(action, list);
            return((IOperable <T>)declaration);
        }
コード例 #7
0
        /// <summary>
        /// Sets the value of one of the type's private properties or readonly fields
        /// </summary>
        public static IOperable <T> With <T, TProperty>(this IOperable <T> operable, Expression <Func <T, TProperty> > property, TProperty value)
        {
            var declaration = GetDeclaration(operable);

            declaration.ObjectBuilder.With(property, value);
            return((IOperable <T>)declaration);
        }
コード例 #8
0
        /// <summary>
        /// Performs an action on the object.
        /// </summary>
        public static IOperable <T> Do <T>(this IOperable <T> operable, Action <T, int> action)
        {
            var declaration = GetDeclaration(operable);

            declaration.ObjectBuilder.Do(action);
            return((IOperable <T>)declaration);
        }
コード例 #9
0
        /// <summary>
        /// Sets the indicating content to the current object.
        /// </summary>
        /// <param name="operable">
        /// The new content.
        /// </param>
        public override void SetContent(IOperable operable)
        {
            var algebraicalFranction = (AlgebraicFraction)operable;

            this.Numerator   = algebraicalFranction.Numerator;
            this.Denominator = algebraicalFranction.Denominator;
        }
コード例 #10
0
 public void GivenListOfExistentSchedules(int n)
 {
     _schedules = Builder <Schedule>
                  .CreateListOfSize(n)
                  .Random(1)
                  .With(x => x.End = null)
                  .With(x => x.Id  = 15668);
 }
コード例 #11
0
        public void Fails_when_closing_hour_is_before_opening_hour()
        {
            _availabilities = _availabilities.With(x => x.OpeningTime = LocalTime.Noon)
                              .With(x => x.ClosingTime = LocalTime.Noon.PlusHours(-2));

            var result = PerformAction();

            Assert.IsFalse(result.IsValid);
        }
コード例 #12
0
        public PersistenceExtensionTests()
        {
            persistenceService  = Substitute.For <IPersistenceService>();
            listBuilderImpl     = Substitute.For <IListBuilderImpl <MyClass> >();
            operable            = Substitute.For <IOperable <MyClass>, IDeclaration <MyClass> >();
            singleObjectBuilder = Substitute.For <ISingleObjectBuilder <MyClass> >();

            theList = new List <MyClass>();
        }
コード例 #13
0
        public void SetUp()
        {
            mocks = new MockRepository();
            persistenceService  = mocks.DynamicMock <IPersistenceService>();
            listBuilderImpl     = mocks.DynamicMock <IListBuilderImpl <MyClass> >();
            operable            = mocks.DynamicMultiMock <IOperable <MyClass> >(typeof(IDeclaration <MyClass>));
            singleObjectBuilder = mocks.DynamicMultiMock <ISingleObjectBuilder <MyClass> >();

            theList = new List <MyClass>();
        }
コード例 #14
0
        public void SetUp()
        {
            mocks = new MockRepository();
            persistenceService = mocks.DynamicMock<IPersistenceService>();
            listBuilderImpl = mocks.DynamicMock<IListBuilderImpl<MyClass>>();
            operable = mocks.DynamicMultiMock<IOperable<MyClass>>(typeof(IDeclaration<MyClass>));
            singleObjectBuilder = mocks.DynamicMultiMock<ISingleObjectBuilder<MyClass>>();

            theList = new List<MyClass>();
        }
コード例 #15
0
        /// <summary>
        /// Sets the indicating content to the current object.
        /// </summary>
        /// <param name="operable">
        /// The new operable.
        /// </param>
        public override void SetContent(IOperable operable)
        {
            var p = operable as Polynomial;

            if (p != null)
            {
                this.Coefficient = p.Coefficient;
                this.Monomials   = p.Monomials;
            }
        }
コード例 #16
0
        private IType OpConcat(IOperable other)
        {
            switch (other)
            {
            case MathString str:
                return(new MathString(value + str.value));

            default:
                return(null);
            }
        }
コード例 #17
0
        private MathBool OpEquals(IOperable other)
        {
            switch (other)
            {
            case MathString str:
                return(str.value.Equals(value) ? MathBool.TRUE : MathBool.FALSE);

            default:
                return(MathBool.FALSE);
            }
        }
コード例 #18
0
ファイル: MathBool.cs プロジェクト: TheUnlocked/FAI-Language
        private IType OpXor(IOperable other)
        {
            switch (other)
            {
            case MathBool b:
                return(b.value ^ value ? TRUE : FALSE);

            default:
                return(null);
            }
        }
コード例 #19
0
        private static IDeclaration <T> GetDeclaration <T>(IOperable <T> operable)
        {
            var declaration = operable as IDeclaration <T>;

            if (declaration == null)
            {
                throw new ArgumentException("Must be of type IDeclaration<T>");
            }

            return(declaration);
        }
コード例 #20
0
        private IType OpConcat(IOperable other)
        {
            switch (other)
            {
            case Tuple tup:
                return(new Tuple(items.Concat(tup.items).ToArray()));

            default:
                return(null);
            }
        }
コード例 #21
0
ファイル: Vector.cs プロジェクト: TheUnlocked/FAI-Language
        private IType OpConcat(IOperable other)
        {
            switch (other)
            {
            case Vector vec:
                return(new Vector(items.Concat(vec.items).ToArray()));

            default:
                return(null);
            }
        }
コード例 #22
0
ファイル: Number.cs プロジェクト: TheUnlocked/FAI-Language
        private IType OpPlusMinus(IOperable other)
        {
            switch (other)
            {
            case Number num:
                return(new UnevaluatedUnion(new IType[] { OpAdd(num), OpSubtract(num) }));

            default:
                return(null);
            }
        }
コード例 #23
0
ファイル: Number.cs プロジェクト: TheUnlocked/FAI-Language
        private IType OpSubtract(IOperable other)
        {
            switch (other)
            {
            case Number num:
                return(new Number(value - num.value));

            default:
                return(null);
            }
        }
コード例 #24
0
ファイル: Number.cs プロジェクト: TheUnlocked/FAI-Language
        private MathBool OpNotEquals(IOperable other)
        {
            switch (other)
            {
            case Number num:
                return(!Equals(num) ? MathBool.TRUE : MathBool.FALSE);

            default:
                return(null);
            }
        }
コード例 #25
0
        public void Setup()
        {
            _availabilities = Builder <TimeSlot> .CreateListOfSize(1)
                              .All()
                              .With(x => x.Day         = IsoDayOfWeek.Friday)
                              .With(x => x.OpeningTime = LocalTime.Noon)
                              .With(x => x.ClosingTime = LocalTime.Noon.PlusHours(8));

            _teacher = new Teacher(1);

            _repository = new Mock <IRepository <Teacher> >(MockBehavior.Loose);
            _repository.SetReturnsDefault(_teacher);
        }
コード例 #26
0
ファイル: Number.cs プロジェクト: TheUnlocked/FAI-Language
        private IType OpConcat(IOperable other)
        {
            switch (other)
            {
            case Number num:
                var     log   = 1 + Complex.Log10(num.value);
                Complex floor = new Complex(Math.Floor(log.Real), Math.Floor(log.Imaginary));
                return(new Number(num.value + (value * Complex.Pow(10, floor))));

            default:
                return(null);
            }
        }
コード例 #27
0
ファイル: Number.cs プロジェクト: TheUnlocked/FAI-Language
        private IType OpMultiply(IOperable other)
        {
            switch (other)
            {
            case Number num:
                return(new Number(value * num.value));

            case Vector vec:
                return(vec.BinaryOperators[BinaryOperator.MULTIPLY].Invoke(this));

            default:
                return(null);
            }
        }
コード例 #28
0
ファイル: Number.cs プロジェクト: TheUnlocked/FAI-Language
        private IType OpDivide(IOperable other)
        {
            switch (other)
            {
            case Number num:
                if (num.IsReal && num.value.Real == 0)
                {
                    return(Undefined.Instance);
                }
                return(new Number(value / num.value));

            default:
                return(null);
            }
        }
コード例 #29
0
        public static IOperable <Product> WithWarehouseLocations(this IOperable <Product> operable)
        {
            // First the IOperable object needs to be cast to IDeclaration
            var declaration = operable as IDeclaration <Product>;

            if (declaration == null)
            {
                throw new ArgumentException("Must be of type IDeclaration<Product>");
            }

            // Then you can access the declaration's object builder
            declaration.ObjectBuilder.With(x => x.Location = LocationGenerator.Generate());

            // Return the operable object
            return(operable);
        }
コード例 #30
0
ファイル: Manager.cs プロジェクト: jorgemk85/OneData
        private static DataSet ExecuteStoredProcedure(string tableName, string storedProcedure, QueryOptions queryOptions, Parameter[] parameters)
        {
            if (queryOptions == null)
            {
                queryOptions = new QueryOptions()
                {
                    ConnectionToUse = DefaultConnection
                };
            }
            if (queryOptions.ConnectionToUse == null)
            {
                queryOptions.ConnectionToUse = DefaultConnection;
            }

            IOperable operation = Operation.GetOperationBasedOnConnectionType(ConnectionType);

            return(operation.ExecuteProcedure(tableName, storedProcedure, queryOptions, parameters));
        }
コード例 #31
0
ファイル: Number.cs プロジェクト: TheUnlocked/FAI-Language
        private MathBool OpLessEqual(IOperable other)
        {
            switch (other)
            {
            case Number num:
                if (value.Real != num.value.Real)
                {
                    return((value.Real <= num.value.Real) ? MathBool.TRUE : MathBool.FALSE);
                }
                else
                {
                    return((value.Imaginary <= num.value.Imaginary) ? MathBool.TRUE : MathBool.FALSE);
                }

            default:
                return(null);
            }
        }