Example #1
0
        public void TestEnumDoubleRange()
        {
            var a1 = EnumerableUtil.RangeSteps(0.0, 1.0, 0).ToArray();

            Assert.AreEqual(0, a1.Length);

            var a2 = EnumerableUtil.RangeSteps(0.0, 1.0, 1).ToArray();

            Assert.AreEqual(1, a2.Length);
            Assert.AreEqual(0.0, a2[0]);

            var a3 = EnumerableUtil.RangeSteps(0.0, 1.0, 2).ToArray();

            Assert.AreEqual(2, a3.Length);
            Assert.AreEqual(0.0, a3[0]);
            Assert.AreEqual(1.0, a3[1]);

            var a4 = EnumerableUtil.RangeSteps(0.0, 1.0, 3).ToArray();

            Assert.AreEqual(3, a4.Length);
            Assert.AreEqual(0.0, a4[0]);
            Assert.AreEqual(0.5, a4[1]);
            Assert.AreEqual(1.0, a4[2]);

            var a5 = EnumerableUtil.RangeSteps(0.0, 1.0, 5).ToArray();

            Assert.AreEqual(5, a5.Length);
            Assert.AreEqual(0.0, a5[0]);
            Assert.AreEqual(0.25, a5[1]);
            Assert.AreEqual(0.50, a5[2]);
            Assert.AreEqual(0.75, a5[3]);
            Assert.AreEqual(1.0, a5[4]);
        }
