Ejemplo n.º 1
0
 public Tickets(Capacity capacity)
 {
     for (int i = 1; i <= capacity; i++)
     {
         _tickets.Add(new Ticket());
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// TODO 保存容量信息
        /// </summary>
        /// <param name="carton"></param>
        /// <returns></returns>
        public bool saveCapacity(Capacity capacity)
        {
            bool          saveMark = true;
            StringBuilder strSql   = new StringBuilder();

            strSql.Append("insert into t_capacity (uuid,capacity_qty,capacity_desc,op_user,create_time)");
            strSql.Append("values(@uuid,@capacityQty,@capacityDesc,@opuser,@createtime)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@uuid",         MySqlDbType.VarChar, 900),
                new MySqlParameter("@capacityQty",  MySqlDbType.Int16,   900),
                new MySqlParameter("@capacityDesc", MySqlDbType.VarChar, 900),
                new MySqlParameter("@opuser",       MySqlDbType.VarChar, 900),
                new MySqlParameter("@createtime",   MySqlDbType.VarChar, 900)
            };
            parameters[0].Value = capacity.Uuid;
            parameters[1].Value = capacity.Capacityqty;
            parameters[2].Value = capacity.Capacitydesc;
            parameters[3].Value = capacity.Opuser;
            parameters[4].Value = capacity.Createtime;
            int rows = SQLHelper.ExecuteNonQuery(SQLHelper.ConnectionString, CommandType.Text, strSql.ToString(), parameters);

            if (rows > 0)
            {
                saveMark = true;
            }
            else
            {
                saveMark = false;
            }
            return(saveMark);
        }
Ejemplo n.º 3
0
 public Port(Direction direction, Capacity capacity, string name, params Type[] allowedConnections)
 {
     this.direction          = direction;
     this.capacity           = capacity;
     this.name               = name;
     this.allowedConnections = allowedConnections;
 }
Ejemplo n.º 4
0
 public void CanReserveIsConsistentAccrossReplays(Capacity sut, Guid id)
 {
     var remaining = sut.Remaining;
     sut.Reserve(remaining, id);
     var result = sut.CanReserve(remaining, id);
     Assert.True(result);
 }
 public void WriteXml(XmlWriter writer)
 {
     writer.WriteAttributeString(inputRateAttributeName, InputRate.ToString(CultureInfo.InvariantCulture));
     writer.WriteAttributeString(outputRateAttributeName, OutputRate.ToString(CultureInfo.InvariantCulture));
     writer.WriteAttributeString(capacityAttributeName, Capacity.ToString(CultureInfo.InvariantCulture));
     writer.WriteAttributeString(accumulatedPowerAttributeName, AccumulatedPower.ToString(CultureInfo.InvariantCulture));
 }
Ejemplo n.º 6
0
        private void describe_()
        {
            describe[Controller.Index] = () =>
            {
                CapacityController controller = null;

                before = () => {
                    var options = new Options()
                    {
                    };
                    controller = new CapacityController(options);
                };

                it["returns positive capacity for MemoryInBytes"] = () =>
                {
                    Capacity capacity = controller.Index();
                    capacity.MemoryInBytes.should_be_greater_than(0);
                };

                it["returns positive capacity for DiskInBytes"] = () =>
                {
                    Capacity capacity = controller.Index();
                    capacity.DiskInBytes.should_be_greater_than(0);
                };

                it["returns positive capacity for MaxContainers"] = () =>
                {
                    Capacity capacity = controller.Index();
                    capacity.MaxContainers.should_be(100);
                };
            };
        }
Ejemplo n.º 7
0
            public override ErrorList Validate()
            {
                var result = new ErrorList();

                result.AddRange(base.Validate());

                if (Identifier != null)
                {
                    Identifier.ForEach(elem => result.AddRange(elem.Validate()));
                }
                if (DescriptionElement != null)
                {
                    result.AddRange(DescriptionElement.Validate());
                }
                if (Type != null)
                {
                    result.AddRange(Type.Validate());
                }
                if (Capacity != null)
                {
                    result.AddRange(Capacity.Validate());
                }
                if (SpecimenQuantity != null)
                {
                    result.AddRange(SpecimenQuantity.Validate());
                }
                if (Additive != null)
                {
                    result.AddRange(Additive.Validate());
                }

                return(result);
            }
Ejemplo n.º 8
0
        public override Expression Build(IEnumerable <Expression> arguments)
        {
            var source          = arguments.First();
            var parameterType   = source.Type.GetGenericArguments()[0];
            var valueParameter  = Expression.Parameter(typeof(object));
            var viewParameter   = Expression.Parameter(typeof(RollingGraphVisualizer));
            var elementVariable = Expression.Variable(parameterType);

            Controller          = new VisualizerController();
            Controller.Capacity = Capacity.GetValueOrDefault();

            var selectedIndex = GraphHelper.SelectIndexMember(elementVariable, IndexSelector, out Controller.IndexLabel);

            Controller.IndexType = selectedIndex.Type;
            if (selectedIndex.Type != typeof(double) && selectedIndex.Type != typeof(string))
            {
                selectedIndex = Expression.Convert(selectedIndex, typeof(double));
            }

            var selectedValues = GraphHelper.SelectDataValues(elementVariable, ValueSelector, out Controller.ValueLabels);
            var showBody       = Expression.Block(new[] { elementVariable },
                                                  Expression.Assign(elementVariable, Expression.Convert(valueParameter, parameterType)),
                                                  Expression.Call(viewParameter, nameof(RollingGraphVisualizer.AddValues), null, selectedIndex, selectedValues));

            Controller.AddValues = Expression.Lambda <Action <object, RollingGraphVisualizer> >(showBody, valueParameter, viewParameter).Compile();
            return(Expression.Call(typeof(RollingGraphBuilder), nameof(Process), new[] { parameterType }, source));
        }
Ejemplo n.º 9
0
        public void loadResources(string custId, string delMatno, string boundType, string workno, string cusPo)
        {
            capacity = capacityService.queryByRelation(custId, delMatno, boundType);
            if (capacity != null)
            {
                this.countBoxQty(capacity.Capacityqty, workno, cusPo);
                this.textBox12.Text = capacity.Capacitydesc;
                this.textBox14.Text = capacity.Capacityqty.ToString();
            }

            codeRule = codeRuleService.queryRuleByCond(custId, delMatno, boundType);  //1代表Carton碼編碼規則
            if (codeRule != null)
            {
                this.textBox2.Text = codeRule.RuleDesc;
            }
            mandUnionFieldTypeList = manRelFieldTypeService.queryFieldListByCond(custId, delMatno, boundType);
            fileRelDel             = fileRelDelService.queryFileRelDelCusNo(custId, delMatno, boundType);
            //下載模板並預覽   1.查询模板是否存在, 若存在不下载  2.若不存在下载模板
            if (fileRelDel != null)
            {
                filePath = modelInfoService.previewModelFile(fileRelDel.FileNo);
                //if (filePath != null)
                //{
                //    string pictureFile = barPrint.PreviewPrintBC(filePath);
                //    this.pictureBox1.Load(pictureFile);
                //}
            }
        }
Ejemplo n.º 10
0
        protected BasePortView(Orientation orientation, Direction direction, Capacity capacity, Type type, IEdgeConnectorListener connectorListener) : base(orientation, direction, capacity, type)
        {
            styleSheets.Add(GraphProcessorStyles.PortViewStyle);

            Icon = new Image();
            Icon.AddToClassList("port-icon");
            Insert(1, Icon);

            visualClass = "Port_" + portType.Name;

            var portLabel = this.Q("type");

            portLabel.pickingMode    = PickingMode.Position;
            portLabel.style.flexGrow = 1;
            bool vertical = orientation == Orientation.Vertical;

            if (vertical)
            {
                portLabel.style.display         = DisplayStyle.None;
                this.Q("connector").pickingMode = PickingMode.Position;
                AddToClassList("vertical");
            }

            m_EdgeConnector = new EdgeConnector <BaseConnectionView>(connectorListener);
            ConnectionViews = new Dictionary <BaseConnection, BaseConnectionView>();
            this.AddManipulator(m_EdgeConnector);
        }
    public float getEfficient(Capacity capacity)
    {
        float result;

        if (capacity is IFireType)
        {
            result = this.fire;
        }
        else if (capacity is IWaterType)
        {
            result = this.water;
        }
        else if (capacity is IPoisonType)
        {
            result = this.poison;
        }
        else if (capacity is IGrassType)
        {
            result = this.grass;
        }
        else
        {
            result = 1.0f;
        }
        return(result);
    }
Ejemplo n.º 12
0
 public void ApplyThrowsOnUnknownMessage(
     Capacity sut,
     IMessage unknownMessage)
 {
     Assert.Throws <ArgumentException>(() =>
                                       sut.Apply(unknownMessage));
 }
Ejemplo n.º 13
0
        public Capacity queryCapacityById(string uuid)
        {
            Capacity      capacity = null;
            StringBuilder strSql   = new StringBuilder();

            strSql.Append("SELECT uuid,capacity_no,capacity_qty,capacity_desc,op_user,create_time,update_user,update_time FROM t_capacity where uuid=@uuid and del_flag is null");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@uuid", MySqlDbType.VarChar, 900),
            };
            parameters[0].Value = uuid;
            DataSet ds = SQLHelper.ExecuteDataset(SQLHelper.ConnectionString, CommandType.Text, strSql.ToString(), parameters);

            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                capacity              = new Capacity();
                capacity.Uuid         = ds.Tables[0].Rows[0]["uuid"].ToString();
                capacity.Capacityno   = ds.Tables[0].Rows[0]["capacity_no"].ToString();
                capacity.Capacityqty  = (int)ds.Tables[0].Rows[0]["capacity_qty"];
                capacity.Capacitydesc = ds.Tables[0].Rows[0]["capacity_desc"].ToString();
                capacity.Opuser       = ds.Tables[0].Rows[0]["op_user"].ToString();
                capacity.Createtime   = ds.Tables[0].Rows[0]["create_time"].ToString();
                capacity.Updateser    = ds.Tables[0].Rows[0]["update_user"].ToString();
                capacity.Updatetime   = ds.Tables[0].Rows[0]["update_time"].ToString();
            }
            return(capacity);
        }
