Ejemplo n.º 1
0
        public async Task FindAsync_WithOneCourse_ShouldReturnCorrectCourse()
        {
            //Arrange
            const int    expectedId   = 1;
            const string expectedName = "AAA";

            var course = new Course
            {
                Id   = expectedId,
                Name = expectedName
            };

            this.courseRepositoryMock
            .Setup(m => m.FindByIdAsync(expectedId))
            .ReturnsAsync(course)
            .Verifiable();

            var sut = new AdminCoursesService(null, this.courseRepositoryMock.Object);

            //Act
            var courseResult = await sut.FindCourseAsync(expectedId);

            //Assert
            this.courseRepositoryMock.Verify();

            Assert.IsNotNull(courseResult);
            Assert.AreEqual(expectedId, courseResult.Id);
            Assert.AreEqual(expectedName, courseResult.Name);
        }
Ejemplo n.º 2
0
        public async Task FindAsync_WithoutCourse_ShouldReturnNull()
        {
            const int expectedId = 1;
            Course    course     = null;

            this.courseRepositoryMock
            .Setup(m => m.FindByIdAsync(expectedId))
            .ReturnsAsync(course)
            .Verifiable();

            var service = new AdminCoursesService(null, this.courseRepositoryMock.Object);

            //Act
            var courseResult = await service.FindCourseAsync(expectedId);

            // Assert
            Assert.IsNull(courseResult);
        }