private void CreateTestData() {
            schedule = instance.Create.Schedule(TestScheduleName, new Duration(7, Duration.Unit.Days), new Duration(0, Duration.Unit.Days));

            member = instance.Create.Member("test user", "test");
            member.Save();
            
            project = instance.Create.Project(TestProjectName, AssetID.FromToken("Scope:0"), DateTime.Now.Date, schedule);

            iteration = instance.Create.Iteration(project);
            iteration.Activate();

            story1 = CreateStory(instance, "Story 1", project, iteration, instance.LoggedInMember);
            story1.Status.CurrentValue = "Future";
            story1.Save();

            if (dataLayer.EffortTracking.StoryTrackingLevel != EffortTrackingLevel.SecondaryWorkitem) {
                var story1Effort = story1.CreateEffort(EffortAmount);
                story1Effort.Save();
            }

            story2 = CreateStory(instance, "Story 2", project, iteration, member);

            task1 = CreateTask(instance, "Task 1", story1, instance.LoggedInMember);

            if (dataLayer.EffortTracking.StoryTrackingLevel != EffortTrackingLevel.PrimaryWorkitem) {
                var task1Effort = task1.CreateEffort(EffortAmount);
                task1Effort.Save();
            }

            task2 = CreateTask(instance, "Task 2", story1, member);
            task3 = CreateTask(instance, "Task 3", story2, member);
        }
        private static Task CreateTask(V1Instance instance, string name, PrimaryWorkitem parent, Member owner) {
            var task = instance.Create.Task(name, parent);

            task.Owners.Add(owner);
            task.Save();

            return task;
        }
        private static Story CreateStory(V1Instance instance, string name, OmProject project, Iteration iteration, Member owner) {
            var story = instance.Create.Story(name, project);

            if(owner != null) {
                story.Owners.Add(owner);
            }

            story.Iteration = iteration;
            story.Save();

            return story;
        }
 ///<summary>
 /// Create a new Message with a subject and recipient.
 ///</summary>
 ///<param name="subject">Message subject.</param>
 ///<param name="messageBody">Message body.</param>
 ///<param name="recipient">Who this message will go to.</param>
 ///<returns>A newly minted Message that exists in the VersionOne system.</returns>
 public Message Message(string subject, string messageBody, Member recipient) {
     ICollection<Member> recipients = new List<Member> {recipient};
     return Message(subject, messageBody, recipients);
 }
            /// <summary>
            /// Create a new effort record with a value and date, assigned to the given workitem and member
            /// </summary>
            /// <param name="value">The value of the effort record</param>
            /// <param name="item">The workitem to assign the effort record to</param>
            /// <param name="member">The member to assign the effort record to</param>
            /// <param name="date">The date to log the effort record against</param>
            /// <returns>A newly minted Effort Record that exists in the VersionOne system.</returns>
            /// <param name="attributes">Required attributes.</param>
            /// <exception cref="System.InvalidOperationException">Effort Tracking is not enabled.</exception>
            public Effort Effort(double value, Workitem item, Member member, DateTime date,
                IDictionary<string, object> attributes) {
                if(!instance.Configuration.EffortTrackingEnabled) {
                    throw new InvalidOperationException("Effort Tracking is disabled.");
                }

                instance.PreventTrackingLevelAbuse(item);

                var actual = instance.New<Effort>(item);
                actual.Value = value;
                actual.Member = member;
                actual.Date = date;
                AddAttributes(actual, attributes);
                actual.Save();
                return actual;
            }
 /// <summary>
 /// Create a new effort record with a value and date, assigned to the given workitem and member
 /// </summary>
 /// <param name="value">The value of the effort record</param>
 /// <param name="item">The workitem to assign the effort record to</param>
 /// <param name="member">The member to assign the effort record to</param>
 /// <param name="date">The date to log the effort record against</param>
 /// <returns>A newly minted Effort Record that exists in the VersionOne system.</returns>
 /// <exception cref="System.InvalidOperationException">Effort Tracking is not enabled.</exception>
 public Effort Effort(double value, Workitem item, Member member, DateTime date) {
     return Effort(value, item, member, date, null);
 }
 /// <summary>
 /// Create a new member entity with a name, short name, and default role
 /// </summary>
 /// <param name="name">The full name of the user.</param>
 /// <param name="shortName">An alias or nickname used throughout the VersionOne user interface.</param>
 /// <param name="defaultRole">The new user's default role on projects.</param>
 /// <param name="attributes">Required attributes.</param>
 /// <returns>A newly minted Member that exists in the VersionOne system.</returns>
 public Member Member(string name, string shortName, Role defaultRole,
     IDictionary<string, object> attributes) {
     var member = new Member(instance) {
         Name = name, 
         ShortName = shortName, 
         DefaultRole = defaultRole
     };
     AddAttributes(member, attributes);
     member.Save();
     return member;
 }
            /// <summary>
            /// Add new Conversation.
            /// </summary>
            /// <param name="author">Author of Conversation.</param>
            /// <param name="content">Content of Conversation.</param>
            /// <param name="attributes">Additional attributes that should be set for Conversation</param>
            /// <returns>Newly created Conversation.</returns>
            public Conversation Conversation(Member author, string content, IDictionary<string, object> attributes) {
                var conversation = new Conversation(instance) {
                    Author = author, 
                    AuthoredAt = DateTime.UtcNow, 
                    Content = content
                };
                AddAttributes(conversation, attributes);
                conversation.Save();

                return conversation;
            }
 /// <summary>
 /// Add new Conversation.
 /// </summary>
 /// <param name="author">Author of Conversation.</param>
 /// <param name="content">Content of Conversation.</param>
 /// <returns>Newly created Conversation.</returns>
 public Conversation Conversation(Member author, string content) {
     return Conversation(author, content, null);
 }
 /// <summary>
 /// Add new Expression
 /// </summary>
 /// <param name="author">Author of Expression</param>
 /// <param name="content">Content of Expression</param>
 /// <param name="belongsTo">Conversation This Expression belongs to</param>
 /// <param name="inReplyTo">The Expression being replied To</param>
 /// <returns></returns>
 public Expression Expression(Member author, string content, Conversation belongsTo, Expression inReplyTo = null)
 {
     return Expression(author, content, null, belongsTo, inReplyTo);
 }
 /// <summary>
 /// Log an effort record against this workitem with the given member, date, and value
 /// </summary>
 /// <param name="member"></param>
 /// <param name="date"></param>
 /// <param name="value"></param>
 /// <returns></returns>
 /// <exception cref="System.InvalidOperationException">Effort Tracking is not enabled.</exception>
 public Effort CreateEffort(Member member, DateTime date, double value) {
     return Instance.Create.Effort(value, this, member, date);
 }
 /// <summary>
 /// Creates conversation which mentioned this member.
 /// </summary>
 /// <param name="author">Author of conversation.</param>
 /// <param name="content">Content of conversation</param>
 /// <returns>Created conversation.</returns>
 public override Conversation CreateConversation(Member author, string content) {
     var conversation = Instance.Create.Conversation(author, content);
     conversation.Mentions.Add(this);
     conversation.Save();
     return conversation;
 }
            /// <summary>
            /// Add new Expression
            /// </summary>
            /// <param name="author">Author of Expression</param>
            /// <param name="content">Content of Expression</param>
            /// <param name="attributes">Additional attributes that should be set for Expression</param>
            /// <param name="belongsTo">Conversation This Expression belongs to</param>
            /// <param name="inReplyTo">The Expression being replied To</param>
            /// <returns></returns>
            public Expression Expression(Member author, string content, IDictionary<string, object> attributes, Conversation belongsTo, Expression inReplyTo)
            {
                var expression = new Expression(instance)
                {
                    Author = author,
                    AuthoredAt = DateTime.UtcNow,
                    Content = content,
                };

                if (belongsTo != null) expression.BelongsTo = belongsTo;
                if (inReplyTo != null) expression.InReplyTo = inReplyTo;

                AddAttributes(expression, attributes);
                expression.Save();
                return expression;
            }
 ///<summary>
 /// Create a new Message with a subject and recipient.
 ///</summary>
 ///<param name="subject">Message subject.</param>
 ///<param name="messageBody">Message body.</param>
 ///<param name="recipient">Who this message will go to.</param>
 ///<param name="attributes">Required attributes.</param>
 ///<returns>A newly minted Message that exists in the VersionOne system.</returns>
 public Message Message(string subject, string messageBody, Member recipient,
     IDictionary<string, object> attributes) {
     ICollection<Member> recipients = new List<Member> {recipient};
     return Message(subject, messageBody, recipients, attributes);
 }
 /// <summary>
 /// Log an effort record against this workitem with the given member, date, and value
 /// </summary>
 /// <param name="member"></param>
 /// <param name="date"></param>
 /// <param name="value"></param>
 /// <param name="attributes">required attributes</param>
 /// <returns></returns>
 /// <exception cref="System.InvalidOperationException">Effort Tracking is not enabled.</exception>
 public Effort CreateEffort(Member member, DateTime date, double value, IDictionary<string, object> attributes) {
     return Instance.Create.Effort(value, this, member, date, attributes);
 }
 /// <summary>
 /// Creates conversation which mentioned this asset.
 /// </summary>
 /// <param name="author">Author of conversation.</param>
 /// <param name="content">Content of conversation</param>
 /// <returns>Created conversation.</returns>
 public virtual Conversation CreateConversation(Member author, string content) {
     var conversation = Instance.Create.Conversation(author, content);
     foreach (Expression containedExpression in conversation.ContainedExpressions)
     {
         containedExpression.Mentions.Add(this);
     }
     conversation.Save();
     return conversation;
 }
 /// <summary>
 /// Add new Conversation with One Expression
 /// </summary>
 /// <param name="author">Author of Conversation Expression.</param>
 /// <param name="content">Content of Conversation Expression.</param>
 /// <param name="attributes">Additional attributes that should be set for Conversation</param>
 /// <returns>Newly created Conversation.</returns>
 public Conversation Conversation(Member author, string content, IDictionary<string, object> attributes)
 {
     var conversation = new Conversation(instance);                
     conversation.Save();
     var expression = Expression(author, content, attributes, conversation, null);
     if (attributes != null) AddAttributes(conversation, attributes);
     expression.Save();
     return instance.Get.ConversationByID(conversation.ID);
 }