Ejemplo n.º 14
0
        public override bool Equals(object o)
        {
            if (!(o is JobHistory))
            {
                return(false);
            }
            JobHistory v = o as JobHistory;

            if (!Capacity.Equals(v.Capacity))
            {
                return(false);
            }
            if (!Column.Equals(v.Column))
            {
                return(false);
            }
            if (!Enabled.Equals(v.Enabled))
            {
                return(false);
            }
            if (!LastDateFrom.Equals(v.LastDateFrom))
            {
                return(false);
            }
            if (!LastDateTo.Equals(v.LastDateTo))
            {
                return(false);
            }
            if (!LastSearchText.Equals(v.LastSearchText))
            {
                return(false);
            }
            return(true);
        }
Ejemplo n.º 15
0
        private void lbCapacidades_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lbCapacidades.SelectedIndex != -1)
            {
                btnNuevoEntrada.Enabled = true;
                btnNuevoSalida.Enabled  = true;

                btnEditarEntrada.Enabled   = true;
                btnEliminarEntrada.Enabled = true;

                btnEliminarSalida.Enabled = true;
                btnEditarSalida.Enabled   = true;

                btnEditar.Enabled = true;

                this.currentCapacity = wsdlManager.getCapacity(lbCapacidades.SelectedItem.ToString());

                lbParametrosEntrada.Items.Clear();
                lbParametrosSalida.Items.Clear();

                foreach (var item in this.currentCapacity.ParametersIn)
                {
                    lbParametrosEntrada.Items.Add(item.Name);
                }

                foreach (var item in this.currentCapacity.ParametersOut)
                {
                    lbParametrosSalida.Items.Add(item.Name);
                }

                txtDocumentacionMetodo.Text = this.currentCapacity.Documentation;
            }
        }
