예제 #1
0
        public void SetActiveSprint()
        {
            // In-memory database only exists while the connection is open
            var connection = new SqliteConnection("DataSource=:memory:");

            connection.Open();
            try
            {
                var options = new DbContextOptionsBuilder <ScrumContext>()
                              .UseSqlite(connection)
                              .Options;

                // Create the schema in the database
                using (var context = new ScrumContext(options))
                {
                    context.Database.EnsureCreated();
                }

                // Run the test against one instance of the context
                using (var context = new ScrumContext(options))
                {
                    var        service    = new GroupRepository(context);
                    SprintList sprintList = new SprintList();
                    sprintList.groupID = -1;
                    sprintList.currentlyActiveSprint = 1;
                    var set = service.SetActiveSprint(sprintList);
                    Assert.AreEqual(true, set);
                    Assert.AreEqual(1, context.SprintLists.Find(-1).CurrentlyActiveSprint);
                }
            }
            finally
            {
                connection.Close();
            }
        }
예제 #2
0
        public void GetAllUsernames()
        {
            // In-memory database only exists while the connection is open
            var connection = new SqliteConnection("DataSource=:memory:");

            connection.Open();
            try
            {
                var options = new DbContextOptionsBuilder <ScrumContext>()
                              .UseSqlite(connection)
                              .Options;

                // Create the schema in the database
                using (var context = new ScrumContext(options))
                {
                    context.Database.EnsureCreated();
                }

                // Run the test
                using (var context = new ScrumContext(options))
                {
                    var service   = new GroupRepository(context);
                    var usernames = service.GetAllUsernames();
                    Assert.AreEqual(0, usernames.Count);
                }
            }
            finally
            {
                connection.Close();
            }
        }
예제 #3
0
        public void RemoveUserStoryFromSprint()
        {
            // In-memory database only exists while the connection is open
            var connection = new SqliteConnection("DataSource=:memory:");

            connection.Open();
            try
            {
                var options = new DbContextOptionsBuilder <ScrumContext>()
                              .UseSqlite(connection)
                              .Options;

                // Create the schema in the database
                using (var context = new ScrumContext(options))
                {
                    context.Database.EnsureCreated();
                }

                // Run the test against one instance of the context
                using (var context = new ScrumContext(options))
                {
                    var       service   = new GroupRepository(context);
                    UserStory userStory = new UserStory("user story message", 3, 0, -1);
                    userStory.storyId = 1;
                    bool removed = service.RemoveUserStoryFromSprint(userStory);
                    Assert.AreEqual(true, removed);
                    Assert.AreEqual(-1, context.UserStories.Find(1).SprintId);
                }
            }
            finally
            {
                connection.Close();
            }
        }
예제 #4
0
        public bool Add(Stories inStories)
        {
            using (var context = new ScrumContext())
            {
                try
                {
                    if (inStories.ElementType == GeneralVariable.ElementType.NewStory.GetHashCode())
                    {
                        foreach (var item in context.Stories)
                        {
                            if (item.Position == inStories.Position)
                            {
                                context.Stories.Remove(item);
                            }
                        }
                    }
                    context.Stories.Add(inStories);
                    if (context.SaveChanges() > 0)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    //logFile.CatchError("YS7TRyVYHUmRS10GOQYEw", ex);

                    return(false);
                }
            }
        }
예제 #5
0
        public void LoadProductBacklog()
        {
            // In-memory database only exists while the connection is open
            var connection = new SqliteConnection("DataSource=:memory:");

            connection.Open();
            try
            {
                var options = new DbContextOptionsBuilder <ScrumContext>()
                              .UseSqlite(connection)
                              .Options;

                // Create the schema in the database
                using (var context = new ScrumContext(options))
                {
                    context.Database.EnsureCreated();
                }

                // Run the test against one instance of the context
                using (var context = new ScrumContext(options))
                {
                    var       service   = new GroupRepository(context);
                    UserStory userStory = new UserStory("user story message", 3, 0, 1);
                    bool      added     = service.AddStory(userStory);
                    Assert.AreEqual(true, added);
                    var PB      = service.LoadProductBacklog(1);
                    var message = PB.userStories[1].userStory;
                    Assert.AreEqual(message, context.UserStories.Find(2).Story);
                }
            }
            finally
            {
                connection.Close();
            }
        }
