예제 #1
0
        public void FamilyEnsureTheFamilyHasAllTheThings()
        {
            Family a_family = new Family();
            DateTime expected_time = DateTime.Now;
            a_family.FamilyId = 1;
            a_family.FamilyName = "Jones";
            a_family.Updated = expected_time;


            Assert.AreEqual(1, a_family.FamilyId);
            Assert.AreEqual("Jones", a_family.FamilyName);
            Assert.AreEqual(expected_time, a_family.Updated);

        }
예제 #2
0
        public void FamilyEnsureICanUseObjectInitializerSyntax()
        {

            DateTime expected_time = DateTime.Now;
            Family a_family = new Family
            {
                FamilyId = 1,
                FamilyName = "Jones",
                Updated = expected_time
        };

            Assert.AreEqual(1, a_family.FamilyId);
            Assert.AreEqual("Jones", a_family.FamilyName);
            Assert.AreEqual(expected_time, a_family.Updated);

        }
예제 #3
0
        public bool CreateFamily(string familyName)
        {
            Family a_family = new Family { FamilyName = familyName, Updated = DateTime.Now };
            bool is_added = true;
            try
            {
                Family added_famiily = _context.Families.Add(a_family);
                _context.SaveChanges();

            }
            catch (Exception)
            {
                is_added = false;
            }
            return is_added;
        }
예제 #4
0
        public bool CreateMember(string firstName, string lastName, Family family1, Group group1)
        {
            Member a_member = new Member { FirstName = firstName, LastName = lastName, Family = family1, Group = group1, Updated = DateTime.Now };
            bool is_added = true;
            try
            {
                Member added_member = _context.Members.Add(a_member);
                _context.SaveChanges();

            }
            catch (Exception)
            {
                is_added = false;
            }
            return is_added;
        }
예제 #5
0
        public void WalkEnsureICanCreateAMember()
        {
            // Arrange
            DateTime base_time = DateTime.Now;
            List<Member> expected_members = new List<Member>();
            ConnectMocksToDataStore(expected_members);
            Family family1 = new Family { FamilyName = "Rice", Updated = base_time };
            Group group1 = new Group { GroupName = "St. Andrew" };
            string firstName = "Laura";
            string lastName = "Rice";
            
            mock_member_set.Setup(j => j.Add(It.IsAny<Member>())).Callback((Member s) => expected_members.Add(s));
            // Act
            bool successful = repository.CreateMember(firstName, lastName, family1, group1);

            // Assert
            Assert.AreEqual(1, repository.GetAllMembers().Count);

        }
예제 #6
0
        public void WalkRepositoryGetGroupsActivities()
        {
            var time = DateTime.Now;
            var family = new Family { FamilyName = "Anderson", FamilyId = 1, Updated = time };
            var family2 = new Family { FamilyName = "Anderson", FamilyId = 2, Updated = time };

            var groups = new List<Group>
            {
                new Group { GroupId = 1, GroupName = "St. Andrew" },
                new Group { GroupId = 2, GroupName = "Fron" }
            };
            mock_group_set.Object.AddRange(groups);
            ConnectMocksToDataStore(groups);

            var members = new List<Member> {
                new Member { MemberId = 1, LastName = "Anderson", FirstName = "Bernie", Family = family, Updated = time, Group
                 = groups[0] },
                new Member { MemberId = 2, LastName = "Rice", FirstName = "Laura", Family = family2, Updated = time, Group = groups[0] },
                new Member { MemberId = 3, LastName = "Anderson", FirstName = "Ruby", Family = family, Updated = time, Group = groups[0] },
                new Member { MemberId = 4, LastName = "Rice", FirstName = "Adam", Family = family2, Updated = time, Group = groups[1] },
                new Member { MemberId = 5, LastName = "Anderson", FirstName = "Samuel", Family = family, Updated = time, Group = groups[1] },
                new Member { MemberId = 6, LastName = "Rice", FirstName = "Noah", Family = family2, Updated = time, Group = groups[1] }
            };

            mock_member_set.Object.AddRange(members);
            ConnectMocksToDataStore(members);

            var activities = new List<Activities>
            {
                new Activities {ActivityId = 1, ActivityName = "walking", Distance = 1.1d, Date = time, Participant =  members[0]},
                new Activities {ActivityId = 2, ActivityName = "run", Distance = 3.5d, Date = time, Participant =  members[3]},
                new Activities {ActivityId = 3, ActivityName = "swim", Distance = 8d, Date = time, Participant =  members[0] },
                new Activities {ActivityId = 4, ActivityName = "eliptical", Distance = 5d, Date = time, Participant =  members[1] },
                new Activities {ActivityId = 5, ActivityName = "swim", Distance = 6.3d, Date = time, Participant =  members[5]},
                new Activities {ActivityId = 6, ActivityName = "walking", Distance = 7.8d, Date = time, Participant =  members[2]  },
                new Activities {ActivityId = 7, ActivityName = "run", Distance = 12.4d, Date = time, Participant =  members[4] }
            };
            mock_activity_set.Object.AddRange(activities);
            ConnectMocksToDataStore(activities);


            List<Activities> actualGroupActivities = repository.GetGroupActivities(groups[0]);
            var group1 = new Group { GroupId = 1, GroupName = "St. Andrew" };
            var group2 = new Group { GroupId = 2, GroupName = "Fron" };
            var group1Activities = new List<Activities>
            {
                new Activities {ActivityId = 1, ActivityName = "walking", Distance = 1.1d, Date = time, Participant =  members[0]},
                new Activities {ActivityId = 3, ActivityName = "swim", Distance = 8d, Date = time, Participant =  members[0] },
                new Activities {ActivityId = 4, ActivityName = "eliptical", Distance = 5d, Date = time, Participant =  members[1] },
                new Activities {ActivityId = 6, ActivityName = "walking", Distance = 7.8d, Date = time, Participant =  members[2]  }
            };

            Assert.AreEqual(1.1d, actualGroupActivities[0].Distance);

        }