Ejemplo n.º 16
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAgregarCapacidad_Click(object sender, EventArgs e)
        {
            if (txtCapacidad.Text.Length > 0)
            {
                Capacity capacity = new Capacity();
                capacity.Name = txtCapacidad.Text.Trim();
                this.wsdlManager.Methods.Add(capacity);

                btnNuevoEntrada.Enabled = false;
                btnNuevoSalida.Enabled  = false;

                btnEliminarEntrada.Enabled = false;
                btnEditarEntrada.Enabled   = false;

                btnEliminarSalida.Enabled = false;
                btnEditarSalida.Enabled   = false;

                txtDocumentacionMetodo.Clear();
                txtCapacidad.Clear();
                lbCapacidades.Items.Clear();

                foreach (var item in wsdlManager.Methods)
                {
                    lbCapacidades.Items.Add(item.Name);
                }
            }
            else
            {
                MessageBox.Show("Debe indicar el nombre de la Capacidad");
            }
        }
Ejemplo n.º 17
0
 /// <summary>
 /// Validate the object.
 /// </summary>
 /// <exception cref="Rest.ValidationException">
 /// Thrown if validation fails
 /// </exception>
 public virtual void Validate()
 {
     if (Capacity != null)
     {
         Capacity.Validate();
     }
 }
