Exemplo n.º 1
0
        public async Task FindByCodeShouldReturnNullIfCodeNotExists()
        {
            //Arrange
            var fixture = new CourseRepositoryFixture()
                          .WithXCourses(5);

            //Act
            var result = await fixture.ExecuteFindByCode("C6");

            //Assert
            Assert.Null(result);
        }
Exemplo n.º 2
0
        public async Task ThreeRecordDatabaseGetAllShouldReturnListWithThreeCourses()
        {
            //Arrange
            var fixture = new CourseRepositoryFixture()
                          .WithXCourses(3);
            int expected = 3;

            //Act
            var result = await fixture.ExecuteGetAll();

            //Assert
            Assert.Equal(expected, result.Count());
        }
Exemplo n.º 3
0
        public async Task FindByCodeShouldReturnIfCodeExists()
        {
            //Arrange
            var fixture = new CourseRepositoryFixture()
                          .WithSpecificCourse(code: "C1");
            string expected = "C1";

            //Act
            var result = await fixture.ExecuteFindByCode("C1");

            //Assert
            Assert.Equal(expected, result.Code);
        }
Exemplo n.º 4
0
        public async Task EmptyDatabaseGetAllShouldReturnEmptyList()
        {
            //Arrange
            var fixture = new CourseRepositoryFixture()
                          .WithXCourses(0);
            int expected = 0;

            //Act
            var result = await fixture.ExecuteGetAll();

            //Assert
            Assert.Equal(expected, result.Count());
        }
Exemplo n.º 5
0
        public async Task AddOneRecordToEmptyDatabaseGetAllShouldReturnListWithOneCourse()
        {
            //Arrange
            var fixture  = new CourseRepositoryFixture();
            int expected = 1;

            //Act
            await fixture.ExecuteAdd(new Course());

            var result = await fixture.ExecuteGetAll();

            //Assert
            Assert.Equal(expected, result.Count());
        }
Exemplo n.º 6
0
        public async Task GetNonExistentCourseShouldReturnNull()
        {
            //Arrange
            var fixture = new CourseRepositoryFixture()
                          .WithXCourses(1);

            //Act
            var result = await fixture.ExecuteGet(new Course()
            {
                Code = "C2"
            });

            //Assert
            Assert.Null(result);
        }
Exemplo n.º 7
0
        public async Task AddIfNotExistsShouldReturnNewCourseWithIdIfExists()
        {
            //Arrange
            var fixture = new CourseRepositoryFixture()
                          .WithXCourses(3);
            int expected = 4;

            //Act
            var result = await fixture.ExecuteAddIfNotExists(new Course()
            {
                Code = "C4", LengthInDays = 5, Title = "Course4"
            });

            //Assert
            Assert.Equal(expected, result.course.CourseId);
        }
Exemplo n.º 8
0
        public async Task AddIfNotExistsShouldReturnCourseAndFalseIfNotExists()
        {
            //Arrange
            var fixture = new CourseRepositoryFixture()
                          .WithXCourses(0);

            //Act
            var result = await fixture.ExecuteAddIfNotExists(new Course()
            {
                Code = "C1", LengthInDays = 5, Title = "Course1"
            });

            //Assert
            Assert.IsType <Course>(result.course);
            Assert.False(result.exists);
        }
Exemplo n.º 9
0
        public async Task AddIfNotExistsShouldNotAddIfCodeExists()
        {
            //Arrange
            var fixture = new CourseRepositoryFixture()
                          .WithXCourses(3);
            int expected = 3;

            //Act
            await fixture.ExecuteAddIfNotExists(new Course()
            {
                Code = "C3", LengthInDays = 3, Title = "Course5"
            });

            var result = await fixture.ExecuteGetAll();

            //Assert
            Assert.Equal(expected, result.Count());
        }
Exemplo n.º 10
0
        public async Task GetExistingCourseShouldReturnCourse()
        {
            //Arrange
            var fixture = new CourseRepositoryFixture()
                          .WithXCourses(1);
            Course expected = new Course()
            {
                CourseId = 1, Code = "C1", LengthInDays = 5, Title = "Course1"
            };

            //Act
            var result = await fixture.ExecuteGet(new Course()
            {
                Code = "C1"
            });

            //Assert
            expected.Should().BeEquivalentTo(result);
        }