예제 #6
0
        public void LoadSprintBacklog()
        {
            // In-memory database only exists while the connection is open
            var connection = new SqliteConnection("DataSource=:memory:");

            connection.Open();
            try
            {
                var options = new DbContextOptionsBuilder <ScrumContext>()
                              .UseSqlite(connection)
                              .Options;

                // Create the schema in the database
                using (var context = new ScrumContext(options))
                {
                    context.Database.EnsureCreated();
                }

                // Run the test against one instance of the context
                using (var context = new ScrumContext(options))
                {
                    var service = new GroupRepository(context);
                    var sprint  = service.LoadSprintBacklog(1, 1);
                    Assert.AreEqual(sprint.sprintId, context.UserStories.Find(1).SprintId);
                }
            }
            finally
            {
                connection.Close();
            }
        }
예제 #7
0
        public void GetGroupInformation()
        {
            // In-memory database only exists while the connection is open
            var connection = new SqliteConnection("DataSource=:memory:");

            connection.Open();
            try
            {
                var options = new DbContextOptionsBuilder <ScrumContext>()
                              .UseSqlite(connection)
                              .Options;

                // Create the schema in the database
                using (var context = new ScrumContext(options))
                {
                    context.Database.EnsureCreated();
                }

                // Run the test against one instance of the context
                using (var context = new ScrumContext(options))
                {
                    var service = new GroupRepository(context);
                    var session = service.GetGroupInformation("dave");
                    Assert.AreEqual(session.username, "dave");
                    Assert.AreEqual(session.groupId, 0);
                    Assert.AreEqual(session.groupRole, null);
                }
            }
            finally
            {
                connection.Close();
            }
        }
예제 #8
0
        public void CreateAccount()
        {
            // In-memory database only exists while the connection is open
            var connection = new SqliteConnection("DataSource=:memory:");

            connection.Open();
            try
            {
                var options = new DbContextOptionsBuilder <ScrumContext>()
                              .UseSqlite(connection)
                              .Options;

                // Create the schema in the database
                using (var context = new ScrumContext(options))
                {
                    context.Database.EnsureCreated();
                }

                // Run the test against one instance of the context
                using (var context = new ScrumContext(options))
                {
                    var service  = new GroupRepository(context);
                    var oldValue = context.Users.Count();
                    var created  = service.CreateAccount("florian", "admin3");
                    Assert.AreEqual(true, created);
                    Assert.AreEqual(oldValue + 1, context.Users.Count());
                }
            }
            finally
            {
                connection.Close();
            }
        }
예제 #9
0
 public List <Stories> GetAll()
 {
     using (var context = new ScrumContext())
     {
         try
         {
             return(context.Stories.OrderBy(s => s.ProcessDate).ToList());
         }
         catch (Exception ex)
         {
             Console.WriteLine(ex.Message);
             //logFile.CatchError("YS7TRyVYHUmRS10GOQYEw", ex);
             return(null);
         }
     }
 }
예제 #10
0
        public void CreateGroup()
        {
            // In-memory database only exists while the connection is open
            var connection = new SqliteConnection("DataSource=:memory:");

            connection.Open();
            try
            {
                var options = new DbContextOptionsBuilder <ScrumContext>()
                              .UseSqlite(connection)
                              .Options;

                // Create the schema in the database
                using (var context = new ScrumContext(options))
                {
                    context.Database.EnsureCreated();
                }

                // Run the test against one instance of the context
                using (var context = new ScrumContext(options))
                {
                    var         service     = new GroupRepository(context);
                    Group       group       = new Group();
                    GroupMember groupMember = new GroupMember();
                    groupMember.user.username = "******";
                    groupMember.role          = "Developer";

                    GroupMember groupMember2 = new GroupMember();
                    groupMember2.user.username = "******";
                    groupMember2.role          = "Product Owner";
                    group.AddMember(groupMember);
                    group.AddMember(groupMember2);

                    var created = service.CreateGroup(group);
                    Assert.AreEqual(true, created);
                    // Assert.AreEqual(2, context.GroupMembers.Count());
                    // Assert.AreEqual(2, context.GroupMembers.Find("Andrew").GroupId);
                }
            }
            finally
            {
                connection.Close();
            }
        }
