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); }
/// <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); }
/// <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); }
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; }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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; }
public void GivenListOfExistentSchedules(int n) { _schedules = Builder <Schedule> .CreateListOfSize(n) .Random(1) .With(x => x.End = null) .With(x => x.Id = 15668); }
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); }
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>(); }
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>(); }
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>(); }
/// <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; } }
private IType OpConcat(IOperable other) { switch (other) { case MathString str: return(new MathString(value + str.value)); default: return(null); } }
private MathBool OpEquals(IOperable other) { switch (other) { case MathString str: return(str.value.Equals(value) ? MathBool.TRUE : MathBool.FALSE); default: return(MathBool.FALSE); } }
private IType OpXor(IOperable other) { switch (other) { case MathBool b: return(b.value ^ value ? TRUE : FALSE); default: return(null); } }
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); }
private IType OpConcat(IOperable other) { switch (other) { case Tuple tup: return(new Tuple(items.Concat(tup.items).ToArray())); default: return(null); } }
private IType OpConcat(IOperable other) { switch (other) { case Vector vec: return(new Vector(items.Concat(vec.items).ToArray())); default: return(null); } }
private IType OpPlusMinus(IOperable other) { switch (other) { case Number num: return(new UnevaluatedUnion(new IType[] { OpAdd(num), OpSubtract(num) })); default: return(null); } }
private IType OpSubtract(IOperable other) { switch (other) { case Number num: return(new Number(value - num.value)); default: return(null); } }
private MathBool OpNotEquals(IOperable other) { switch (other) { case Number num: return(!Equals(num) ? MathBool.TRUE : MathBool.FALSE); default: return(null); } }
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); }
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); } }
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); } }
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); } }
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); }
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)); }
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); } }