Ejemplo n.º 18
0
 // Start is called before the first frame update
 void Start()
 {
     myCapacity = Capacity.HIGH;
     RefreshSprite();
     playerController = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <PlayerController>();
     timer            = Random.Range(0f, 1f);
 }
Ejemplo n.º 19
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (OwnerID.Length != 0)
            {
                hash ^= OwnerID.GetHashCode();
            }
            if (Salt.Length != 0)
            {
                hash ^= Salt.GetHashCode();
            }
            if (Capacity != 0UL)
            {
                hash ^= Capacity.GetHashCode();
            }
            if (rules_ != null)
            {
                hash ^= Rules.GetHashCode();
            }
            if (BasicACL != 0)
            {
                hash ^= BasicACL.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Ejemplo n.º 20
0
        public override int GetHashCode()
        {
            // Auto-generated by Visual Studio

            var hashCode = -871570897;

            hashCode = hashCode * -1521134295 + EqualityComparer <byte[]> .Default.GetHashCode(_buffer);

            hashCode = hashCode * -1521134295 + _isOpen.GetHashCode();
            hashCode = hashCode * -1521134295 + _readOnly.GetHashCode();
            hashCode = hashCode * -1521134295 + _length.GetHashCode();
            hashCode = hashCode * -1521134295 + _capacity.GetHashCode();
            hashCode = hashCode * -1521134295 + _position.GetHashCode();
            hashCode = hashCode * -1521134295 + _startIndex.GetHashCode();
            hashCode = hashCode * -1521134295 + _isExpandable.GetHashCode();
            hashCode = hashCode * -1521134295 + IsReadOnly.GetHashCode();
            hashCode = hashCode * -1521134295 + IsOpen.GetHashCode();
            hashCode = hashCode * -1521134295 + Length.GetHashCode();
            hashCode = hashCode * -1521134295 + Capacity.GetHashCode();
            hashCode = hashCode * -1521134295 + Position.GetHashCode();
            hashCode = hashCode * -1521134295 + RemainingBytes.GetHashCode();
            hashCode = hashCode * -1521134295 + StartIndex.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer <byte[]> .Default.GetHashCode(Raw);

            return(hashCode);
        }
Ejemplo n.º 21
0
        private void HandleCapacity()
        {
            float sum;
            float max;

            if (!Environment.AgentNetwork.Any())
            {
                return;
            }

            if (Environment.Schedule.IsWorkingDay)
            {
                max = Environment.AgentNetwork.AllCognitiveAgents()
                      .Count(agent => agent.Cognitive.TasksAndPerformance.CanPerformTask);
                sum = Environment.AgentNetwork.AllCognitiveAgents()
                      .Where(agent => agent.Cognitive.TasksAndPerformance.CanPerformTask)
                      .Select(x => x.Capacity.Initial).Sum();
            }
            else
            {
                max = Environment.AgentNetwork.AllCognitiveAgents()
                      .Count(agent => agent.Cognitive.TasksAndPerformance.CanPerformTaskOnWeekEnds);
                sum = Environment.AgentNetwork.AllCognitiveAgents()
                      .Where(agent => agent.Cognitive.TasksAndPerformance.CanPerformTaskOnWeekEnds)
                      .Select(x => x.Capacity.Initial).Sum();
            }

            var density = new DensityStruct(sum, max, Environment.Schedule.Step);

            Capacity.Add(density);

            SumCapacity.Add(Capacity.Sum(x => x.ActualNumber));
        }
Ejemplo n.º 22
0
        // TODO type might be void if a variable setter has no variable reference; use unknown instead
        Port(Orientation portOrientation, Direction portDirection, Capacity portCapacity, Type type)
            : base(portOrientation, portDirection, portCapacity, type == typeof(void) || type.ContainsGenericParameters ? typeof(Unknown) : type)
        {
            styleSheets.Add(AssetDatabase.LoadAssetAtPath <StyleSheet>(UICreationHelper.templatePath + "Port.uss"));

            RegisterCallback <CustomStyleResolvedEvent>(OnCustomStyleResolved);
        }
Ejemplo n.º 23
0
        public void ReadExternal(BinaryReader input)
        {
            _paramCount = Primitives.ReadU30(input);
            _returnType = Primitives.ReadU30(input);

            _paramType = new ArrayList(Capacity.Max(_paramCount));

            for (uint i = 0; i < _paramCount._value; ++i)
            {
                _paramType.Add(Primitives.ReadU30(input));
            }

            _name  = Primitives.ReadU30(input);
            _flags = input.ReadByte();

            if (HasFlag(HasOptional))
            {
                _optionInfo = new OptionInfo();
                _optionInfo.ReadExternal(input);
            }

            if (HasFlag(HasParamNames))
            {
                //param_info { u30 param_name[param_count] }
                _paramName = new ArrayList(Capacity.Max(_paramCount));

                for (uint i = 0; i < _paramCount._value; ++i)
                {
                    _paramName.Add(Primitives.ReadU30(input));
                }
            }
        }
Ejemplo n.º 24
0
 /// <summary>
 ///     Initialise a constants object
 /// </summary>
 public Constants()
 {
     MotorValues         = new Motor();
     CapacityValues      = new Capacity();
     WarningFactorValues = new WarningFactor();
     WheelsValues        = new WheelsConstants();
 }
Ejemplo n.º 25
0
    public int OnClick()
    {
        int honeyToReturn = 1;

        switch (myCapacity)
        {
        case Capacity.EMPTY:
            Debug.Log("Clicked on Empty Honeycomb!");
            honeyToReturn = 0;
            break;

        case Capacity.LOW:
            myCapacity = Capacity.EMPTY;
            break;

        case Capacity.MEDIUM:
            myCapacity = Capacity.LOW;
            break;

        case Capacity.HIGH:
            myCapacity = Capacity.MEDIUM;
            break;
        }
        RefreshSprite();
        return(honeyToReturn);
    }
Ejemplo n.º 26
0
        public VisualPort(Orientation portOrientation, Direction portDirection, Capacity portCapacity, Type type) : base(portOrientation, portDirection, portCapacity, type)
        {
            styleSheets.Add(Resources.Load <StyleSheet>("Styles/Ports/VisualPort"));

            m_portGraphics = this.Q("connector");
            m_portLabel    = this.Q("type");
        }
Ejemplo n.º 27
0
        protected Port(Orientation portOrientation, Direction portDirection, Capacity portCapacity, Type type)
        {
            // currently we don't want to be styled as .graphElement since we're contained in a Node
            ClearClassList();

            var tpl = EditorGUIUtility.Load("UXML/GraphView/Port.uxml") as VisualTreeAsset;

            tpl.CloneTree(this, null);
            m_ConnectorBox  = this.Q(name: "connector");
            m_ConnectorText = this.Q <Label>(name: "type");
            m_ConnectorText.clippingOptions = ClippingOptions.NoClipping;

            m_ConnectorBoxCap = this.Q(name: "cap");

            m_Connections = new HashSet <Edge>();

            orientation = portOrientation;
            direction   = portDirection;
            portType    = type;
            capacity    = portCapacity;

            AddToClassList("port");
            AddToClassList(portDirection.ToString().ToLower());
            AddStyleSheetPath("StyleSheets/GraphView/Port.uss");
        }
Ejemplo n.º 28
0
 private EditExamCommand(ExamId examId, Capacity capacity, UtcDate registrationStartDate, UtcDate registrationEndDate)
 {
     ExamId   = examId;
     Capacity = capacity;
     RegistrationStartDate = registrationStartDate;
     RegistrationEndDate   = registrationEndDate;
 }
Ejemplo n.º 29
0
        public List <Capacity> queryCapacityAll(string capacityNo)
        {
            List <Capacity> capacityList = null;
            StringBuilder   strSql       = new StringBuilder();

            strSql.Append("SELECT uuid,capacity_no,capacity_qty,capacity_desc,op_user,create_time,update_user,update_time FROM t_capacity where capacity_no like @capacityNo and del_flag is null");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@capacityNo", MySqlDbType.VarChar, 900),
            };
            parameters[0].Value = "%" + capacityNo + "%";
            DataSet ds = SQLHelper.ExecuteDataset(SQLHelper.ConnectionString, CommandType.Text, strSql.ToString(), parameters);

            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                capacityList = new List <Capacity>();
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    Capacity capacity = new Capacity();
                    capacity.Uuid         = dr["uuid"].ToString();
                    capacity.Capacityno   = dr["capacity_no"].ToString();
                    capacity.Capacityqty  = (int)dr["capacity_qty"];
                    capacity.Capacitydesc = dr["capacity_desc"].ToString();
                    capacity.Opuser       = dr["op_user"].ToString();
                    capacity.Createtime   = dr["create_time"].ToString();
                    capacity.Updateser    = dr["update_user"].ToString();
                    capacity.Updatetime   = dr["update_time"].ToString();
                    capacityList.Add(capacity);
                }
            }
            return(capacityList);
        }
