public void GetAllTeamMembersShouldGetTeamMambersCorrectly() { var mockList = new List <TeamMemberViewModel> { new TeamMemberViewModel { About = "Anne Smith (born July 1, 1959) is an educational psychologist", Name = "Ann Smith", Facebook = "lkjkljklasdf", Image350X290 = "lkjfasd", Instagram = "fdaasdf", Position = "fdasadf", Skype = "fdaasdf", Twitter = "fdaasdf" }, new TeamMemberViewModel { About = "Anne Smith (born July 1, 1959) is an educational psychologist", Name = "Ann Smith", Facebook = "lkjkljklasdf", Image350X290 = "lkjfasd", Instagram = "fdaasdf", Position = "fdasadf", Skype = "fdaasdf", Twitter = "fdaasdf" } }; var options = new DbContextOptionsBuilder <IntillegioContext>() .UseInMemoryDatabase(databaseName: "Get_All_TeamMembers_Db") .Options; var dbContext = new IntillegioContext(options); var mapper = new Mock <IMapper>(); mapper.Setup(m => m.Map <IEnumerable <TeamMemberViewModel> >( dbContext.TeamMembers)) .Returns(mockList); var teamMembersCount = 5; for (int i = 0; i < teamMembersCount; i++) { dbContext.TeamMembers.Add(new TeamMember()); } dbContext.SaveChanges(); var service = new AboutService(dbContext, mapper.Object); var allTeamMembers = service.GetAllTeamMembers(); Assert.NotNull(allTeamMembers); }
public void GetTeamMembersForAdminShouldGetTeamMambersCorrectly() { var mockList = new List <AdminTeamMemberViewModel> { new AdminTeamMemberViewModel { Name = "Jack Semper ", Id = 1, PhoneNumber = "(+123) 123 456 789", Email = "*****@*****.**", Position = "Majority Owner", } }; var options = new DbContextOptionsBuilder <IntillegioContext>() .UseInMemoryDatabase(databaseName: "Get_All_TeamMembers_for_Admin_Db") .Options; var dbContext = new IntillegioContext(options); var mapper = new Mock <IMapper>(); mapper.Setup(m => m.Map <IEnumerable <AdminTeamMemberViewModel> >( dbContext.TeamMembers)) .Returns(mockList); var teamMembersCount = 5; for (int i = 0; i < teamMembersCount; i++) { dbContext.TeamMembers.Add(new TeamMember()); } dbContext.SaveChanges(); var service = new AboutService(dbContext, mapper.Object); var allTeamMembers = service.GetAllTeamMembers(); Assert.NotNull(allTeamMembers); }