public void BeAbleToReturnASinglePaymentInRepository() { List <IField> emptyFields = new List <IField>(); NumberField field = new NumberField("Monto"); emptyFields.Add(field); IField filledField = field.FillAndClone("100"); List <IField> fullFields = new List <IField>(); fullFields.Add(filledField); Provider provider = new Provider("Antel", 3, emptyFields); Receipt receipt = new Receipt(provider, fullFields, 100); List <Receipt> list = new List <Receipt>(); list.Add(receipt); Payment payment = new Payment(new CashPayMethod(DateTime.Now), 100, list); var mockPaymentService = new Mock <IPaymentService>(); mockPaymentService.Setup(x => x.GetSinglePayment(payment.ID)).Returns(payment); PaymentsController controller = new PaymentsController(mockPaymentService.Object); IHttpActionResult actionResult = controller.GetPayment(payment.ID); OkNegotiatedContentResult <Payment> contentResult = (OkNegotiatedContentResult <Payment>)actionResult; Assert.AreSame(contentResult.Content, payment); }
public void Should_compute_valid_checksum() { // Arrange var schema1 = TestData.CreateSchema(); var schema2 = TestData.CreateSchema(); // Act var case0 = schema1.ComputeHash(); var case1 = schema2.ComputeHash(); var field = new NumberField() { Name = "Foo", Min = 10, Max = 100 }; schema1.Add(field); var case2 = schema1.ComputeHash(); field.Max = 1000; var case3 = schema1.ComputeHash(); // Assert case0.ShouldNotBeNullOrWhiteSpace(); case1.ShouldBe(case0); case2.ShouldNotBe(case0); case3.ShouldNotBe(case2); }
protected override void CreateChildControls() { base.CreateChildControls(); Controls.Clear(); _txtRegisterdName = new TextField { MaxLength = 100 }; _txtCompanyRegNumber = new TextField { MaxLength = 15 }; _txtCompanyRegNumberIssuedByCountry = new CountryList { Width = DropdownListWith }; _txtTexRefNo = new NumberField { NumberTypes = NumberFieldTypes.CIT, MaxLength = 10 }; _ddlTexRefNoIssuedByCountry = new CountryList { Width = DropdownListWith }; Controls.Add(_txtRegisterdName); Controls.Add(_txtCompanyRegNumber); Controls.Add(_txtCompanyRegNumberIssuedByCountry); Controls.Add(_txtTexRefNo); Controls.Add(_ddlTexRefNoIssuedByCountry); }
private bool ParseNumber(Element el) { double val = 0; bool hasDefault = Double.TryParse(el.defaultValue.Trim(), out val); NumberField field = new NumberField { Label = el.label, DefaultValue = val, DefaultValueSpecified = hasDefault, ReadOnly = el.readOnly, Required = el.required, Searchable = el.searchable, ModifyEnabled = el.modifyEnable, HiddenField = el.hiddenField, ClientId = el.clientId, ColumnName = Utils.SafeSQLName(el.label), ResultVisibility = el.resultVisibility, ResultPosition = el.resultPosition, Format = el.format, MinValue = el.minValue ?? 0, MinValueSpecified = el.minValue.HasValue, MaxValue = el.maxValue ?? 0, MaxValueSpecified = el.maxValue.HasValue, Layout = new LayoutPosition { PanelId = el.columns.ToString(), ColNumber = el.columns, RowNumber = el.rows } }; sections.AddCtrl(field); return(true); }
void ReleaseDesignerOutlets() { if (UserField != null) { UserField.Dispose(); UserField = null; } if (NumberField != null) { NumberField.Dispose(); NumberField = null; } if (PasswordField != null) { PasswordField.Dispose(); PasswordField = null; } if (FeedbackLabel != null) { FeedbackLabel.Dispose(); FeedbackLabel = null; } if (TextEditor != null) { TextEditor.Dispose(); TextEditor = null; } }
private NumberField GetNumberFieldItem(FilterHtmlGenerator.Filter filterData, bool isRangeControl) { var config = StandartConfigNumberField(isRangeControl); var maxValue = filterData.MaxValue == null ? (double?)null : Convert.ToDouble(filterData.MaxValue); if (maxValue != null) { config.MaxValue = maxValue.Value; } var numberField = new NumberField(config) { ID = RegistrationControlToRepository( isRangeControl ? UniquePrefixes.EndNumberField : UniquePrefixes.BeginNumberField, filterData, isRangeControl), ClientIDMode = ClientIDMode.Static, DecimalPrecision = filterData.DecimalPrecision }; numberField.CustomConfig.Add(new ConfigItem("rememberMaxValue", maxValue?.ToString() ?? "", ParameterMode.Value)); return(numberField); }
private void SetListeners(FilterHtmlGenerator.Filter filterData, NumberField numberField, bool isRangeControl) { if (!isRangeControl && !string.IsNullOrEmpty(filterData.OnChangedValue)) { numberField.Listeners.Change.Handler += filterData.OnChangedValue; } }
public static NumberField DecodingLong(Stream stream) { var begin = stream.ReadByte(); if (begin != _startInt) { throw new Exception("整数开始字节错误"); } int lengthNeedRead = 0; while (true) { var b = stream.ReadByte(); if (b == _end) { break; } lengthNeedRead++; } stream.Position = stream.Position - lengthNeedRead - 1; byte[] intBuf = new byte[lengthNeedRead]; stream.EnsureRead(intBuf, 0, lengthNeedRead); stream.ReadByte(); var longStr = Encoding.UTF8.GetString(intBuf); if (!long.TryParse(longStr, out long intVal)) { throw new Exception("整数内容的格式错误"); } return(NumberField.Create(intVal)); }
public NumberField Equal(NumberField number) { ////判斷傳入的數字是否為可運算狀態 if (number.CanNotOperated) { if (LastResult == null) { LastResult = number.EraseRedundantPoint(); } return(LastResult = (OperateSelector == null) ? BaseNumber = LastResult : Compute(BaseNumber = LastResult, LastInput)); } if (LastResult == null) { return(LastResult = number.EraseRedundantPoint()); } else { BaseNumber = LastResult; LastInput = number.EraseRedundantPoint(); return(LastResult = Compute(LastResult, number)); } }
/// <summary> /// 等號事件 /// </summary> /// <returns>等號響應</returns> public FrameUpdate Equal() { //這裡的case應該還有更多 if (NumberField != null) { ExpTreeManager.Add(NumberField.Number.Value); NumberField = null; } //result處理 var result = ExpTreeManager.TryGetResult(); var updateString = string.Empty; for (int i = 0; i < result.ExtraRightBracketCount; i++) { updateString += ")"; } //送出結果 updateString += "="; var ans = result.Answer; CurrentAnswer = ans; return(new FrameUpdate(ans.ToString(), new ExpUpdate(removeLength: 0, updateString: updateString))); }
public void FailIfSinglePaymentIdDoesntExistInRepository() { List <IField> emptyFields = new List <IField>(); NumberField field = new NumberField("Monto"); emptyFields.Add(field); IField filledField = field.FillAndClone("100"); List <IField> fullFields = new List <IField>(); fullFields.Add(filledField); Provider provider = new Provider("Antel", 3, emptyFields); Receipt receipt = new Receipt(provider, fullFields, 100); List <Receipt> list = new List <Receipt>(); list.Add(receipt); Payment payment = new Payment(new CashPayMethod(DateTime.Now), 100, list); var mockPaymentService = new Mock <IPaymentService>(); mockPaymentService.Setup(x => x.GetSinglePayment(payment.ID + 1)).Throws(new ArgumentOutOfRangeException()); PaymentsController controller = new PaymentsController(mockPaymentService.Object); IHttpActionResult actionResult = controller.GetPayment(payment.ID + 1); Assert.IsInstanceOfType(actionResult, typeof(NotFoundResult)); }
public void FailIfPostedNewPaymentIsAlreadyInRepository() { List <IField> emptyFields = new List <IField>(); NumberField field = new NumberField("Monto"); emptyFields.Add(field); IField filledField = field.FillAndClone("100"); List <IField> fullFields = new List <IField>(); fullFields.Add(filledField); Provider provider = new Provider("Antel", 3, emptyFields); Receipt receipt = new Receipt(provider, fullFields, 100); List <Receipt> list = new List <Receipt>(); list.Add(receipt); Payment payment = new Payment(new CashPayMethod(DateTime.Now), 100, list); var mockPaymentService = new Mock <IPaymentService>(); mockPaymentService.Setup(x => x.CreatePayment(payment)).Throws(new ArgumentException()); PaymentsController controller = new PaymentsController(mockPaymentService.Object); IHttpActionResult actionResult = controller.PostPayment(payment); Assert.IsInstanceOfType(actionResult, typeof(BadRequestErrorMessageResult)); }
public void ReturnANewNumberFieldWhenFilled() { NumberField numberField = new NumberField("Monto"); IField newNumberField = numberField.FillAndClone("15"); Assert.AreNotSame(numberField, newNumberField); }
public void BeAbleToTellItIsNotEqualToAnotherTypeOfField() { NumberField aNumberField = new NumberField("Monto"); DateField aDateField = new DateField("Fecha"); Assert.IsFalse(aNumberField.Equals(aDateField)); }
public void BeAbleToTellItIsNotEqualToANullObject() { NumberField firstNumberField = new NumberField("Monto"); IField firstNewNumberField = firstNumberField.FillAndClone("2"); Assert.IsFalse(firstNewNumberField.Equals(null)); }
public void BeAbleToReturnItsData() { NumberField numberField = new NumberField("Monto"); string expectedResult = null; Assert.AreEqual(null, numberField.GetData()); }
public void TellItIsNotValidWhenItStoresANumberSmallerOrEqualToZero() { NumberField numberField = new NumberField("Monto"); IField newNumberField = numberField.FillAndClone("0"); Assert.IsFalse(newNumberField.IsValid()); }
public void TellItIsValidWhenItStoresANumberGreaterThanZero() { NumberField numberField = new NumberField("Monto"); IField newNumberField = numberField.FillAndClone("1"); Assert.IsTrue(newNumberField.IsValid()); }
private NumberField AddNumberField(int id) { var field = new NumberField(id, $"my-field-{id}", Partitioning.Invariant); sut.AddField(field); return(field); }
string FigureOutFormFieldType(IFieldType field) { return(field switch { NumberField _ => "number-field", BooleanField _ => "boolean-field", _ => "text-field", });
public async Task Should_not_add_error_if_number_is_valid() { var sut = new NumberField(1, "my-number", Partitioning.Invariant); await sut.ValidateAsync(CreateValue(null), errors); Assert.Empty(errors); }
private NumberField CreateNumberField(string name, string value) { NumberField field = new NumberField(); field.Name = name; field.SetValue(Convert.ToInt32(value)); return(field); }
public void FailIfNameIsWhitespace() { NumberField aNumberField = new NumberField("ID"); List <IField> fields = new List <IField>(); fields.Add(aNumberField); Provider provider = new Provider(" ", 20, fields); }
public void FailIfNameIsNull() { NumberField aNumberField = new NumberField("ID"); List <IField> fields = new List <IField>(); fields.Add(aNumberField); Provider provider = new Provider(null, 20, fields); }
public async Task Should_add_errors_if_value_is_not_valid() { var sut = new NumberField(1, "my-number", Partitioning.Invariant); await sut.ValidateAsync(CreateValue("Invalid"), errors); errors.ShouldBeEquivalentTo( new[] { "<FIELD> is not a valid value." }); }
public void AllowToBeFilled() { NumberField numberField = new NumberField("Monto"); IField newNumberField = numberField.FillAndClone("15"); string expectedResult = "15"; Assert.AreEqual(expectedResult, newNumberField.GetData()); }
public FindFilter KeyBetween(NumberField field, long fromValue, long toValue, bool includeFrom = true, bool includeTo = true) { _numberFilters[field] = new RangeFilter(fromValue, includeFrom ? Filter.OperatorGreaterOrEquals : Filter.OperatorGreater, toValue, includeTo ? Filter.OperatorLessOrEquals : Filter.OperatorLess ); return(this); }
public void Should_get_default_value_from_number_field() { var field = new NumberField(1, "1", Partitioning.Invariant, new NumberFieldProperties { DefaultValue = 12 }); Assert.Equal(12, DefaultValueFactory.CreateDefaultValue(field, Now)); }
public void BeAbleToTellItIsNotEqualToAnotherNumberFieldWithSameNameButDifferentData() { NumberField firstNumberField = new NumberField("Monto"); NumberField secondNumberField = new NumberField("Monto"); IField firstNewNumberField = firstNumberField.FillAndClone("2"); IField secondNewNumberField = secondNumberField.FillAndClone("3"); Assert.IsFalse(firstNewNumberField.Equals(secondNewNumberField)); }
public void BeAbleToTellItIsEqualToAnotherNumberFieldWithSameNameAndData() { NumberField firstNumberField = new NumberField("Monto"); NumberField secondNumberField = new NumberField("Monto"); IField firstNewNumberField = firstNumberField.FillAndClone("2"); IField secondNewNumberField = secondNumberField.FillAndClone("2"); Assert.IsTrue(firstNewNumberField.Equals(secondNewNumberField)); }
protected IStorageNumberField CreateEmptyNumberFieldObject(NumberField field) { var storageService = service.StorageService; return (IStorageNumberField)storageService.GetObjectFactory().CreateEmptyFieldObject(field.GetType()); }
private void OutputNumberValues(NumberField field, StringBuilder sb) { if (field.Values.Count() == 0) { sb.Append("<empty/>\n"); return; } foreach (double numberValue in field.Values) { sb.Append("<number>"); sb.Append(numberValue); sb.Append("</number>\n"); } }
public ComponentType(ItemFields fields, int publicationId) { this.publicationId = publicationId; this.schemaId = (NumberField) fields["schemaId"]; this.templateId = (NumberField) fields["templateId"]; }