Ejemplo n.º 30
0
        public static Capacity CreateCapacity(long ID)
        {
            Capacity capacity = new Capacity();

            capacity.id = ID;
            return(capacity);
        }
Ejemplo n.º 31
0
        /// <summary>
        /// Задает значения по умолчанию (значения по варианту).
        /// </summary>
        private void DefaultValues_Click(object sender, EventArgs e)
        {
            RangeFrom             = 0;
            RangeFromTextBox.Text = RangeFrom.ToString();
            RangeFromChecked      = true;

            RangeTo             = 0.05;
            RangeToTextBox.Text = RangeTo.ToString();
            RangeToChecked      = true;

            StepNumber             = 100;
            StepNumberTextBox.Text = StepNumber.ToString();
            StepNumberChecked      = true;

            InitialCondition             = 0;
            InitialConditionTextBox.Text = InitialCondition.ToString();
            InitialConditionChecked      = true;

            Resistance             = 1000;
            ResistanceTextBox.Text = Resistance.ToString();
            ResistanceChecked      = true;

            Capacity             = Math.Pow(10, -5);
            CapacityTextBox.Text = Capacity.ToString();
            CapacityChecked      = true;

            Voltage             = 10;
            VoltageTextBox.Text = Voltage.ToString();
            VoltageChecked      = true;
        }
