예제 #1
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);
        }
예제 #2
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);
        }
예제 #3
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());
        }