Example #2
0
        public void Riak_Can_Generate_Key()
        {
            MapResponse r = SaveMap();

            Assert.True(EnumerableUtil.NotNullOrEmpty((string)r.Key));
            Log.DebugFormat("Riak Generated Key: {0}", r.Key);
        }
        public int Remove(params object[] keys)
        {
            var _keys = new _ColumnWithValue[0];

            EnumerableUtil.Each(keys, y => {
                _keys = EnumerableUtil.ToArray(
                    EnumerableUtil.UnionAll(
                        _keys,
                        EnumerableUtil.Except(
                            EnumerableUtil.Join(
                                EnumerableUtil.Where(this._Columns, x => x.IsKey || x.IsForeignKey),
                                EnumerableUtil.Where(_Column.GetColumns(y.GetType()), x => x.IsKey),
                                x => x.Alias ?? x.Name,
                                x => x.Alias ?? x.Name,
                                (o, i) => new _ColumnWithValue(o, i, y)),
                            _keys,
                            EnumerableUtil.CreateComparer <_ColumnWithValue>((a, b) => a.EntityColumn.Name == b.EntityColumn.Name))));
            });

            var _predicate = string.Empty;

            EnumerableUtil.Each(_keys, x => _predicate += $"AND {x.EntityColumn.Name}=? ");

            return(this.Execute(
                       $"DELETE FROM {this._Table} WHERE 1=1 {_predicate}",
                       EnumerableUtil.ToArray(
                           EnumerableUtil.Select(_keys, x => x.ForeignValue))));
        }
 public static IEnumerable <_Column> GetColumns(Type type)
 {
     return
         (EnumerableUtil.Where(
              EnumerableUtil.Select(type.GetProperties(), x => {
         var _column = EnumerableUtil.FirstOrDefault(x.GetCustomAttributes(typeof(ColumnAttribute), false)) as ColumnAttribute;
         var _key = EnumerableUtil.FirstOrDefault(x.GetCustomAttributes(typeof(KeyAttribute), false)) as KeyAttribute;
         var _foreignKey = EnumerableUtil.FirstOrDefault(x.GetCustomAttributes(typeof(ForeignKeyAttribute), false)) as ForeignKeyAttribute;
         if (_column != null)
         {
             return new _Column {
                 Name = _column.Name,
                 Alias = _column.Alias,
                 PropertyInfo = x,
                 KeyInfo = _key != null ? new _Key {
                     Method = _key.DatabaseGenerated, Expresion = _key.Expresion, Size = _key.Size, Order = _key.Order
                 } : null,
                 ForeignKeyInfo = _foreignKey != null ? new _ForeignKey {
                     Name = _foreignKey.Name, PropertyInfo = EnumerableUtil.FirstOrDefault(typeof(T).GetProperties(BindingFlags.Instance | BindingFlags.Public), p => p.Name == _foreignKey.Name)
                 } : null
             };
         }
         return null;
     }),
              x => x != null));
 }
        public void GroupByCountTest_Dynamic_4()
        {
            var items         = new int[] { 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000 };
            var sizes         = new int[] { 3, 0, 0, 0, 0, 0, 0, 0, 0, 7 };
            var grouped_items =
                EnumerableUtil.GroupByCount(items, sizes, size => new List <int>(size),
                                            (list, index, item) => list.Add(item)).ToList();

            Assert.AreEqual(10, grouped_items.Count);
            Assert.AreEqual(10, grouped_items.Select(g => g.Count()).Sum());
            Assert.AreEqual(3, grouped_items[0].Count);
            Assert.AreEqual(0, grouped_items[1].Count);
            Assert.AreEqual(0, grouped_items[2].Count);
            Assert.AreEqual(0, grouped_items[3].Count);
            Assert.AreEqual(0, grouped_items[4].Count);
            Assert.AreEqual(0, grouped_items[5].Count);
            Assert.AreEqual(0, grouped_items[6].Count);
            Assert.AreEqual(0, grouped_items[7].Count);
            Assert.AreEqual(0, grouped_items[8].Count);
            Assert.AreEqual(7, grouped_items[9].Count);
            Assert.AreEqual(100, grouped_items[0][0]);
            Assert.AreEqual(200, grouped_items[0][1]);
            Assert.AreEqual(300, grouped_items[0][2]);
            Assert.AreEqual(400, grouped_items[9][0]);
            Assert.AreEqual(500, grouped_items[9][1]);
            Assert.AreEqual(600, grouped_items[9][2]);
            Assert.AreEqual(700, grouped_items[9][3]);
            Assert.AreEqual(800, grouped_items[9][4]);
            Assert.AreEqual(900, grouped_items[9][5]);
            Assert.AreEqual(1000, grouped_items[9][6]);
        }
        public void Chunkify_1()
        {
            var items1  = new[] { 0, 1, 2, 3, 4, 5, 6, 7 };
            var chunks1 = EnumerableUtil.Chunkify(items1, 1);

            Assert.AreEqual(items1.Length, chunks1.Count);
            Assert.AreEqual(items1.Length, chunks1.Select(c => c.Count).Sum());

            var items2  = new[] { 0, 1, 2, 3, 4, 5, 6, 7 };
            var chunks2 = EnumerableUtil.Chunkify(items2, 3);

            Assert.AreEqual(3, chunks2.Count);
            Assert.AreEqual(3, chunks2[0].Count);
            Assert.AreEqual(3, chunks2[1].Count);
            Assert.AreEqual(2, chunks2[2].Count);

            var items3  = new[] { 0, 1, 2, 3, 4, 5 };
            var chunks3 = EnumerableUtil.Chunkify(items3, 3);

            Assert.AreEqual(2, chunks3.Count);
            Assert.AreEqual(3, chunks3[0].Count);
            Assert.AreEqual(3, chunks3[1].Count);

            var items4  = new[] { 0, 1, 2, 3, 4, 5, 6 };
            var chunks4 = EnumerableUtil.Chunkify(items4, 3);

            Assert.AreEqual(3, chunks4.Count);
            Assert.AreEqual(3, chunks4[0].Count);
            Assert.AreEqual(3, chunks4[1].Count);
            Assert.AreEqual(1, chunks4[2].Count);
        }
Example #7
0
        private SetResponse SaveSet(string key = null)
        {
            var updateBuilder = new UpdateSet.Builder(DefaultAdds, null)
                                .WithBucketType(BucketType)
                                .WithBucket(Bucket)
                                .WithTimeout(TimeSpan.FromMilliseconds(20000));

            if (!string.IsNullOrEmpty(key))
            {
                updateBuilder.WithKey(key);
            }

            UpdateSet  cmd  = updateBuilder.Build();
            RiakResult rslt = client.Execute(cmd);

            Assert.IsTrue(rslt.IsSuccess, rslt.ErrorMessage);

            SetResponse response = cmd.Response;

            Keys.Add(response.Key);

            Assert.True(EnumerableUtil.NotNullOrEmpty(response.Context));

            return(response);
        }
