Ejemplo n.º 1
0
        public async Task When_getting_an_admin_identity_with_a_INVALID_email_should_return_an_empty_list()
        {
            // Arrange
            // Supplied Data: Setting up our baseline of supplied data.
            string suppliedEmail = "*****@*****.**";

            var suppliedStaff = new List <Staff>();
            var suppliedStaffElectronicEmail = new List <StaffElectronicMail>();

            var suppliedParents = new List <Parent>();
            var suppliedParentElectronicEmail = new List <ParentElectronicMail>();

            var suppliedAdmins = new List <Admin>();

            var dbContextMock = new Mock <IEdFi31Context>();

            dbContextMock.Setup(p => p.Staffs).Returns(DbContextMockingHelper.GetAsyncQueryableDbSetMock(suppliedStaff));
            dbContextMock.Setup(p => p.StaffElectronicMails).Returns(DbContextMockingHelper.GetAsyncQueryableDbSetMock(suppliedStaffElectronicEmail));
            dbContextMock.Setup(p => p.Parents).Returns(DbContextMockingHelper.GetAsyncQueryableDbSetMock(suppliedParents));
            dbContextMock.Setup(p => p.ParentElectronicMails).Returns(DbContextMockingHelper.GetAsyncQueryableDbSetMock(suppliedParentElectronicEmail));
            dbContextMock.Setup(p => p.Admins).Returns(DbContextMockingHelper.GetAsyncQueryableDbSetMock(suppliedAdmins));

            var edFiContextMock = dbContextMock.Object;

            // Act
            var repoUnderTest = new AdminRepository(edFiContextMock);
            var actualResult  = await repoUnderTest.GetAdminIdentityByEmailAsync(suppliedEmail);

            // Assert
            Assert.IsNotNull(actualResult);
            Assert.AreEqual(0, actualResult.Count);
        }
        public async Task When_getting_an_admin_identity_with_a_valid_staff_email_should_return_an_admin_identity()
        {
            // Arrange
            // Supplied Data: Setting up our baseline of supplied data.
            var suppliedSchoolId = 1;
            var suppliedSchools = new List<School>
            {
                new School{ SchoolId = suppliedSchoolId, LocalEducationAgencyId = 10},
                new School{ SchoolId = 99, LocalEducationAgencyId = 99} // Should be filtered out.
            };

            var dbContextMock = new Mock<IEdFi31Context>();

            dbContextMock.Setup(p => p.Schools).Returns(DbContextMockingHelper.GetAsyncQueryableDbSetMock(suppliedSchools));

            var edFiContextMock = dbContextMock.Object;

            var suppliedGradesLevelModel = new GradesLevelModel{PageSize = 1, SkipRows = 0};

            // Act
            var repoUnderTest = new CommunicationsRepository(edFiContextMock);
           // var actualResult = await repoUnderTest.GetStudentListByGradeLevelsProgramsAndSearchTerm("notUsed", "term", suppliedGradesLevelModel,);

            // Assert
            //Assert.IsNotNull(actualResult);
           // Assert.AreEqual(1,actualResult.Count);

        }
Ejemplo n.º 3
0
        public async Task When_getting_an_admin_identity_with_a_valid_parent_email_should_return_an_admin_identity()
        {
            // Arrange
            // Supplied Data: Setting up our baseline of supplied data.

            var suppliedStaff = new List <Staff>();
            var suppliedStaffElectronicEmail = new List <StaffElectronicMail>();

            string suppliedEmail   = "*****@*****.**";
            var    suppliedParents = new List <Parent>
            {
                new Parent {
                    ParentUsi = 1, ParentUniqueId = "S1", FirstName = "Parent", LastSurname = "Perez"
                },
                new Parent {
                    ParentUsi = 99, ParentUniqueId = "S99", FirstName = "Should be filtered out", LastSurname = "X"
                },
            };

            var suppliedParentElectronicEmail = new List <ParentElectronicMail>
            {
                new ParentElectronicMail {
                    ParentUsi = 1, ElectronicMailAddress = suppliedEmail
                },
                new ParentElectronicMail {
                    ParentUsi = 99, ElectronicMailAddress = "*****@*****.**"
                }
            };

            var suppliedAdmins = new List <Admin>
            {
                new Admin {
                    ElectronicMailAddress = suppliedEmail
                },
                new Admin {
                    ElectronicMailAddress = "*****@*****.**"
                }
            };

            var dbContextMock = new Mock <IEdFi31Context>();

            dbContextMock.Setup(p => p.Staffs).Returns(DbContextMockingHelper.GetAsyncQueryableDbSetMock(suppliedStaff));
            dbContextMock.Setup(p => p.StaffElectronicMails).Returns(DbContextMockingHelper.GetAsyncQueryableDbSetMock(suppliedStaffElectronicEmail));

            dbContextMock.Setup(p => p.Parents).Returns(DbContextMockingHelper.GetAsyncQueryableDbSetMock(suppliedParents));
            dbContextMock.Setup(p => p.ParentElectronicMails).Returns(DbContextMockingHelper.GetAsyncQueryableDbSetMock(suppliedParentElectronicEmail));

            dbContextMock.Setup(p => p.Admins).Returns(DbContextMockingHelper.GetAsyncQueryableDbSetMock(suppliedAdmins));

            var edFiContextMock = dbContextMock.Object;

            // Act
            var repoUnderTest = new AdminRepository(edFiContextMock);
            var actualResult  = await repoUnderTest.GetAdminIdentityByEmailAsync(suppliedEmail);

            // Assert
            Assert.IsNotNull(actualResult);
            Assert.AreEqual(1, actualResult.Count);

            var expectedParent = suppliedParents.Single(x => x.ParentUsi == 1);
            var actualParent   = actualResult.Single();

            Assert.AreEqual(expectedParent.ParentUsi, actualParent.Usi);
            Assert.AreEqual(expectedParent.ParentUniqueId, actualParent.UniqueId);
            Assert.AreEqual(expectedParent.FirstName, actualParent.FirstName);
            Assert.AreEqual(expectedParent.LastSurname, actualParent.LastSurname);
            Assert.AreEqual(ChatLogPersonTypeEnum.Parent.Value, actualParent.PersonTypeId);
            Assert.AreEqual(suppliedEmail, actualParent.Email);
        }