Ejemplo n.º 32
0
        public Meeting Schedule(Id meetingId, MeetingDate on, Id venue, Id speaker, Capacity capacity)
        {
            if (on == null)
                throw new ArgumentNullException("on", "A meeting must have a date to be scheduled");

            Tickets tickets = _overbookingPolicy.AllocateTickets(capacity);

            var meeting = new Meeting(on, venue, speaker, tickets, new Version(), meetingId);
            meeting.OpenForRegistration();
            return meeting;
        }
Ejemplo n.º 33
0
        public void ConsumeDoesNotSendReservedEventWhenCapacityIsExceeded(
            [Frozen]Mock<ICapacityRepository> repositoryStub,
            [Frozen]Mock<IChannel<CapacityReservedEvent>> channelMock,
            CapacityGate sut,
            RequestReservationCommand command,
            Capacity capacity)
        {
            repositoryStub
                .Setup(r => r.Read(command.Date.Date))
                .Returns(capacity.ToMaybe());

            sut.Consume(command.WithQuantity(capacity.Remaining + 1));

            channelMock.Verify(c => c.Send(It.IsAny<CapacityReservedEvent>()), Times.Never());
        }
Ejemplo n.º 34
0
        public void ConsumeDoesNotSendRejectEventWhenRequestIsWithinCapacity(
            [Frozen]Mock<ICapacityRepository> repositoryStub,
            [Frozen]Mock<IChannel<ReservationRejectedEvent>> channelMock,
            CapacityGate sut,
            RequestReservationCommand command,
            Capacity capacity)
        {
            repositoryStub
                .Setup(r => r.Read(command.Date.Date))
                .Returns(new[] { capacity });

            sut.Consume(command.WithQuantity(capacity.Remaining));

            channelMock.Verify(c => c.Send(It.IsAny<ReservationRejectedEvent>()), Times.Never());
        }
Ejemplo n.º 35
0
    void Awake()
    {
        IO_DataField.Add(new IO_Capacity() );

        Capacity = new Capacity(((TreeType)DefaultGrup).TreeCapacity, ResourceProduction.sprite);
        Capacity.setMax(((TreeType)DefaultGrup).TreeCapacity);

        Employees.setMaxSize(DefaultGrup.MaxSizeEmployees);

        subject.Add(this);
        if (DefaultGrup.name != "Tree")
        {
            Debug.LogError("System Rozjebany!");
            return;
        }
    }
