public void InsertThenUpdate_ShouldReflectChanges() { // Arrange var dummyId = 7; var dbModel = new ReportLinesModel() { ReportId = dummyId, OssIndexId = _OssIndexId, }; // Act var newId = new ReportLinesRepository(AppState.ConnectionString) .Insert(dbModel); dummyId = 8; var dbModel2 = new ReportLinesRepository(AppState.ConnectionString) .Select(newId); dbModel2.ReportId = dummyId; new ReportLinesRepository(AppState.ConnectionString) .Update(dbModel2); var actualValue = new ReportLinesRepository(AppState.ConnectionString) .Select(newId) .ReportId; // Assert Assert.AreEqual(dummyId, actualValue); }
public int Insert(ReportLinesModel obj) { var storedProc = "sp_insert_report_lines"; var insertObj = new { report_id = obj.ReportId, oss_index_id = obj.OssIndexId }; return(Insert(storedProc, insertObj)); }
public void Update(ReportLinesModel obj) { var storedProc = "sp_update_report_lines"; var updateObj = new { id = obj.Id, report_id = obj.ReportId, oss_index_id = obj.OssIndexId }; Update(storedProc, updateObj); }
public void InsertAndSelect_ShouldEqualInserted() { // Arrange var dbModel = new ReportLinesModel() { ReportId = 7, OssIndexId = _OssIndexId, }; var expectedValue = new ReportLinesRepository(AppState.ConnectionString) .Insert(dbModel); // Act var actualValue = new ReportLinesRepository(AppState.ConnectionString) .Select(expectedValue) .Id; // Assert Assert.AreEqual(expectedValue, actualValue); }
public void InsertAndDelete_ShouldNoLongerExistAfterDelete() { // Arrange var expectedValue = 0; var dbModel = new ReportLinesModel() { ReportId = 7, OssIndexId = _OssIndexId, }; // Act var newId = new ReportLinesRepository(AppState.ConnectionString).Insert(dbModel); new ReportLinesRepository(AppState.ConnectionString).Delete(newId); var actualValue = new ReportLinesRepository(AppState.ConnectionString) .Select(newId) .Id; // Assert Assert.AreEqual(expectedValue, actualValue); }