public async Task SaveAsync_ShouldSaveDataTableSuccessfully_WhenTableHasNoForeignKey() { using var datatable = TestObjectFactory.NewTestDataTable() .WithRowData(1, "String Value 1", true, new System.DateTime(2020, 01, 26), null, null) .WithRowData(2, "String Value 2", false, new System.DateTime(2020, 01, 27), true, new System.DateTime(2020, 01, 19)) .Build(); var exptectedModel1 = TestObjectFactory.TestDbModelObject() .WithId(1) .WithStringColumnValue("String Value 1") .WithDateColumnValue(new System.DateTime(2020, 01, 26)) .WithBoolColumnValue(true) .WithNullableBoolColumnValue(null) .WithNullableDateColumnValue(null) .Build(); var expectedModel2 = TestObjectFactory.TestDbModelObject() .WithId(2) .WithStringColumnValue("String Value 2") .WithDateColumnValue(new System.DateTime(2020, 01, 27)) .WithBoolColumnValue(false) .WithNullableBoolColumnValue(true) .WithNullableDateColumnValue(new System.DateTime(2020, 01, 19)) .Build(); var expctedResults = new List <TestDbModel> { exptectedModel1, expectedModel2 }; await BulkProcessor.SaveAsync(datatable, nameof(TestDbContext.TestDbModels)); var results = TestDbContext.TestDbModels.OrderBy(x => x.Id).ToList(); results.Should().BeEquivalentTo(expctedResults); }
public async Task SaveAsync_ShouldSaveModelsSuccessfully_WhenTableHasNoForeignKey() { var model1 = TestObjectFactory.TestDbModelObject() .WithId(1) .WithStringColumnValue("String Value 1") .WithDateColumnValue(new System.DateTime(2020, 01, 26)) .WithBoolColumnValue(true) .WithNullableBoolColumnValue(null) .WithNullableDateColumnValue(null) .Build(); var model2 = TestObjectFactory.TestDbModelObject() .WithId(2) .WithStringColumnValue("String Value 2") .WithDateColumnValue(new System.DateTime(2020, 01, 27)) .WithBoolColumnValue(false) .WithNullableBoolColumnValue(true) .WithNullableDateColumnValue(new System.DateTime(2020, 01, 19)) .Build(); var model3 = TestObjectFactory.TestDbModelObject() .WithId(3) .WithStringColumnValue("String Value 3") .WithDateColumnValue(new System.DateTime(2020, 01, 28)) .WithBoolColumnValue(true) .WithNullableBoolColumnValue(false) .WithNullableDateColumnValue(new System.DateTime(2020, 1, 10)) .Build(); var models = new List <TestDbModel> { model1, model2, model3 }; await BulkProcessor.SaveAsync(models, nameof(TestDbContext.TestDbModels)); var results = TestDbContext.TestDbModels.OrderBy(x => x.Id).ToList(); results.Should().BeEquivalentTo(models); }
private async Task WhenSaveAsyncIsCalled(DataTable dataToCopy, string tableName) { await BulkProcessor.SaveAsync(dataToCopy, tableName); }
private async Task WhenSaveAsyncIsCalled <T>(IEnumerable <T> dataToCopy, string tableName) where T : class { await BulkProcessor.SaveAsync(dataToCopy, tableName); }