Beispiel #1
0
        public async Task AuthenticateBasicAsync_WithValidCredentials_ShouldReturnStudent()
        {
            var header          = "Basic dGVzdEB5cy5jb206dGVzdDEyMw==";
            var expectedStudent = new Student {
                StudentId = 1
            };
            var mockLogger     = new Mock <IBaseLogger <StudentService> >();
            var mockRepository = new Mock <IStudentRepository>();

            mockRepository.Setup(repo => repo.GetStudentsAsync(It.IsAny <ISpecification <Student> >()))
            .ReturnsAsync(new Student[] { expectedStudent })
            .Verifiable();
            var service = new StudentService(mockRepository.Object, mockLogger.Object);

            var result = await service.AuthenticateBasicAsync(header);

            Assert.Equal(expectedStudent.StudentId, result.StudentId);
            mockRepository.Verify();
        }