Example #8
0
        public void EnumPairsTest()
        {
            var a_in  = new int[] {};
            var a_out = EnumerableUtil.SelectPairs(a_in).ToArray();

            Assert.AreEqual(0, a_out.Length);

            var b_in  = new int[] { 0 };
            var b_out = EnumerableUtil.SelectPairs(b_in).ToArray();

            Assert.AreEqual(0, b_out.Length);

            var c_in  = new int[] { 0, 1 };
            var c_out = EnumerableUtil.SelectPairs(c_in).ToArray();

            Assert.AreEqual(1, c_out.Length);

            var d_in  = new int[] { 0, 1, 2 };
            var d_out = EnumerableUtil.SelectPairs(d_in).ToArray();

            Assert.AreEqual(1, d_out.Length);

            Assert.AreEqual(0, d_out[0].Item1);
            Assert.AreEqual(1, d_out[0].Item2);

            var e_in  = new int[] { 0, 1, 2, 3 };
            var e_out = EnumerableUtil.SelectPairs(e_in).ToArray();

            Assert.AreEqual(2, e_out.Length);

            Assert.AreEqual(0, e_out[0].Item1);
            Assert.AreEqual(1, e_out[0].Item2);
            Assert.AreEqual(2, e_out[1].Item1);
            Assert.AreEqual(3, e_out[1].Item2);
        }
        private void Reduce()
        {
            var gridSize = Grids.GetSize();
            var points   = EnumerableUtil.Rectangle(gridSize);

            var flagPoints = points.Where(t => Grids[t.X, t.Y] == Grid.Flag).ToArray();

            foreach (var flagPoint in flagPoints)
            {
                var surroundingPoints = flagPoint.Surrounding().Where(t => gridSize.Contains(t));
                foreach (var surroundingPoint in surroundingPoints)
                {
                    var surroundingValue = Grids[surroundingPoint.X, surroundingPoint.Y];
                    if (surroundingValue.IsNumber())
                    {
                        var reducedValue = surroundingValue - 1;
                        Grids[surroundingPoint.X, surroundingPoint.Y] = reducedValue;
                    }
                }

                Grids[flagPoint.X, flagPoint.Y] = Grid.None;
            }

            var questionPoints = points.Where(t => Grids[t.X, t.Y] == Grid.Question).ToArray();

            foreach (var questionPoint in questionPoints)
            {
                Grids[questionPoint.X, questionPoint.Y] = Grid.Raw;
            }
        }
Example #10
0
        /// <summary>
        /// Returns a hash code for the current object.
        /// Uses a combination of the public properties to generate a unique hash code.
        /// </summary>
        /// <returns>A hash code for the current object.</returns>
        public override int GetHashCode()
        {
            if (EnumerableUtil.IsNullOrEmpty(cells))
            {
                return(base.GetHashCode());
            }

            unchecked
            {
                int  result = 1;
                bool hashed = false;

                if (EnumerableUtil.NotNullOrEmpty(cells))
                {
                    hashed = true;
                    foreach (Cell cell in cells)
                    {
                        result = (result * 397) ^ cell.GetHashCode();
                    }
                }

                if (!hashed)
                {
                    result = base.GetHashCode();
                }

                return(result);
            }
        }
Example #11
0
        public IconScanner(params Icon[] icons)
        {
            if (icons == null)
            {
                throw new ArgumentNullException();
            }
            if (icons.Length <= 1)
            {
                throw new ArgumentException();
            }

            this.icons = icons;

            var maxWidth      = icons.Max(t => t.IntegerMap.Size.Width);
            var maxHeight     = icons.Max(t => t.IntegerMap.Size.Height);
            var scannerPoints = EnumerableUtil.Rectangle(maxWidth, maxHeight).Select(point =>
            {
                var validIcons   = icons.Where(icon => icon.IntegerMap.Size.Contains(point)).ToArray();
                var invalidIcons = icons.Except(validIcons).ToArray();

                var pixelLookup   = validIcons.ToLookup(t => t.IntegerMap[point.X, point.Y]);
                var scannerValues = pixelLookup.Select(t => new IconScannerValue {
                    Pixel = t.Key, Icons = t.Concat(invalidIcons).ToArray()
                });

                return(new IconScannerPoint {
                    Point = point, Values = scannerValues.ToArray()
                });
            }).ToArray();

            this.scannerPoints = ReduceScannerPoints(scannerPoints).ToArray();
        }
        public IEnumerable <T> Get(params object[] keys)
        {
            var _cols = new _ColumnWithValue[0];

            EnumerableUtil.Each(keys, y => {
                _cols = EnumerableUtil.ToArray(
                    EnumerableUtil.UnionAll(
                        _cols,
                        EnumerableUtil.Except(
                            EnumerableUtil.Join(
                                EnumerableUtil.Where(this._Columns, x => x.IsForeignKey),
                                EnumerableUtil.Where(_Column.GetColumns(y.GetType()), x => x.IsKey),
                                x => x.Alias ?? x.Name,
                                x => x.Alias ?? x.Name,
                                (o, i) => new _ColumnWithValue(o, i, y)),
                            _cols,
                            EnumerableUtil.CreateComparer <_ColumnWithValue>((a, b) => a.EntityColumn.Name == b.EntityColumn.Name))));
            });

            var _predicate = string.Empty;

            EnumerableUtil.Each(_cols, x => _predicate += $"AND {x.EntityColumn.Name}=? ");

            return(this.ToEnumerable(
                       this._SqlSelect + _predicate,
                       EnumerableUtil.ToArray(
                           EnumerableUtil.Select(_cols, x => x.ForeignValue))));
        }