예제 #7
0
        public void WalkRepositoryEnsureCanGetMembersForAGroup()
        {
            var time = DateTime.Now;
            var family = new Family { FamilyName = "Anderson", FamilyId = 1, Updated = time };
            var family2 = new Family { FamilyName = "Anderson", FamilyId = 2, Updated = time };
            var group1 = new Group { GroupId = 1, GroupName = "St. Andrew" };
            var group2 = new Group { GroupId = 2, GroupName = "Fron" };
            

            var member = new List<Member> {
                new Member { MemberId = 1, LastName = "Anderson", FirstName = "Bernie", Family = family, Updated = time, Group
                 = group1},
                new Member {MemberId = 2, LastName = "Rice", FirstName = "Laura", Family = family2, Updated = time, Group = group2},
                new Member {MemberId = 3, LastName = "Anderson", FirstName = "Ruby", Family = family, Updated = time, Group = group1},
                new Member {MemberId = 4, LastName = "Rice", FirstName = "Adam", Family = family2, Updated = time, Group = group2},
                new Member {MemberId = 5, LastName = "Anderson", FirstName = "Samuel", Family = family, Updated = time, Group = group1},
                new Member {MemberId = 6, LastName = "Rice", FirstName = "Noah", Family = family2, Updated = time, Group = group2}
            };
            mock_member_set.Object.AddRange(member);
            ConnectMocksToDataStore(member);


            var testGroup = new Group { GroupId = 1, GroupName = "St. Andrew" };
            var expectedMembers = new List<Member>
            {
                 new Member { MemberId = 1, LastName = "Anderson", FirstName = "Bernie", Family = family, Updated = time, Group
                 = group1},
                new Member {MemberId = 3, LastName = "Anderson", FirstName = "Ruby", Family = family, Updated = time, Group = group1},
                new Member {MemberId = 5, LastName = "Anderson", FirstName = "Samuel", Family = family, Updated = time, Group = group1},
            };
            var actual = repository.GetAllGroupMembers(testGroup);

            Assert.AreEqual("Bernie", actual.First().FirstName);
            Assert.AreEqual(expectedMembers[0].Family, actual[0].Family);
            Assert.AreEqual(expectedMembers[0].MemberId, actual[0].MemberId);
            Assert.AreEqual(expectedMembers[1].LastName, actual[1].LastName);
            Assert.AreEqual(expectedMembers[0].Group, actual[0].Group);
            Assert.AreEqual(expectedMembers[0].Updated, actual[0].Updated);
            //Assert.AreEqual(expectedMembers[0], actual[0]);

        }
예제 #8
0
 public void FamilyEnsureICanCreateInstance()
 {
     Family a_family = new Family();
     Assert.IsNotNull(a_family);
 }