示例#1
0
        public int CreateWorkItem(Dictionary <string, string> values)
        {
            if (ThrowOnCreateBug != null)
            {
                throw ThrowOnCreateBug;
            }

            Logger.InfoFormat("Creating bug:");

            // Generate a random ID
            int id;

            do
            {
                id = _rand.Next(1, int.MaxValue);
            } while (Bugs.ContainsKey(id));

            // Apply defaults
            ApplyDefault(values, "ID", id.ToString());
            ApplyDefault(values, "Title", $"WorkItem {id}");
            ApplyDefault(values, "Assigned To", "Owner");
            ApplyDefault(values, "State", "New");

            Bugs[id] = new Dictionary <string, string>(values);

            CacheWorkItem(id);

            return(id);
        }
示例#2
0
        public void ModifyWorkItem(int workItemId, IIncomingEmailMessage message, Dictionary <string, string> values)
        {
            if (ThrowOnModifyBug != null)
            {
                throw ThrowOnModifyBug;
            }

            if (!Bugs.ContainsKey(workItemId))
            {
                Logger.WarnFormat("Trying to modify non-existing bug {0}. Initializing with no field values", workItemId);
                Bugs[workItemId] = new Dictionary <string, string>();
            }

            var bugEntry = Bugs[workItemId];

            foreach (var key in values.Keys)
            {
                bugEntry[key] = values[key];
            }

            if (!bugEntry.ContainsKey(HistoryField))
            {
                bugEntry[HistoryField] = "";
            }

            bugEntry[HistoryField] += message.GetLastMessageText();
        }
示例#3
0
        public void ModifyWorkItem(int workItemId, string comment, bool commentIsHtml, Dictionary <string, string> values, MessageAttachmentCollection attachments)
        {
            if (ThrowOnModifyBug != null)
            {
                throw ThrowOnModifyBug;
            }

            if (!Bugs.ContainsKey(workItemId))
            {
                Logger.WarnFormat("Trying to modify non-existing bug {0}. Initializing with no field values", workItemId);
                Bugs[workItemId] = new Dictionary <string, string>();
            }

            var bugEntry = Bugs[workItemId];

            foreach (var key in values.Keys)
            {
                bugEntry[key] = values[key];
            }

            if (!bugEntry.ContainsKey(HistoryField))
            {
                bugEntry[HistoryField] = "";
            }

            bugEntry[HistoryField] += comment;
        }
示例#4
0
        public IWorkItemFields GetWorkItemFields(int workItemId)
        {
            if (!Bugs.ContainsKey(workItemId))
            {
                Logger.WarnFormat("Trying to modify non-existing bug {0}", workItemId);
                return(null);
            }

            var bugEntry = Bugs[workItemId];

            return(new WorkItemFieldsMock(bugEntry));
        }
        public long CreateWorkItem(Dictionary <string, string> values, Dictionary <string, string> overrides)
        {
            if (ThrowOnCreateBug != null)
            {
                throw ThrowOnCreateBug;
            }

            Logger.InfoFormat("Creating bug:");

            // Generate a random ID
            int id;

            do
            {
                id = _rand.Next(1, int.MaxValue);
            } while (Bugs.ContainsKey(id));

            Bugs[id] = new Dictionary <string, string>(values);

            CacheWorkItem(id);

            return(id);
        }