Example #13
0
        /// <summary>
        /// Method used to validate a server certificate
        /// </summary>
        /// <param name="sender">The sender</param>
        /// <param name="certificate">The server certificate</param>
        /// <param name="chain">The X509 certificate chain</param>
        /// <param name="sslPolicyErrors">The set of errors according to SSL policy</param>
        /// <returns>boolean indicating validity of server certificate</returns>
        public bool ServerCertificateValidationCallback(
            object sender,
            X509Certificate certificate,
            X509Chain chain,
            SslPolicyErrors sslPolicyErrors)
        {
            if (sslPolicyErrors == SslPolicyErrors.None)
            {
                return(true);
            }

            /*
             * Inspired by the following:
             * http://msdn.microsoft.com/en-us/library/office/dd633677%28v=exchg.80%29.aspx
             * http://stackoverflow.com/questions/22076184/how-to-validate-a-certificate
             *
             * First, ensure we've got a cert authority file
             */
            if (certificateAuthorityCert != null)
            {
                if ((sslPolicyErrors & SslPolicyErrors.RemoteCertificateChainErrors) != 0)
                {
                    // This ensures the presented cert is for the current host
                    if (EnsureServerCertificateSubject(certificate.Subject))
                    {
                        if (chain != null && chain.ChainStatus != null)
                        {
                            foreach (X509ChainStatus status in chain.ChainStatus)
                            {
                                if (status.Status == X509ChainStatusFlags.UntrustedRoot &&
                                    EnumerableUtil.NotNullOrEmpty(chain.ChainElements))
                                {
                                    // The root cert must not be installed but we provided a file
                                    // See if anything in the chain matches our root cert
                                    foreach (X509ChainElement chainElement in chain.ChainElements)
                                    {
                                        if (chainElement.Certificate.Equals(certificateAuthorityCert))
                                        {
                                            return(true);
                                        }
                                    }
                                }
                                else
                                {
                                    if (status.Status != X509ChainStatusFlags.NoError)
                                    {
                                        // If there are any other errors in the certificate chain, the certificate is invalid,
                                        // so immediately returns false.
                                        return(false);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return(false);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="UpdateCommand{TResponse}"/> class.
 /// </summary>
 /// <param name="options">Options for this operation. See <see cref="UpdateMapOptions"/></param>
 public UpdateCommand(UpdateCommandOptions options)
     : base(options)
 {
     if (this.CommandOptions.HasRemoves &&
         EnumerableUtil.IsNullOrEmpty(this.CommandOptions.Context))
     {
         throw new InvalidOperationException("When doing any removes a context must be provided.");
     }
 }
Example #15
0
        public TsTtbMsg(byte[] buffer)
        {
            if (EnumerableUtil.IsNullOrEmpty(buffer))
            {
                throw new ArgumentNullException("buffer");
            }

            this.buffer = buffer;
        }
        public VfpApplicationControl()
        {
            #region Подписываемся на события, отмеченные аттрибутом VfpProcessedAttribute

            foreach (EventInfo _event in this.GetType().GetEvents(BindingFlags.Public | BindingFlags.Instance))
            {
                if (_event.GetCustomAttributes(typeof(VfpProcessedAttribute), false).Length > 0)
                {
                    _EventDispatcher.AddEventDispatcher(this, _event, this._DefaultEventHandler);
                }
            }

            #endregion

            this._services.Bind <_IoC.IConfiguration, _Configuration>();
            this._services.Bind <IInstanceFactory>(this._services.CreateInstance <_InstanceFactory>(x => x("container", this._services)));
            this._services.Bind <IBinder>(this._services.CreateInstance <_Binder>(x => x("container", this._services)));
            this._services.Bind <IProxy>(this._proxy = this._services.CreateInstance <ProxyService>(x => x("handler", new EventHandler(this._ExternalInvokeHandler))));
            this._services.Bind(typeof(IWin32Window), this);

            this._services.Load(this.GetType().Assembly);

            this.Externals = new Dictionary <Type, _VfpExternalComponent>();

            #region Добавляем требуемые внешние компоненты

            foreach (VfpExternalRequiredAttribute _attr in this.GetType().GetCustomAttributes(typeof(VfpExternalRequiredAttribute), false))
            {
                this.Externals.Add(_attr.Type, this._services.CreateInstance(_attr.Type) as _VfpExternalComponent);
            }

            #endregion

            #region Внедряем зависимости в открытые свойства

            EnumerableUtil.Each(
                EnumerableUtil.Where(
                    this.GetType().GetProperties(),
                    x => x.IsDefined(typeof(ServiceRequiredAttribute), false)),
                x => x.SetValue(this, this.GetServiceCore(x.PropertyType), null));

            #endregion

            #region Внедряем зависимости в закрытые свойства базовых типов

            for (var _type = this.GetType().BaseType; _type != null && _type != typeof(VfpApplicationControl).BaseType; _type = _type.BaseType)
            {
                EnumerableUtil.Each(
                    EnumerableUtil.Where(
                        _type.GetProperties(BindingFlags.Instance | BindingFlags.NonPublic),
                        x => x.IsDefined(typeof(ServiceRequiredAttribute), false)),
                    x => x.SetValue(this, this.GetServiceCore(x.PropertyType), null));
            }

            #endregion
        }
        public void GroupByCountTest_Fixed_2()
        {
            var items         = new int[] { 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000 };
            var grouped_items =
                EnumerableUtil.GroupByCount(items, 2, size => new List <int>(size), (list, count, item) => list.Add(item))
                .ToList();

            Assert.AreEqual(5, grouped_items.Count);
            Assert.AreEqual(10, grouped_items.Select(g => g.Count()).Sum());
        }
Example #18
0
            public Builder WithColumns(ICollection <Column> columns)
            {
                if (EnumerableUtil.IsNullOrEmpty(columns))
                {
                    throw new ArgumentNullException("columns", "columns are required");
                }

                this.columns = columns;
                return(this);
            }
Example #19
0
        public Cell(byte[] value)
        {
            if (EnumerableUtil.IsNullOrEmpty(value))
            {
                throw new ArgumentNullException("value", "Value must not be null or empty. Use the zero-arg ctor for null cells.");
            }

            varcharValue = value;
            valueType    = ColumnType.Blob;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="GetResponse"/> class.
        /// </summary>
        /// <param name="key">A <see cref="Row"/> representing the key.</param>
        /// <param name="columns">The columns for the fetched TS data.</param>
        /// <param name="values">The rows for the fetched TS data.</param>
        public GetResponse(Row key, IEnumerable <Column> columns, IEnumerable <Row> values)
            : base(key, values)
        {
            if (EnumerableUtil.IsNullOrEmpty(values))
            {
                isNotFound = true;
            }

            this.columns = columns;
        }
Example #21
0
            public Builder WithRows(ICollection <Row> rows)
            {
                if (EnumerableUtil.IsNullOrEmpty(rows))
                {
                    throw new ArgumentNullException("rows", "rows are required");
                }

                this.rows = rows;
                return(this);
            }
Example #22
0
        public IEnumerable <Tuple <Point, Icon> > QuickScan(IntegerMap targetMap)
        {
            var points = EnumerableUtil.Rectangle(targetMap.Size);
            var reads  = points.Select(point =>
            {
                var icon = QuickRead(targetMap, point);
                return(Tuple.Create(point, icon));
            });

            return(reads.Where(t => t.Item2 != null));
        }
        private IEnumerable <PointMutation> GetPointMutationsForIndex(int index)
        {
            var removedPointPolygons    = ListUtil.Singleton((PointMutation) new DeletedPoint(index));
            var changedPointPolygons    = MutatePoint(index);
            var insertedPointPolygons   = EnumerableUtil.From(0).Select(i => InsertPoint(index));
            var changedInserted         = EnumerableUtil.ConcatUtil(changedPointPolygons, insertedPointPolygons);
            var changedInsertedDiagonal = Diagonalizes.DiagonalizeListRateEmpty(changedInserted, 2).ConcatUtil().Select(xs => CombineAddedChangedMutations(xs.ToLazyList()));
            var combined = removedPointPolygons.Concat(changedInsertedDiagonal);

            return(combined);
        }
Example #24
0
        public void EnumeratorTest()
        {
            var expected = new string[] { "aaa", "bbb", "ccc" };
            var i        = 0;

            foreach (var s in EnumerableUtil.Enumerator("aaa", "bbb", "ccc"))
            {
                Assert.AreEqual(expected[i++], s);
            }
            Assert.AreEqual(i, 3);
        }
Example #25
0
        private IEnumerable <Chain <Point> > GetChains(StrategyBoard board)
        {
            var numberPoints         = EnumerableUtil.Rectangle(board.Size).Where(t => board.Grids[t.X, t.Y].IsNumber());
            var surroundingRawPoints = numberPoints.Select(numberPoint =>
            {
                var surroundingPoints = numberPoint.Surrounding().Where(t => board.Size.Contains(t));
                return(surroundingPoints.Where(t => board.Grids[t.X, t.Y] == Grid.Raw).ToChain());
            });

            return(MergeChains(surroundingRawPoints).Distinct());
        }
 public virtual void TestFixtureTearDown()
 {
     if (EnumerableUtil.NotNullOrEmpty(Keys))
     {
         foreach (string key in Keys)
         {
             var id = new RiakObjectId(BucketType, Bucket, key);
             client.Delete(id);
         }
     }
 }
Example #27
0
        public IEnumerable <T> ToEnumerable(IDataReader reader, params Common.Action <T>[] rowCallbacks)
        {
            var _result = new List <T>();

            while (reader.Read())
            {
                var _item = this.ToEntity(reader);
                EnumerableUtil.Each(rowCallbacks, x => x(_item));
                _result.Add(_item);
            }
            return(_result);
        }
Example #28
0
        public void CommitHooksAreStoredAndLoadedProperly()
        {
            // when we load, the commit hook lists should be null
            RiakResult <RiakBucketProperties> result = Client.GetBucketProperties(bucket);

            result.IsSuccess.ShouldBeTrue(result.ErrorMessage);

            RiakBucketProperties props = result.Value;

            props.PreCommitHooks.ShouldBeNull();
            props.PostCommitHooks.ShouldBeNull();

            // we then store something in each
            props.AddPreCommitHook(new RiakJavascriptCommitHook("Foo.doBar"))
            .AddPreCommitHook(new RiakErlangCommitHook("my_mod", "do_fun"))
            .AddPostCommitHook(new RiakErlangCommitHook("my_other_mod", "do_more"));

            var propResult = Client.SetBucketProperties(bucket, props);

            propResult.IsSuccess.ShouldBeTrue(propResult.ErrorMessage);

            // load them out again and make sure they got loaded up
            Func <RiakResult <RiakBucketProperties> > getFunc = () =>
            {
                result = Client.GetBucketProperties(bucket);
                result.IsSuccess.ShouldBeTrue(result.ErrorMessage);
                return(result);
            };

            Func <RiakResult <RiakBucketProperties>, bool> successFunc = (r) =>
            {
                bool rv = false;

                RiakBucketProperties p = r.Value;
                if (EnumerableUtil.NotNullOrEmpty(p.PreCommitHooks) &&
                    EnumerableUtil.NotNullOrEmpty(p.PostCommitHooks))
                {
                    rv    = true;
                    props = p;
                }

                return(rv);
            };

            getFunc.WaitUntil(successFunc);

            props.PreCommitHooks.ShouldNotBeNull();
            props.PreCommitHooks.Count.ShouldEqual(2);
            props.PostCommitHooks.ShouldNotBeNull();
            props.PostCommitHooks.Count.ShouldEqual(1);

            Client.DeleteBucket(bucket);
        }
Example #29
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Store"/> class.
        /// </summary>
        /// <param name="options">Options for this operation. See <see cref="StoreOptions"/></param>
        public Store(StoreOptions options)
            : base(options)
        {
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            if (EnumerableUtil.IsNullOrEmpty(options.Rows))
            {
                throw new ArgumentNullException("Rows", "Rows can not be null or empty");
            }
        }
Example #30
0
        protected override DtOp GetRequestOp()
        {
            var op = new DtOp();

            op.hll_op = new HllOp();

            if (EnumerableUtil.NotNullOrEmpty(hllOptions.Additions))
            {
                op.hll_op.adds.AddRange(hllOptions.Additions);
            }

            return(op);
        }