Ejemplo n.º 36
0
    public static void CapacityTests()
    {
        Capacity objTest = new Capacity();

        try
        {
            objTest.RunTest();
        }
        catch (Exception e)
        {
            Console.WriteLine(" : FAIL The following exception was thorwn in RunTest(): \n" + e.ToString());
            objTest._numErrors++;
            objTest._retValue = 1;
        }

        Assert.Equal(objTest._retValue, 100);
    }
Ejemplo n.º 37
0
        public void ConsumeDoesNotForwardReplayedEvent(
            [Frozen]Mock<ICapacityRepository> repositoryMock,
            [Frozen]Mock<IChannel<CapacityReservedEvent>> capacityChannelMock,
            [Frozen]Mock<IChannel<SoldOutEvent>> soldOutChannelMock,
            CapacityGate sut,
            RequestReservationCommand command,
            Capacity originalCapacity)
        {
            var requestWithinCapacity = command.WithQuantity(originalCapacity.Remaining - 1);
            var newCapacity = originalCapacity.Apply(requestWithinCapacity.ReserveCapacity());

            repositoryMock
                .Setup(r => r.Read(command.Date.Date))
                .Returns(newCapacity.ToMaybe());

            sut.Consume(requestWithinCapacity);

            repositoryMock.Verify(r => r.Append(requestWithinCapacity.Date.Date, It.IsAny<CapacityReservedEvent>()), Times.Never());
            capacityChannelMock.Verify(r => r.Send(It.IsAny<CapacityReservedEvent>()), Times.Never());
            soldOutChannelMock.Verify(r => r.Send(It.IsAny<SoldOutEvent>()), Times.Never());
        }
Ejemplo n.º 38
0
 public void SutIsEquatable(Capacity sut)
 {
     Assert.IsAssignableFrom<IEquatable<Capacity>>(sut);
 }
Ejemplo n.º 39
0
 public void SutEqualsOtherSutWhenBothReservationsAndRemainingAreEqual([Frozen]int remaining, [Frozen]Guid[] ids, Capacity sut, Capacity other)
 {
     Assert.True(sut.Equals(other));
 }
Ejemplo n.º 40
0
 public void ReserveDoesNotThrowWhenQuantityIsLessThanRemaining(Capacity sut, Guid id)
 {
     var lesserQuantity = sut.Remaining - 1;
     Assert.DoesNotThrow(() =>
         sut.Reserve(lesserQuantity, id));
 }
Ejemplo n.º 41
0
 public void ReserveDoesNotHaveSideEffects(Guid id, int quantity, Capacity sut)
 {
     var result = sut.Reserve(quantity, id);
     Assert.NotEqual(result, sut);
 }
Ejemplo n.º 42
0
 public void GetHashCodeReturnsCorrectResult([Frozen]Guid[] ids, Capacity sut)
 {
     var expectedHashCode = ids.Select(g => g.GetHashCode()).Aggregate((x, y) => x ^ y) ^ sut.Remaining.GetHashCode();
     Assert.Equal(expectedHashCode, sut.GetHashCode());
 }
Ejemplo n.º 43
0
 public void CanReserveReturnsTrueWhenQuantityIsEqualToRemaining(Capacity sut, Guid id)
 {
     var result = sut.CanReserve(sut.Remaining, id);
     Assert.True(result);
 }
Ejemplo n.º 44
0
 public void ReserveThrowsWhenQuantityIsGreaterThanRemaining(Capacity sut, Guid id)
 {
     var greaterQuantity = sut.Remaining + 1;
     Assert.Throws<ArgumentOutOfRangeException>(() =>
         sut.Reserve(greaterQuantity, id));
 }
Ejemplo n.º 45
0
 public void ReserveReturnsInstanceWithWithoutDecrementingRemainingWhenIdAlreadyExists([Frozen]Guid[] ids, int quantity, Capacity sut)
 {
     var existingId = ids.First();
     var expectedRemaining = sut.Remaining;
     var result = sut.Reserve(quantity, existingId);
     Assert.Equal(expectedRemaining, result.Remaining);
 }
Ejemplo n.º 46
0
 public void ReserveReturnsInstanceWithCorrectlyDecrementedRemaining(Guid id, int quantity, Capacity sut)
 {
     var expected = sut.Remaining - quantity;
     var result = sut.Reserve(quantity, id);
     Assert.Equal(expected, result.Remaining);
 }
