コード例 #1
0
        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)));
        }
コード例 #2
0
        public void CreateQuery_GetDataInsert_Test()
        {
            // arrange
            var component = new DatabaseQueryCreator();
            var testData  = new MyTestData {
                MyText = "Hello"
            };

            // act
            var query = component.GetDataInsert(testData, out _);

            // assert
            Assert.AreEqual("INSERT INTO MyTestData (MyText) VALUES ('Hello')", query);
        }
コード例 #3
0
        public void CreateQuery_GetDataDelete_ByData_Test()
        {
            // arrange
            var component = new DatabaseQueryCreator();
            var data      = new MyTestData {
                Id = 123L, MyText = "For delete"
            };

            // act
            var query = component.GetDataDelete(data);

            // assert
            Assert.AreEqual("DELETE FROM MyTestData WHERE Id='123'", query);
        }
コード例 #4
0
        public void CreateQuery_GetDataUpdate_Test()
        {
            // arrange
            var component = new DatabaseQueryCreator();
            var data      = new MyTestData {
                Id = 123, MyText = "Change text"
            };

            // act
            var query = component.CreateQueryUpdateData(data);

            // assert
            Assert.AreEqual("UPDATE MyTestData SET Id='123',MyText='Change text' WHERE Id='123';", query);
        }
コード例 #5
0
        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);
        }