public async Task GetExistingCourseInstanceShouldReturnCourseInstance() { //Arrange var fixture = new CourseInstanceRepositoryFixture() .WithXCourseInstances(1); CourseInstance expected = new CourseInstance() { Course = new Course() { CourseId = 1, Code = "C1", LengthInDays = 5, Title = "Course1" }, StartDate = DateTime.Now.Date, CourseInstanceId = 1 }; //Act var result = await fixture.ExecuteGet(new CourseInstance() { Course = new Course() { Code = "C1" }, StartDate = DateTime.Now.Date }); //Assert expected.Should().BeEquivalentTo(result); }
public async Task EmptyDatabaseGetAllShouldReturnEmptyList() { //Arrange var fixture = new CourseInstanceRepositoryFixture() .WithXCourseInstances(0); int expected = 0; //Act var result = await fixture.ExecuteGetAll(); //Assert Assert.Equal(expected, result.Count()); }
public async Task ThreeRecordsDatabaseGetAllShouldReturnListWithThreeCourseInstances() { //Arrange var fixture = new CourseInstanceRepositoryFixture() .WithXCourseInstances(3); int expected = 3; //Act var result = await fixture.ExecuteGetAll(); //Assert Assert.Equal(expected, result.Count()); }
public async Task AddOneRecordToEmptyDatabaseGetAllShouldReturnListWithOneCourseInstance() { //Arrange var fixture = new CourseInstanceRepositoryFixture(); int expected = 1; //Act await fixture.ExecuteAdd(new CourseInstance()); var result = await fixture.ExecuteGetAll(); //Assert Assert.Equal(expected, result.Count()); }
public async Task AddIfNotExistsShouldReturnCourseInstanceAndFalseIfNotExists() { //Arrange var fixture = new CourseInstanceRepositoryFixture(); //Act var result = await fixture.ExecuteAddIfNotExists(new CourseInstance() { Course = new Course(), StartDate = DateTime.Now.Date }); //Assert Assert.IsType <CourseInstance>(result.courseInstance); Assert.False(result.exists); }
public async Task GetCourseInstanceWithWrongCodeShouldReturnNull() { //Arrange var fixture = new CourseInstanceRepositoryFixture() .WithXCourseInstances(1); //Act var result = await fixture.ExecuteGet(new CourseInstance() { Course = new Course() { Code = "C2" }, StartDate = DateTime.Now.Date }); //Assert Assert.Null(result); }
public async Task AddIfNotExistsShouldReturnNewCourseInstanceWithIdIfExists() { //Arrange var fixture = new CourseInstanceRepositoryFixture() .WithXCourseInstances(3); int expected = 4; //Act var result = await fixture.ExecuteAddIfNotExists(new CourseInstance() { Course = new Course() { Code = "C4", LengthInDays = 5, Title = "Course4" }, StartDate = DateTime.Now.Date.AddDays(3) }); //Assert Assert.Equal(expected, result.courseInstance.CourseInstanceId); }
public async Task AddIfNotExistsShouldReturnCourseInstanceAndTrueIfExists() { //Arrange var fixture = new CourseInstanceRepositoryFixture() .WithXCourseInstances(3); //Act var result = await fixture.ExecuteAddIfNotExists(new CourseInstance() { Course = new Course() { Code = "C1", LengthInDays = 5, Title = "Course1" }, StartDate = DateTime.Now.Date }); //Assert Assert.IsType <CourseInstance>(result.courseInstance); Assert.True(result.exists); }
public async Task AddIfNotExistsShouldNotAddIfCourseInstanceExists() { //Arrange var fixture = new CourseInstanceRepositoryFixture() .WithXCourseInstances(3); int expected = 3; //Act await fixture.ExecuteAddIfNotExists(new CourseInstance() { Course = new Course() { Code = "C3", LengthInDays = 5, Title = "Course3" }, StartDate = DateTime.Now.Date.AddDays(2) }); var result = await fixture.ExecuteGetAll(); //Assert Assert.Equal(expected, result.Count()); }