Ejemplo n.º 47
0
        public void ConsumeWritesEventToRepositoryWhenCapacityIsAvailable(
            [Frozen]Mock<ICapacityRepository> repositoryMock,
            CapacityGate sut,
            RequestReservationCommand command,
            Capacity capacity)
        {
            repositoryMock
                .Setup(r => r.Read(command.Date.Date))
                .Returns(capacity.ToMaybe());

            var requestWithinCapacity = command.WithQuantity(capacity.Remaining - 1);
            sut.Consume(requestWithinCapacity);

            var expected = requestWithinCapacity.ReserveCapacity().Id;
            repositoryMock.Verify(r => r.Append(requestWithinCapacity.Date.Date, It.Is<CapacityReservedEvent>(e => e.Id == expected)));
        }
Ejemplo n.º 48
0
 public Tickets Issue(Capacity capacity)
 {
     return new Tickets(capacity);
 }
Ejemplo n.º 49
0
 public bool Equals(Capacity other)
 {
     if (ReferenceEquals(null, other)) return false;
     if (ReferenceEquals(this, other)) return true;
     return other.capacity == capacity;
 }
Ejemplo n.º 50
0
        public void ConsumeSendsSoldOutEventWhenSoldOut(
            [Frozen]Mock<ICapacityRepository> repositoryStub,
            [Frozen]Mock<IChannel<SoldOutEvent>> channelMock,
            CapacityGate sut,
            RequestReservationCommand command,
            Capacity capacity)
        {
            repositoryStub
                .Setup(r => r.Read(command.Date.Date))
                .Returns(capacity.ToMaybe());

            sut.Consume(command.WithQuantity(capacity.Remaining));

            var expected = command.Date.Date;
            channelMock.Verify(c => c.Send(It.Is<SoldOutEvent>(e => e.Date == expected)));
        }
Ejemplo n.º 51
0
 public void CanReserveReturnsFalseWhenQuantityIsGreaterThanRemaining(Capacity sut, Guid id)
 {
     var greaterQuantity = sut.Remaining + 1;
     bool result = sut.CanReserve(greaterQuantity, id);
     Assert.False(result);
 }
Ejemplo n.º 52
0
 public void SutDoesNotEqualArbitraryOtherObject(Capacity sut, object other)
 {
     Assert.False(sut.Equals(other));
 }
Ejemplo n.º 53
0
 public void CanReserveReturnsTrueWhenQuantityIsLessThanRemaining(Capacity sut, Guid id)
 {
     var lesserQuantity = sut.Remaining - 1;
     var result = sut.CanReserve(lesserQuantity, id);
     Assert.True(result);
 }
Ejemplo n.º 54
0
 public void SutDoesNotEqualNullObject(Capacity sut)
 {
     Assert.False(sut.Equals((object)null));
 }
Ejemplo n.º 55
0
 public void RemainingIsCorrect([Frozen]int capacity, Capacity sut)
 {
     Assert.Equal<int>(capacity, sut.Remaining);
 }
Ejemplo n.º 56
0
 public void SutDoesNotEqualNullSut(Capacity sut)
 {
     Assert.False(sut.Equals((Capacity)null));
 }
Ejemplo n.º 57
0
 public void ReserveDoesNotThrowWhenQuantityIsEqualToRemaining(Capacity sut, Guid id)
 {
     Assert.DoesNotThrow(() =>
         sut.Reserve(sut.Remaining, id));
 }
Ejemplo n.º 58
0
 public void SutDoesNotEqualOtherSutWhenDifferentReservationsHaveBeenMade([Frozen]int remaining, Capacity sut, Capacity other)
 {
     Assert.False(sut.Equals(other));
 }
Ejemplo n.º 59
0
 public void ReserveReturnsEquivalentInstanceWhenReplayed(Guid id, int quantity, Capacity sut)
 {
     var expected = sut.Reserve(quantity, id);
     var result = sut.Reserve(quantity, id);
     Assert.Equal(expected, result);
 }
Ejemplo n.º 60
0
 public void SutDoesNotEqualOtherSutWhenRemainingDiffers(Capacity sut, Capacity other)
 {
     Assert.NotEqual(sut.Remaining, other.Remaining);
     Assert.False(sut.Equals(other));
 }