public void Add_ShouldAddMarkGeneralDataPoint() { // Arrange var context = GetContext(TestData.markGeneralDataPoints); var repo = new SqlMarkGeneralDataPointRepo(context); int markId = _rnd.Next(1, TestData.marks.Count()); int sectionId = _rnd.Next(1, TestData.generalDataSections.Count()); var markGeneralDataPoint = new MarkGeneralDataPoint { Mark = TestData.marks.SingleOrDefault(v => v.Id == markId), Section = TestData.generalDataSections.SingleOrDefault( v => v.Id == sectionId), Text = "NewCreate", OrderNum = 3, }; // Act repo.Add(markGeneralDataPoint); // Assert Assert.NotNull(repo.GetById(markGeneralDataPoint.Id)); context.Database.EnsureDeleted(); context.Dispose(); }
public void Update_ShouldUpdateMarkGeneralDataPoint() { // Arrange var markGeneralDataPoints = new List <MarkGeneralDataPoint> { }; foreach (var gdp in TestData.markGeneralDataPoints) { markGeneralDataPoints.Add(new MarkGeneralDataPoint { Id = gdp.Id, Mark = gdp.Mark, Section = gdp.Section, Text = gdp.Text, OrderNum = gdp.OrderNum, }); } var context = GetContext(markGeneralDataPoints); var repo = new SqlMarkGeneralDataPointRepo(context); int id = _rnd.Next(1, markGeneralDataPoints.Count()); var markGeneralDataPoint = markGeneralDataPoints.FirstOrDefault( v => v.Id == id); markGeneralDataPoint.Text = "NewUpdate"; // Act repo.Update(markGeneralDataPoint); // Assert Assert.Equal(markGeneralDataPoint.Text, repo.GetById(id).Text); context.Database.EnsureDeleted(); context.Dispose(); }
public void GetById_ShouldReturnNull_WhenWrongId() { // Arrange var context = GetContext(TestData.markGeneralDataPoints); var repo = new SqlMarkGeneralDataPointRepo(context); // Act var markGeneralDataPoint = repo.GetById(999); // Assert Assert.Null(markGeneralDataPoint); context.Database.EnsureDeleted(); context.Dispose(); }
public void GetById_ShouldReturnMarkGeneralDataPoint() { // Arrange var context = GetContext(TestData.markGeneralDataPoints); var repo = new SqlMarkGeneralDataPointRepo(context); int id = _rnd.Next(1, TestData.markGeneralDataPoints.Count()); // Act var markGeneralDataPoint = repo.GetById(id); // Assert Assert.Equal(TestData.markGeneralDataPoints.SingleOrDefault(v => v.Id == id), markGeneralDataPoint); context.Database.EnsureDeleted(); context.Dispose(); }
public void Delete_ShouldDeleteMarkGeneralDataPoint() { // Arrange var context = GetContext(TestData.markGeneralDataPoints); var repo = new SqlMarkGeneralDataPointRepo(context); int id = _rnd.Next(1, TestData.markGeneralDataPoints.Count()); var markGeneralDataPoint = TestData.markGeneralDataPoints.FirstOrDefault( v => v.Id == id); // Act repo.Delete(markGeneralDataPoint); // Assert Assert.Null(repo.GetById(id)); context.Database.EnsureDeleted(); context.Dispose(); }