public void ValidateSource_ThousandBeforeComma_WithErrors(string source, string target) { //target settings var numberVerifierSettings = NumberVerifierLocalizationsSettings.RequireLocalization(); numberVerifierSettings.Setup(t => t.TargetThousandsComma).Returns(true); // source settings numberVerifierSettings.Setup(s => s.SourceNoSeparator).Returns(true); NumberVerifierLocalizationsSettings.InitSeparators(numberVerifierSettings); var numberVerifierMain = new NumberVerifierMain(numberVerifierSettings.Object); //run initialize method in order to set chosen separators var errorMessage = numberVerifierMain.CheckSourceAndTarget(source, target); Assert.Equal(errorMessage[0].ErrorMessage, PluginResources.Error_DifferentValues); }
public void NormalizeDecimalNumbersComma(string text, string thousandSep, string decimalSep) { // add to settings allow localization and thousnds separators var numberVerifierSettings = SourceSettings.SourceSettingsAndAllowLocalization.SpaceCommaPeriod(); numberVerifierSettings.Setup(d => d.SourceDecimalComma).Returns(true); NumberVerifierLocalizationsSettings.InitSeparators(numberVerifierSettings); var numberVerifierMain = new NumberVerifierMain(numberVerifierSettings.Object); //run initialize method in order to set chosen separators var docPropMock = new Mock <IDocumentProperties>(); numberVerifierMain.Initialize(docPropMock.Object); var normalizedNumber = numberVerifierMain.NormalizedNumber(text, thousandSep, decimalSep, false); Assert.Equal(normalizedNumber, "1d55"); }
public void NormalizeThousandsNumberNoSeparatorSelected(string source, string target) { //target settings var numberVerifierSettings = NumberVerifierLocalizationsSettings.RequireLocalization(); numberVerifierSettings.Setup(t => t.TargetThousandsPeriod).Returns(true); // source settings numberVerifierSettings.Setup(s => s.SourceNoSeparator).Returns(true); NumberVerifierLocalizationsSettings.InitSeparators(numberVerifierSettings); var numberVerifierMain = new NumberVerifierMain(numberVerifierSettings.Object); //run initialize method in order to set chosen separators numberVerifierMain.Initialize(_documentProperties.Object); var errorMessage = numberVerifierMain.CheckSourceAndTarget(source, target); Assert.True(errorMessage.Count == 0); }
public void ValidateMultipleNumbers_WithNoErrors(string source, string target) { // target settings var numberVerifierSettings = NumberVerifierLocalizationsSettings.RequireLocalization(); numberVerifierSettings.Setup(t => t.TargetThousandsComma).Returns(true); // source settings numberVerifierSettings.Setup(t => t.SourceThousandsPeriod).Returns(true); NumberVerifierLocalizationsSettings.InitSeparators(numberVerifierSettings); var numberVerifierMain = new NumberVerifierMain(numberVerifierSettings.Object); // run initialize method in order to set chosen separators var errorMessage = numberVerifierMain.CheckSourceAndTarget(source, target); Assert.True(errorMessage.Count == 0); }
public void CheckFromHindiToArabicInvalid(string source, string target, string sourceLanguage) { // settings var numberVerifierSettings = NumberVerifierRequireLocalizationSettings.HindiNumbers(); numberVerifierSettings.Setup(s => s.HindiNumberVerification).Returns(true); NumberVerifierLocalizationsSettings.InitSeparators(numberVerifierSettings); var numberVerifierMain = new NumberVerifierMain(numberVerifierSettings.Object); //run initialize method in order to set chosen separators numberVerifierMain.Initialize(_documentProperties.Object); var results = numberVerifierMain.GetTargetFromHindiNumbers(source, target, sourceLanguage); if (results.Any()) { Assert.NotEqual(results[0].SourceText, results[0].TargetText); } }
public void CheckNoSeparatorNumbers(string source, string target) { //target settings var numberVerifierSettings = NumberVerifierRequireLocalizationSettings.AllTypesOfSpacesChecked(); // source settings numberVerifierSettings.Setup(s => s.SourceNoSeparator).Returns(true); NumberVerifierLocalizationsSettings.InitSeparators(numberVerifierSettings); var numberVerifierMain = new NumberVerifierMain(numberVerifierSettings.Object); //run initialize method in order to set chosen separators var docPropMock = new Mock <IDocumentProperties>(); numberVerifierMain.Initialize(docPropMock.Object); var errorMessage = numberVerifierMain.CheckSourceAndTarget(source, target); Assert.True(errorMessage.Count == 0); }
public void DecimalSeparatorsComma(string source, string target) { //target settings var numberVerifierSettings = SourceSettingsAndPreventLocalization.SpaceCommaPeriod(); //source settings numberVerifierSettings.Setup(s => s.SourceThousandsComma).Returns(true); numberVerifierSettings.Setup(s => s.SourceDecimalComma).Returns(true); numberVerifierSettings.Setup(s => s.SourceDecimalPeriod).Returns(true); NumberVerifierLocalizationsSettings.InitSeparators(numberVerifierSettings); var numberVerifierMain = new NumberVerifierMain(numberVerifierSettings.Object); //run initialize method in order to set chosen separators numberVerifierMain.Initialize(_documentProperties.Object); var errorMessage = numberVerifierMain.CheckSourceAndTarget(source, target); Assert.True(errorMessage.Count == 0); }
public void ValidateTarget_ThousandsSeparatorsComma_NoSeparatorIsChecked(string source, string target) { //target settings var numberVerifierSettings = NumberVerifierLocalizationsSettings.RequireLocalization(); numberVerifierSettings.Setup(d => d.TargetThousandsComma).Returns(true); //source settings numberVerifierSettings.Setup(s => s.SourceNoSeparator).Returns(true); NumberVerifierLocalizationsSettings.InitSeparators(numberVerifierSettings); var numberVerifierMain = new NumberVerifierMain(numberVerifierSettings.Object); //run initialize method in order to set chosen separators var errorMessage = numberVerifierMain.CheckSourceAndTarget(source, target); Assert.True(errorMessage.Count == 0); }
public void ValidateTargetSpace_NoSeparator_Errors(string source, string target) { //target settings var numberVerifierSettings = NumberVerifierLocalizationsSettings.RequireLocalization(); numberVerifierSettings.Setup(t => t.TargetNoSeparator).Returns(true); numberVerifierSettings.Setup(t => t.TargetThousandsSpace).Returns(false); // source settings numberVerifierSettings.Setup(s => s.SourceNoSeparator).Returns(true); NumberVerifierLocalizationsSettings.InitSeparators(numberVerifierSettings); var numberVerifierMain = new NumberVerifierMain(numberVerifierSettings.Object); //run initialize method in order to set chosen separators numberVerifierMain.Initialize(_documentProperties.Object); var errorMessage = numberVerifierMain.CheckSourceAndTarget(source, target); Assert.Equal(PluginResources.Error_NumbersNotIdentical, errorMessage[0].ErrorMessage); }
public void CheckIfNoSeparatorMethodIsCalled(string text, string thousandSep, string decimalSep, bool noSeparator) { var numberVerifierSettings = SourceSettings.SourceSettingsAndAllowLocalization.SpaceCommaPeriod(); numberVerifierSettings.Setup(d => d.SourceDecimalComma).Returns(true); NumberVerifierLocalizationsSettings.InitSeparators(numberVerifierSettings); var numberVerifierMain = new NumberVerifierMain(numberVerifierSettings.Object); //run initialize method in order to set chosen separators var docPropMock = new Mock <IDocumentProperties>(); numberVerifierMain.Initialize(docPropMock.Object); var normalizedNumber = numberVerifierMain.NormalizedNumber(text, thousandSep, decimalSep, noSeparator); var methodsMock = new Mock <INumberVerifierMethods>(MockBehavior.Strict); methodsMock.Verify(s => s.NormalizeNumberNoSeparator(thousandSep, decimalSep, normalizedNumber), Times.Never); }
public void ValidateSource_ThousandBeforeComma_WithSpaces_CombinedNumbers_NoErrors(string source, string target) { //target settings var numberVerifierSettings = NumberVerifierLocalizationsSettings.RequireLocalization(); numberVerifierSettings.Setup(t => t.TargetThousandsComma).Returns(true); // source settings numberVerifierSettings.Setup(s => s.SourceNoSeparator).Returns(true); numberVerifierSettings.Setup(s => s.CustomsSeparatorsAlphanumerics).Returns(false); NumberVerifierLocalizationsSettings.InitSeparators(numberVerifierSettings); var numberVerifierMain = new NumberVerifierMain(numberVerifierSettings.Object); //run initialize method in order to set chosen separators var errorMessage = numberVerifierMain.CheckSourceAndTarget(source, target); Assert.True(errorMessage.Count == 0); }
public void NormalizeNegativeNumbers(string text, string thousandSep, string decimalSep) { var numberVerifierSettings = SourceSettings.SourceSettingsAndAllowLocalization.CommaPeriod(); numberVerifierSettings.Setup(d => d.SourceDecimalComma).Returns(true); NumberVerifierLocalizationsSettings.InitSeparators(numberVerifierSettings); var numberVerifierMain = new NumberVerifierMain(numberVerifierSettings.Object); //run initialize method in order to set chosen separators numberVerifierMain.Initialize(_documentProperties.Object); var thousandSeparators = numberVerifierMain.AddCustomSeparators(thousandSep, true); var decimalSeparators = numberVerifierMain.AddCustomSeparators(decimalSep, true); var normalizeNumber = NumberVerifierSetup.GetNormalizedNumber(text, thousandSeparators, decimalSeparators, false, false); numberVerifierMain.NormalizeNumbers(normalizeNumber); Assert.Equal("−74,5", $"{normalizeNumber.InitialNumberList[0]}{normalizeNumber.InitialNumberList[1]}"); Assert.Equal("m74m5", $"{normalizeNumber.NormalizedNumberList[0]}{normalizeNumber.NormalizedNumberList[1]}"); }
public string OmitZeroUnchecked(string number) { var numberVerifierSettings = OmitZeroSettings.OmitZeroUncheckedAndAllowLocalization(); var methodsMock = new Mock <INumberVerifierMethods>(MockBehavior.Strict); NumberVerifierLocalizationsSettings.InitSeparators(numberVerifierSettings); var numberVerifierMain = new NumberVerifierMain(numberVerifierSettings.Object); numberVerifierMain.NormalizeAlphanumerics(number, new List <string>(), new List <string>(), ".", ".", false, numberVerifierSettings.Object.SourceOmitLeadingZero); var normalizedNumber = numberVerifierMain.NormalizedNumber(new SeparatorModel { MatchValue = number, ThousandSeparators = ".", DecimalSeparators = ".", NoSeparator = false, CustomSeparators = string.Empty }); methodsMock.Verify(m => m.OmitZero(number), Times.Never); return(normalizedNumber); }
public void CheckForAddedNumbers(string source, string target) { //target settings var numberVerifierSettings = NumberVerifierRequireLocalizationSettings.ThousandsSeparatorsSpaceAndNoBreak(); numberVerifierSettings.Setup(d => d.TargetDecimalPeriod).Returns(true); //source settings numberVerifierSettings.Setup(s => s.SourceThousandsSpace).Returns(true); numberVerifierSettings.Setup(s => s.SourceDecimalPeriod).Returns(true); NumberVerifierLocalizationsSettings.InitSeparators(numberVerifierSettings); var numberVerifierMain = new NumberVerifierMain(numberVerifierSettings.Object); //run initialize method in order to set chosen separators var errorMessage = numberVerifierMain.CheckSourceAndTarget(source, target); Assert.Equal(PluginResources.Error_NumberAdded, errorMessage[0].ErrorMessage); }
public List <ErrorReporting> SourceOmitCheckedTargetChecked(string source, string target) { //source settings var numberVerifierSettings = SourceSettings.SourceSettingsAndAllowLocalization.CommaPeriod(); numberVerifierSettings.Setup(d => d.SourceOmitLeadingZero).Returns(true); numberVerifierSettings.Setup(d => d.SourceDecimalPeriod).Returns(true); numberVerifierSettings.Setup(t => t.TargetOmitLeadingZero).Returns(true); NumberVerifierLocalizationsSettings.InitSeparators(numberVerifierSettings); var numberVerifierMain = new NumberVerifierMain(numberVerifierSettings.Object); //run initialize method in order to set chosen separators var docPropMock = new Mock <IDocumentProperties>(); var errorMessage = numberVerifierMain.CheckSourceAndTarget(source, target); return(errorMessage); }
public void ThousandsSeparatorsNoSeparatorCommaPeriod(string source, string target) { var numberVerifierSettings = SourceSettings.SourceSettingsAndAllowLocalization.CommaPeriod(); numberVerifierSettings.Setup(s => s.SourceNoSeparator).Returns(true); numberVerifierSettings.Setup(s => s.TargetNoSeparator).Returns(true); numberVerifierSettings.Setup(d => d.SourceDecimalComma).Returns(true); numberVerifierSettings.Setup(d => d.TargetDecimalPeriod).Returns(true); numberVerifierSettings.Setup(d => d.TargetThousandsPeriod).Returns(true); NumberVerifierLocalizationsSettings.InitSeparators(numberVerifierSettings); var numberVerifierMain = new NumberVerifierMain(numberVerifierSettings.Object); //run initialize method in order to set chosen separators var docPropMock = new Mock <IDocumentProperties>(); numberVerifierMain.Initialize(docPropMock.Object); var errorMessage = numberVerifierMain.CheckSourceAndTarget(source, target); Assert.True(errorMessage.Count == 0); }
public void ThousandsNumbersAndAlphanumerics(string source, string target) { //target settings var numberVerifierSettings = NumberVerifierRequireLocalizationSettings.CommaPeriod(); numberVerifierSettings.Setup(d => d.TargetDecimalPeriod).Returns(true); //source settings numberVerifierSettings.Setup(s => s.SourceThousandsComma).Returns(true); numberVerifierSettings.Setup(s => s.SourceDecimalComma).Returns(true); NumberVerifierLocalizationsSettings.InitSeparators(numberVerifierSettings); var numberVerifierMain = new NumberVerifierMain(numberVerifierSettings.Object); //run initialize method in order to set chosen separators var docPropMock = new Mock <IDocumentProperties>(); numberVerifierMain.Initialize(docPropMock.Object); var errorMessage = numberVerifierMain.CheckSourceAndTarget(source, target); Assert.True(errorMessage.Count > 0); }
public string NormalizeNoSeparatorNumbers(string text, string thousandSep, string decimalSep, bool noSeparator) { var numberVerifierSettings = SourceSettings.SourceSettingsAndAllowLocalization.SpaceCommaPeriod(); numberVerifierSettings.Setup(d => d.SourceDecimalComma).Returns(true); NumberVerifierLocalizationsSettings.InitSeparators(numberVerifierSettings); var numberVerifierMain = new NumberVerifierMain(numberVerifierSettings.Object); //run initialize method in order to set chosen separators numberVerifierMain.Initialize(_documentProperties.Object); var normalizedNumber = numberVerifierMain.NormalizeNumber(new SeparatorModel { MatchValue = text, ThousandSeparators = thousandSep, DecimalSeparators = decimalSep, NoSeparator = noSeparator, CustomSeparators = string.Empty }); return(normalizedNumber); }
public string OmitZeroChecked(string number) { var numberVerifierSettings = OmitZeroSettings.OmitZeroCheckedAndPreventLocalization(); var methodsMock = new Mock <INumberVerifierMethods>(); NumberVerifierLocalizationsSettings.InitSeparators(numberVerifierSettings); var numberVerifierMain = new NumberVerifierMain(numberVerifierSettings.Object); var normalizeNumber = NumberVerifierSetup.GetNormalizedNumber(number, ".", ".", false, numberVerifierSettings.Object.SourceOmitLeadingZero); numberVerifierMain.NormalizeNumbers(normalizeNumber); var normalizedNumber = numberVerifierMain.NormalizeNumber(new SeparatorModel { MatchValue = number, ThousandSeparators = ".", DecimalSeparators = ".", NoSeparator = false, CustomSeparators = string.Empty }); methodsMock.Setup(x => x.OmitZero(number)); return(normalizedNumber); }
public void ValidateTargetSpace_NoSeparator_Errors(string source, string target) { //target settings var numberVerifierSettings = NumberVerifierLocalizationsSettings.RequireLocalization(); numberVerifierSettings.Setup(t => t.TargetNoSeparator).Returns(true); numberVerifierSettings.Setup(t => t.TargetThousandsSpace).Returns(false); // source settings numberVerifierSettings.Setup(s => s.SourceNoSeparator).Returns(true); NumberVerifierLocalizationsSettings.InitSeparators(numberVerifierSettings); var numberVerifierMain = new NumberVerifierMain(numberVerifierSettings.Object); //run initialize method in order to set chosen separators var errorMessage = numberVerifierMain.CheckSourceAndTarget(source, target); Assert.Collection(errorMessage, em => Assert.Equal(PluginResources.Error_DifferentValues, em.ErrorMessage), em => Assert.Equal(PluginResources.Error_NumberAdded, em.ErrorMessage)); }
public void DecimalSeparatorsCommaInsteadOfPeriodErrorMessage(string source, string target) { //target settings var numberVerifierSettings = NumberVerifierRequireLocalizationSettings.SpaceCommaPeriod(); numberVerifierSettings.Setup(d => d.TargetDecimalPeriod).Returns(true); //source settings numberVerifierSettings.Setup(s => s.SourceThousandsComma).Returns(true); numberVerifierSettings.Setup(s => s.SourceDecimalComma).Returns(true); NumberVerifierLocalizationsSettings.InitSeparators(numberVerifierSettings); var numberVerifierMain = new NumberVerifierMain(numberVerifierSettings.Object); //run initialize method in order to set chosen separators var docPropMock = new Mock <IDocumentProperties>(); numberVerifierMain.Initialize(docPropMock.Object); var errorMessage = numberVerifierMain.CheckSourceAndTarget(source, target); Assert.Equal(errorMessage[0].ErrorMessage, PluginResources.Error_NumbersNotIdentical); }
public void CheckNumbersAreValid(string sourceText, string targetText, string thousandSep, string decimalSep) { // Arrange var numberVerifierSettings = SourceSettings.SourceSettingsAndAllowLocalization.CommaPeriod(); numberVerifierSettings.Setup(d => d.SourceDecimalComma).Returns(false); NumberVerifierLocalizationsSettings.InitSeparators(numberVerifierSettings); var numberVerifierMain = new NumberVerifierMain(numberVerifierSettings.Object); // run initialize method in order to set chosen separators numberVerifierMain.Initialize(_documentProperties.Object); var thousandSeparators = numberVerifierMain.AddCustomSeparators(thousandSep, true); var decimalSeparators = numberVerifierMain.AddCustomSeparators(decimalSep, true); // Act var sourceResult = numberVerifierMain.GetNumbersTuple(sourceText, decimalSeparators, thousandSeparators, false, false); var targetResult = numberVerifierMain.GetNumbersTuple(targetText, decimalSeparators, thousandSeparators, false, false); // Assert Assert.Equal(sourceResult.Item1[0], targetResult.Item1[0]); }
public void NormalizeNegativeNumbers(string text, string thousandSep, string decimalSep) { var numberVerifierSettings = SourceSettings.SourceSettingsAndAllowLocalization.CommaPeriod(); numberVerifierSettings.Setup(d => d.SourceDecimalComma).Returns(true); NumberVerifierLocalizationsSettings.InitSeparators(numberVerifierSettings); var numberVerifierMain = new NumberVerifierMain(numberVerifierSettings.Object); //run initialize method in order to set chosen separators var docPropMock = new Mock <IDocumentProperties>(); numberVerifierMain.Initialize(docPropMock.Object); var normalizedNumberCollection = new List <string>(); var numberCollection = new List <string>(); var thousandSeparators = numberVerifierMain.AddCustomSeparators(thousandSep, true); var decimalSeparators = numberVerifierMain.AddCustomSeparators(decimalSep, true); numberVerifierMain.NormalizeAlphanumerics(text, numberCollection, normalizedNumberCollection, thousandSeparators, decimalSeparators, false, false); Assert.Equal("−74,5", $"{numberCollection[0]}{numberCollection[1]}"); Assert.Equal("m74m5", $"{normalizedNumberCollection[0]}{normalizedNumberCollection[1]}"); }
public void ThousandsSeparatorsNoSeparatorCommaPeriod(string source, string target) { var numberVerifierSettings = SourceSettings.SourceSettingsAndAllowLocalization.CommaPeriod(); numberVerifierSettings.Setup(s => s.SourceNoSeparator).Returns(true); numberVerifierSettings.Setup(s => s.TargetNoSeparator).Returns(true); numberVerifierSettings.Setup(d => d.SourceDecimalPeriod).Returns(true); numberVerifierSettings.Setup(d => d.SourceDecimalComma).Returns(true); numberVerifierSettings.Setup(d => d.TargetDecimalPeriod).Returns(true); numberVerifierSettings.Setup(d => d.TargetThousandsComma).Returns(true); numberVerifierSettings.Setup(d => d.CustomsSeparatorsAlphanumerics).Returns(false); NumberVerifierLocalizationsSettings.InitSeparators(numberVerifierSettings); var numberVerifierMain = new NumberVerifierMain(numberVerifierSettings.Object); var errorMessage = numberVerifierMain.CheckSourceAndTarget(source, target); Assert.Collection(errorMessage, error => Assert.Equal(error.ErrorMessage, PluginResources.Error_DifferentSequences), error => Assert.Equal(error.ErrorMessage, PluginResources.NumberCannotHaveTheSameCharacterAsThousandAndAsDecimalSeparator)); }