public void TestChangeRowsProcessedOutputTypeToData() { Microsoft.SqlServer.Dts.Runtime.Package package = new Microsoft.SqlServer.Dts.Runtime.Package(); Executable exec = package.Executables.Add("STOCK:PipelineTask"); Microsoft.SqlServer.Dts.Runtime.TaskHost thMainPipe = exec as Microsoft.SqlServer.Dts.Runtime.TaskHost; MainPipe dataFlowTask = thMainPipe.InnerObject as MainPipe; ComponentEventHandler events = new ComponentEventHandler(); dataFlowTask.Events = DtsConvert.GetExtendedInterface(events as IDTSComponentEvents); IDTSComponentMetaData100 textFileSplitter = dataFlowTask.ComponentMetaDataCollection.New(); textFileSplitter.Name = "Row Splitter Test"; textFileSplitter.ComponentClassID = typeof(Martin.SQLServer.Dts.TextFileSplitter).AssemblyQualifiedName; CManagedComponentWrapper instance = textFileSplitter.Instantiate(); instance.ProvideComponentProperties(); Boolean exceptionThrown = false; try { instance.SetOutputProperty(textFileSplitter.OutputCollection[3].ID, ManageProperties.typeOfOutput, Utilities.typeOfOutputEnum.DataRecords); } catch (COMException ex) { Assert.AreEqual(MessageStrings.CantChangeOutputProperties("RowsProcessed"), ex.Message, "Exception Message Wrong"); exceptionThrown = true; } Assert.IsTrue(exceptionThrown, "Exception Not Thrown"); }
public override CompoundTerm DoStep(InterpretationContext c, CompoundTerm action) { // Result of invocation must be a value term (must support IComparable) IComparable /*?*/ thisArg; IComparable /*?*/[] methodArgs = this.ConvertTermArgumentsToMethodArguments(c, action.Arguments, out thisArg); foreach (IComparable /*?*/ o in methodArgs) { AbstractValue.FinalizeImport(o); } object /*?*/ resultObj = this.method.methodInfo.Invoke(thisArg, methodArgs); CompoundTerm /*?*/ finishAction = null; // Handle output args and return value if (null != this.finishActionMethod) { int nOutputs = this.finishActionMethod.actionLabel.Arguments.Count; Sequence <Term> outputs = Sequence <Term> .EmptySequence; for (int i = 0; i < nOutputs; i += 1) { int outputArgIndex = this.finishActionMethod.outputArgumentIndices[i]; if (-2 == outputArgIndex) // "any" placeholder { outputs = outputs.AddLast(Any.Value); } else { object output = (-1 == outputArgIndex ? resultObj : methodArgs[outputArgIndex]); IComparable outputAsComparable; if (null == output) { outputAsComparable = null; } else { outputAsComparable = output as IComparable; if (null == outputAsComparable) { throw new InvalidOperationException(MessageStrings.LocalizedFormat(MessageStrings.ComparableResultRequired, action.ToString(), output.ToString())); } } outputs = outputs.AddLast(AbstractValue.GetTerm(outputAsComparable)); } } finishAction = new CompoundTerm(this.FinishAction, outputs); } return(finishAction); }
/// <summary> /// Get returns the value of the provided key stored in the map, provided it exists, otherwise it abrupts; /// Set includes/overrides the key-value pair in the map [Time: log(this.Count)] /// </summary> public S this[T /*!*/ key] { get { S /*?*/ result; bool foundp = TryGetValue(key, out result); if (foundp) { return(result); } else { throw new ArgumentException(MessageStrings.LocalizedFormat(MessageStrings.MapKeyNotFound, key.ToString())); } } }
public IComparable /*?*/ GetValue(InterpretationContext context) { if (!field.IsStatic) { // TO DO: Implement instance field maps Map <LabeledInstance, IComparable /*?*/> result = Map <LabeledInstance, IComparable /*?*/> .EmptyMap; Symbol sort = AbstractValue.TypeSort(field.DeclaringType); foreach (LabeledInstance instance in context.InstancePoolValues(sort)) { object obj = field.GetValue(instance); if (obj == null) { result = result.Add(instance, null); } else { IComparable comparable = obj as IComparable; if ((object)comparable == null) { throw new ArgumentException(MessageStrings.LocalizedFormat(MessageStrings.RuntimeTypeError, typeof(IComparable).ToString(), obj.GetType().ToString())); } result = result.Add(instance, comparable); } } return(result); } else { object obj = field.GetValue(null); if (obj == null) { return(null); } IComparable comparable = obj as IComparable; if ((object)comparable == null) { throw new ArgumentException(MessageStrings.LocalizedFormat(MessageStrings.RuntimeTypeError, typeof(IComparable).ToString(), obj.GetType().ToString())); } return(comparable); } }
[SuppressMessage("Microsoft.Performance", "CA1804:RemoveUnusedLocals")] // want to use "found" var private void InPlaceAdd(T key, S value) { bool added; LobTree <Maplet> newElems = LobTree <Maplet> .Insert(elems, new Maplet(new Pair <T, S>(key, value)), true, out added); if (!added) { S previousValue; bool found = this.TryGetValue(key, out previousValue); //^ assume found; if (!Object.Equals(value, previousValue)) { throw new ArgumentException(MessageStrings.LocalizedFormat(MessageStrings.MapAddInvalidArgument, key.ToString())); } } else { this.count += 1; } this.elems = newElems; this.InvalidateCache(); }
public void TestChangeErrorOutputSetColumnProperty() { Microsoft.SqlServer.Dts.Runtime.Package package = new Microsoft.SqlServer.Dts.Runtime.Package(); Executable exec = package.Executables.Add("STOCK:PipelineTask"); Microsoft.SqlServer.Dts.Runtime.TaskHost thMainPipe = exec as Microsoft.SqlServer.Dts.Runtime.TaskHost; MainPipe dataFlowTask = thMainPipe.InnerObject as MainPipe; ComponentEventHandler events = new ComponentEventHandler(); dataFlowTask.Events = DtsConvert.GetExtendedInterface(events as IDTSComponentEvents); IDTSComponentMetaData100 textFileSplitter = dataFlowTask.ComponentMetaDataCollection.New(); textFileSplitter.Name = "Row Splitter Test"; textFileSplitter.ComponentClassID = typeof(Martin.SQLServer.Dts.TextFileSplitter).AssemblyQualifiedName; CManagedComponentWrapper instance = textFileSplitter.Instantiate(); instance.ProvideComponentProperties(); IDTSOutput100 errorOutput = textFileSplitter.OutputCollection[1]; ManageProperties.AddMissingOutputColumnProperties(errorOutput.OutputColumnCollection[0].CustomPropertyCollection); Boolean exceptionThrown = false; try { instance.SetOutputColumnProperty(errorOutput.ID, errorOutput.OutputColumnCollection[0].ID, ManageProperties.dotNetFormatString, String.Empty); } catch (COMException ex) { Assert.AreEqual(MessageStrings.CantChangeOutputProperties("Error"), ex.Message, "Exception Message Wrong"); exceptionThrown = true; } Assert.IsTrue(exceptionThrown, "Exception Not Thrown"); }
public void CantFindPropertyTest() { VeryfyMessageString(MessageStrings.CantFindProperty("propertyName"), new string[] { "propertyName" }); }
public void DefaultColumnNameTest() { VeryfyMessageString(MessageStrings.DefaultColumnName(77), new string[] { "77" }); }
public void FailedToAssignColumnValueTest() { VeryfyMessageString(MessageStrings.FailedToAssignColumnValue(17, "some data", "column \"First column\" (343)"), new string[] { "17", "some data", "column \"First column\" (343)" }); }
/// <summary> /// Term order. Comparision is based on type and recursively on fields. /// </summary> /// <param name="obj"></param> /// <returns>-1 if less than, 0 if equal, 1 if greater than</returns> /// <exception cref="System.ArgumentException">Thrown if <paramref name="obj"/> is nonnull but is not an <c>CompoundValue</c>.</exception> public override int CompareTo(object /*?*/ obj) //^ requires obj != null ==> obj is IComparable; //^ ensures result == 0 <==> Object.Equals(this, obj); //^ ensures result == -1 || result == 0 || result == 1; { // Case 1: other obj is null if (obj == null) { return(1); // nonnull is bigger than null } CompoundValue other = obj as CompoundValue; if ((object)other == null) { throw new ArgumentException(MessageStrings.LocalizedFormat(MessageStrings.CompoundValueRequired, obj.GetType().ToString())); } // Case 2: types aren't the same, do type comparison in dictionary order Type t1 = this.GetType(); Type t2 = obj.GetType(); if (t1 != t2) { return(t1.ToString().CompareTo(t2.ToString())); } // Case 3: types are the same, look for first field that is not equal IEnumerator <IComparable> fields1 = this.FieldValues().GetEnumerator(); IEnumerator <IComparable> fields2 = other.FieldValues().GetEnumerator(); while (true) { bool hasNext1 = fields1.MoveNext(); bool hasNext2 = fields2.MoveNext(); if (hasNext1 & !hasNext2) { return(1); // longer comes after shorter } if (!hasNext1 & hasNext2) { return(-1); // shorter comes before longer } if (!hasNext1) { return(0); // items are equal } IComparable c1 = fields1.Current as IComparable; IComparable c2 = fields2.Current as IComparable; if (fields1.Current != null && c1 == null) { throw new ArgumentException(MessageStrings.LocalizedFormat(MessageStrings.ComparableTypeRequired, fields1.Current.GetType().ToString())); } if (fields2.Current != null && c2 == null) { throw new ArgumentException(MessageStrings.LocalizedFormat(MessageStrings.ComparableTypeRequired, fields2.Current.GetType().ToString())); } int fieldCompare = HashAlgorithms.CompareValues(c1, c2); if (fieldCompare != 0) { return(fieldCompare); } } }
public void PropertyStringTooLongTest() { VeryfyMessageString(MessageStrings.PropertyStringTooLong("propertyName", "propertyValue"), new string[] { "propertyName", "propertyValue" }); }
/// <summary>Sends a formatted message.</summary> internal void SendMessageID(uint type, MessageStrings msgStr, params string[] messages) { SendMessageID(type, msgStr, string.Join("\0", messages)); }
/// <summary>Sends a formatted message.</summary> /// <param name="msgTxt">Separate multiple messages by null terminators.</param> internal void SendMessageID(uint type, MessageStrings msgStr, byte[] msgTxt) { // TODO: add message filtering once filters are in if (type == (uint)MessageType.Emote) type = 4; FormattedMessageBytes fmb = new FormattedMessageBytes() { StringId = (uint)msgStr, MsgType = type, MsgBytes = msgTxt }; EQRawApplicationPacket fmPack = new EQRawApplicationPacket(AppOpCode.FormattedMessage, _zp.Client.IPEndPoint, fmb.Serialize()); _zp.Client.SendApplicationPacket(fmPack, true); }
internal void SendMessageID(uint type, MessageStrings msgStr) { // TODO: add message filtering once filters are in SimpleMessage sm = new SimpleMessage() { Color = type, StringID = (uint)msgStr }; EQApplicationPacket<SimpleMessage> smPack = new EQApplicationPacket<SimpleMessage>(AppOpCode.SimpleMessage, sm); _zp.Client.SendApplicationPacket(smPack, true); }
public void UnsupportedDataTypeTest() { VeryfyMessageString(MessageStrings.UnsupportedDataType("DT_BYTES"), new string [] { "DT_BYTES" }); }
public void RowOveflowTest() { VeryfyMessageString(MessageStrings.RowOveflow(17, 33, 12), new string[] { "17", "33", "12" }); }
public void MaximumColumnNumberOverflowTest() { VeryfyMessageString(MessageStrings.MaximumColumnNumberOverflow(17, 2000), new string[] { "17", "2000" }); }
public void ParsingBufferOverflowTest() { VeryfyMessageString(MessageStrings.ParsingBufferOverflow(17, 33, 64000), new string[] { "17", "33", "64000" }); }
public void InvalidPropertyValueTest() { VeryfyMessageString(MessageStrings.InvalidPropertyValue("propertyName", "propertyValue"), new string[] { "propertyName", "propertyValue" }); }
internal virtual void InterruptSpell(uint? spellId, MessageStrings? msg) { uint intSpellId = spellId ?? _castingSpell.SpellID; ResetCastingVars(); Spell s = GetSpell((ushort)intSpellId); _log.DebugFormat("{0} has had spell {1} interrupted.", this.Name, s == null ? "None" : s.SpellName); if (intSpellId == 0) // If there is no spell to interrupt, begone return; // TODO: stop bard songs // Get the correct message if one hasn't been specified if (msg == null) msg = s.IsBardSong ? MessageStrings.SONG_ENDS_ABRUPTLY : MessageStrings.INTERRUPT_SPELL; // Signal the mob manager that a spell was interrupted OnSpellCastInterrupted(new InterruptCastEventArgs() { SpellId = intSpellId, Message = msg.Value }); }
public void InvalidConnectionReferenceTest() { VeryfyMessageString(MessageStrings.InvalidConnectionReference("Connection"), new string[] { "Connection" }); }
internal override void InterruptSpell(uint? spellId, MessageStrings? msg) { // TODO: spell casting AI stop casting stuff base.InterruptSpell(spellId, msg); }
public void FileDoesNotExistTest() { VeryfyMessageString(MessageStrings.FileDoesNotExist("c:\\temp\\file.txt"), new string[] { "c:\\temp\\file.txt" }); }