public async Task FindByCodeShouldReturnNullIfCodeNotExists() { //Arrange var fixture = new CourseRepositoryFixture() .WithXCourses(5); //Act var result = await fixture.ExecuteFindByCode("C6"); //Assert Assert.Null(result); }
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()); }
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); }
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()); }
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()); }
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); }
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); }
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); }
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()); }
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); }