예제 #11
0
        public void RemoveMember_AddMember()
        {
            // In-memory database only exists while the connection is open
            var connection = new SqliteConnection("DataSource=:memory:");

            connection.Open();
            try
            {
                var options = new DbContextOptionsBuilder <ScrumContext>()
                              .UseSqlite(connection)
                              .Options;

                // Create the schema in the database
                using (var context = new ScrumContext(options))
                {
                    context.Database.EnsureCreated();
                }

                // Run the test against one instance of the context
                using (var context = new ScrumContext(options))
                {
                    var service = new GroupRepository(context);
                    var user    = new User {
                        username = "******"
                    };
                    GroupMember groupMember = new GroupMember {
                        user = user, role = "Developer", groupID = 1
                    };
                    var added        = service.AddMember(groupMember);
                    var existingItem = context.GroupMembers.Any(x => x.Username.Equals("Andrew"));
                    Assert.AreEqual(true, existingItem);
                    bool removed     = service.RemoveMember(groupMember);
                    bool removedItem = context.GroupMembers.Any(x => x.Username.Equals("Andrew"));
                    Assert.AreEqual(false, removedItem);
                    Assert.AreEqual(true, removed);
                }
            }
            finally
            {
                connection.Close();
            }
        }
예제 #12
0
        public void ChangeRole()
        {
            // In-memory database only exists while the connection is open
            var connection = new SqliteConnection("DataSource=:memory:");

            connection.Open();
            try
            {
                var options = new DbContextOptionsBuilder <ScrumContext>()
                              .UseSqlite(connection)
                              .Options;

                // Create the schema in the database
                using (var context = new ScrumContext(options))
                {
                    context.Database.EnsureCreated();
                }

                // Run the test against one instance of the context
                using (var context = new ScrumContext(options))
                {
                    var  service = new GroupRepository(context);
                    User user    = new User();
                    user.username = "******";
                    GroupMember groupMember = new GroupMember();
                    groupMember.user    = user;
                    groupMember.role    = "Product Owner";
                    groupMember.groupID = 1;
                    service.AddMember(groupMember);
                    Assert.AreEqual("Product Owner", context.GroupMembers.Find("dave").GroupRole);
                    groupMember.role = "Scrum Master";
                    service.ChangeRole(groupMember);
                    Assert.AreEqual("Scrum Master", context.GroupMembers.Find("dave").GroupRole);
                }
            }
            finally
            {
                connection.Close();
            }
        }
예제 #13
0
        public void LoadGroup()
        {
            // In-memory database only exists while the connection is open
            var connection = new SqliteConnection("DataSource=:memory:");

            connection.Open();
            try
            {
                var options = new DbContextOptionsBuilder <ScrumContext>()
                              .UseSqlite(connection)
                              .Options;

                // Create the schema in the database
                using (var context = new ScrumContext(options))
                {
                    context.Database.EnsureCreated();
                }

                // Run the test against one instance of the context
                using (var context = new ScrumContext(options))
                {
                    var service = new GroupRepository(context);

                    GroupMember groupMember = new GroupMember();
                    groupMember.user.username = "******";
                    groupMember.groupID       = 1;
                    groupMember.role          = "Scrum Master";
                    var added = service.AddMember(groupMember);
                    var group = service.LoadGroup(1);
                    Assert.AreEqual(true, added);
                    Assert.AreEqual(1, context.GroupMembers.Count());
                    // Assert.AreEqual(group.GetGroupMembers()[0].user.username, context.GroupMembers.Find("jaime").Username);
                }
            }
            finally
            {
                connection.Close();
            }
        }
예제 #14
0
        public void AddTaskToUserStory()
        {
            // In-memory database only exists while the connection is open
            var connection = new SqliteConnection("DataSource=:memory:");

            connection.Open();
            try
            {
                var options = new DbContextOptionsBuilder <ScrumContext>()
                              .UseSqlite(connection)
                              .Options;

                // Create the schema in the database
                using (var context = new ScrumContext(options))
                {
                    context.Database.EnsureCreated();
                }

                // Run the test against one instance of the context
                using (var context = new ScrumContext(options))
                {
                    var       service   = new GroupRepository(context);
                    UserStory userStory = new UserStory("user story message", 3, 0, -1);
                    userStory.storyId = 1;
                    Tasks task = new Tasks("task message", 5);
                    task.TaskId    = 1;
                    task.Completed = false;
                    bool added = service.AddTaskToUserStory(task);
                    Assert.AreEqual(true, added);
                    Assert.AreEqual(1, context.Tasks.Count());
                    Assert.AreEqual("task message", context.Tasks.Find(1).TaskMessage);
                }
            }
            finally
            {
                connection.Close();
            }
        }
