コード例 #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 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);
        }
コード例 #3
0
        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());
        }
コード例 #4
0
        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());
        }
コード例 #5
0
        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);
        }
コード例 #6
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);
        }