public void DeleteData() { // arrange this.Init(9); var connector = new RkiDatabaseConnector(string.Format(this._connectionString, 9)); connector.Create <MyTestData>(); connector.Insert(new MyTestData { MyText = "Test data 1" }); var deleteData = new MyTestData { MyText = "Test data 2" }; connector.Insert(deleteData); var updateData = connector.Select <MyTestData>(2L); // act var resultDelete = connector.Delete(updateData); var result = connector.Select <MyTestData>(); // assert Assert.IsTrue(resultDelete); Assert.IsNotNull(result); Assert.IsFalse(result.Any(a => a.MyText.Equals(deleteData.MyText))); }
public void UpdateData() { // arrange this.Init(8); var connector = new RkiDatabaseConnector(string.Format(this._connectionString, 8)); connector.Create <MyTestData>(); connector.Insert(new MyTestData { MyText = "Test data 1" }); connector.Insert(new MyTestData { MyText = "Test data 2" }); var updateData = connector.Select <MyTestData>(2L); // act updateData.MyText = "new text"; var resultUpdate = connector.Update(updateData); var result = connector.Select <MyTestData>(2L); // assert Assert.IsTrue(resultUpdate); Assert.IsNotNull(result); Assert.AreEqual(typeof(MyTestData), result.GetType()); Assert.AreEqual(updateData.MyText, result.MyText); }
public void CreateNewTable() { // arrange this.Init(1); var connector = new RkiDatabaseConnector(string.Format(this._connectionString, 1)); // act var result = connector.Create <MyTestDataSubData>(); // assert Assert.IsTrue(result); }
public void SelectEmptyData() { // arrange this.Init(5); var connector = new RkiDatabaseConnector(string.Format(this._connectionString, 5)); connector.Create <MyTestData>(); // act var result = connector.Select <MyTestData>(); // assert Assert.IsTrue(!result.Any()); }
public void TableExist() { // arrange this.Init(3); var connector = new RkiDatabaseConnector(string.Format(this._connectionString, 3)); connector.Create <MyTestData>(); // act var result = connector.Exist <MyTestData>(); // assert Assert.IsTrue(result); }
public void InsertData() { // arrange this.Init(4); var connector = new RkiDatabaseConnector(string.Format(this._connectionString, 4)); connector.Create <MyTestData>(); // act var result = connector.Insert(new MyTestData { MyText = "Hallo" }); // assert Assert.IsTrue(result); }
public void SelectOneData() { // arrange this.Init(6); var connector = new RkiDatabaseConnector(string.Format(this._connectionString, 6)); connector.Create <MyTestData>(); connector.Insert(new MyTestData { MyText = "Test data" }); // act var result = connector.Select <MyTestData>(); // assert Assert.IsTrue(result.Any()); }
public void InsertDataWithCollection() { // arrange this.Init(4); var connector = new RkiDatabaseConnector(string.Format(this._connectionString, 4)); connector.Create <MyTestDataSubData>(); // act connector.Insert(new MyTestDataSubData { CollectionOfInteger = new [] { 12, 34, 56 } }); var result = connector.Select <MyTestDataSubData>(); // assert Assert.IsNotNull(result); var data = result.First(); Assert.IsNotNull(data.CollectionOfInteger); Assert.IsInstanceOfType(data.CollectionOfInteger, typeof(int[])); Assert.AreEqual(3, data.CollectionOfInteger.Length); }
public void SelectDataById() { // arrange this.Init(7); var connector = new RkiDatabaseConnector(string.Format(this._connectionString, 7)); connector.Create <MyTestData>(); connector.Insert(new MyTestData { MyText = "Test data 1" }); var insertData = new MyTestData { MyText = "Test data 2" }; connector.Insert(insertData); // act var result = connector.Select <MyTestData>(2L); // assert Assert.IsNotNull(result); Assert.AreEqual(typeof(MyTestData), result.GetType()); Assert.AreEqual(insertData.MyText, result.MyText); }
static bool CreateTables(RkiDatabaseConnector dbConnector) => _tables.All(a => dbConnector.Create(a));