예제 #15
0
        public bool Update(Stories inStories)
        {
            using (var context = new ScrumContext())
            {
                try
                {
                    context.Entry(inStories).State = EntityState.Modified;
                    if (context.SaveChanges() > 0)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                catch (Exception ex)
                {
                    //logFile.CatchError("asdf9o234nj92834n09234", ex);

                    return(false);
                }
            }
        }
예제 #16
0
        public bool Delete(Stories inStories)
        {
            using (var context = new ScrumContext())
            {
                try
                {
                    context.Entry(inStories).State = EntityState.Deleted;
                    if (context.SaveChanges() > 0)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                catch (Exception ex)
                {
                    //logFile.CatchError("adsfkjo2h394823n498273u4j", ex);

                    return(false);
                }
            }
        }
예제 #17
0
        public static void Main(string[] args)
        {
            using (var db = new ScrumContext())
            {
                db.Add(new Group {
                    GroupId = 9
                });
                Console.WriteLine("Creating group");

                try
                {
                    db.Add(new User
                    {
                        GroupId = 1, Password = "******", Username = "******", GroupRole = GroupRole.ScrumMaster
                    });
                    db.SaveChanges();
                    Console.Write("Creating user");
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }
        }
예제 #18
0
        public void CreateMinutesOfMeeting()
        {
            // In-memory database only exists while the connection is open
            var connection = new SqliteConnection("DataSource=:memory:");

            connection.Open();
            try
            {
                var options = new DbContextOptionsBuilder <ScrumContext>()
                              .UseSqlite(connection)
                              .Options;

                // Create the schema in the database
                using (var context = new ScrumContext(options))
                {
                    context.Database.EnsureCreated();
                }

                // Run the test against one instance of the context
                using (var context = new ScrumContext(options))
                {
                    var          service = new GroupRepository(context);
                    MeetingNotes notes   = new MeetingNotes();
                    notes.SprintId     = 1;
                    notes.dailyMeeting = "DAILY TEST";
                    bool created = service.CreateMinutesOfMeeting(notes);
                    Assert.AreEqual(true, created);
                    Assert.AreEqual(1, context.MeetingNoteses.Count());
                    Assert.AreEqual("DAILY TEST", context.MeetingNoteses.Find(1).DailyMeeting);
                }
            }
            finally
            {
                connection.Close();
            }
        }
 public BacklogTaskSchedulesController(ScrumContext context, IAuthorizationService authorizationService)
 {
     _context = context;
     _authorizationService = authorizationService;
 }
예제 #20
0
 public UserRepository(ScrumContext dbContext, UserManager <ScrumUser> userManager)
 {
     _dbContext   = dbContext;
     _userManager = userManager;
 }
예제 #21
0
 public ScrumTeamsController(ScrumContext context, IAuthorizationService authorizationService)
 {
     _context = context;
     _authorizationService = authorizationService;
 }
예제 #22
0
 public ProductBacklogController(ScrumContext context, IAuthorizationService authorizationService)
 {
     _context = context;
     _authorizationService = authorizationService;
 }
예제 #23
0
 public HomeController(IAuthorizationService authorizationService, ScrumContext dbContext)
 {
     _authorizationService = authorizationService;
     _dbContext            = dbContext;
 }
예제 #24
0
 public GroupRepository(ScrumContext context, IParticipantRepository participantRepository)
 {
     _context = context ?? throw new System.ArgumentNullException(nameof(context));
     _participantRepository = participantRepository ?? throw new System.ArgumentNullException(nameof(participantRepository));
 }
예제 #25
0
 public ParticipantRepository(ScrumContext context) => _context = context ?? throw new System.ArgumentNullException(nameof(context));
예제 #26
0
 public PersonnelController(ScrumContext context)
 {
     _context = context;
 }
예제 #27
0
 public GroupRepository(ScrumContext db)
 {
     this.db = db;
 }
예제 #28
0
 public SprintLogRepository(ScrumContext context) => _context = context ?? throw new System.ArgumentNullException(nameof(context));
예제 #29
0
 public TeamAuthorizationHandler(ScrumContext dbContext)
 {
     _dbContext = dbContext;
 }
예제 #30
0
 public ProductTeamsController(ScrumContext context)
 {
     _context = context;
 }