예제 #1
0
        public void ValidSelect()
        {
            using var db = new SampleDb();
            var data = db.Employees.SelectAll();

            Assert.NotEmpty(data);
        }
예제 #2
0
        public async void SelectAllAsync()
        {
            using var db = new SampleDb();
            var employee = await db.Employees.SelectAllAsync();

            Assert.Equal(5, employee.Count());
        }
예제 #3
0
        public async void ExistInvalid()
        {
            using var db = new SampleDb();
            var result = await db.Definition.TableExistsAsync <Thing>();

            result.Should <bool>().Be(false);
        }
예제 #4
0
        public async void ExistValid()
        {
            using var db = new SampleDb();
            var result = await db.Definition.TableExistsAsync <Employee>();

            result.Should <bool>().Be(true);
        }
예제 #5
0
        public async void CountAllAsync()
        {
            using var db = new SampleDb();
            var employees = await db.CountAllAsync(typeof(Employee));

            employees.Should <int>().BeGreaterThan(0);
        }
예제 #6
0
        public async void CreateTable()
        {
            using var db = new SampleDb();
            var result = await db.Definition.CreateTableAsync <Thing>();

            result.Should <int>().Be(-1);
        }
예제 #7
0
        public void SelectAll()
        {
            using var db = new SampleDb();
            var employees = db.Employees.SelectAll();

            Assert.Equal(5, employees.Count());
        }
예제 #8
0
        public async void DropTable()
        {
            using var db = new SampleDb();
            await db.Definition.DropTableAsync <Employee>();

            var result = await Utils.ExistsEmployees();

            result.Should <bool>().Be(false);
        }
예제 #9
0
        public async void InsertAsync()
        {
            var fixture = new Fixture();

            using var db = new SampleDb();
            var employee = fixture.Create <Employee>();
            await db.Employees.InsertAsync(employee, false);

            Assert.NotEqual(0, employee.EmployeeId);
        }
예제 #10
0
        public async void InsertManyAsync()
        {
            var fixture = new Fixture();

            using var db = new SampleDb();
            var employees = fixture.CreateMany <Employee>(5);
            await db.Employees.InsertManyAsync(employees, false);

            employees.Count().Should().Be(5);
        }
예제 #11
0
        public async void SelectSingleAsync()
        {
            using var db = new SampleDb();
            var employee = new Employee()
            {
                EmployeeId = 1
            };
            var employees = await db.SelectSingleAsync(employee);

            Assert.NotEqual(0, employee.FullName.Length);
        }
예제 #12
0
        public void ValidUpdate()
        {
            using var db = new SampleDb();
            var toUpdate = db.Employees.SelectAll().FirstOrDefault();
            var newValue = new Random().Next(100);

            toUpdate.Children = newValue;

            db.Update(toUpdate);
            Assert.True(toUpdate.Children == newValue);
        }
예제 #13
0
        public void InsertUpdate()
        {
            var fixture = new Fixture();

            using var db = new SampleDb();
            var employee = fixture.Build <Employee>()
                           .Without(x => x.Reads)
                           .Create();

            db.Employees.Insert(employee, true);
            employee.Reads.Should().BeGreaterThan(0);
        }
예제 #14
0
파일: Utils.cs 프로젝트: unosquare/pocodata
        /**
         * This method should be changed to read the user without using the library
         */
        public static Employee?SelectEmployee(int employeeId)
        {
            var employee = new Employee
            {
                EmployeeId = employeeId
            };

            using var db = new SampleDb();
            var result = db.Employees.SelectSingle(employee);

            return(result ? employee : null);
        }
예제 #15
0
        public void ValidInsert()
        {
            using var db = new SampleDb();
            var data = new Employee()
            {
                FullName     = "José Correa",
                EmailAddress = "*****@*****.**",
                Children     = 0,
                DateOfBirth  = new DateTime(1995, 6, 12)
            };

            var result = db.Employees.Insert(data, false);

            Assert.True(data.EmployeeId != 0);
        }
예제 #16
0
        public async void DeleteAsync()
        {
            using (var db = new SampleDb())
            {
                var employee = new Employee()
                {
                    EmployeeId = 1
                };

                await db.Employees.DeleteAsync(employee);
            }

            var newData = Utils.SelectEmployee(1);

            Assert.Null(newData);
        }
예제 #17
0
        public async void UpdateAsync()
        {
            var fixture = new Fixture();

            var employee = fixture.Build <Employee>()
                           .With(x => x.EmployeeId, 1)
                           .Create();

            using (var db = new SampleDb())
            {
                await db.Employees.UpdateAsync(employee);
            }

            var newValue = Utils.SelectEmployee(1);

            newValue.FullName.Should().Be(employee.FullName);
            newValue.EmailAddress.Should().Be(employee.EmailAddress);
            newValue.DateOfBirth.Should().BeCloseTo(employee.DateOfBirth);
            newValue.Children.Should().Be(employee.Children);
            newValue.Reads.Should().Be(employee.Reads);
        }
예제 #18
0
 public async void CreateTableStringKey()
 {
     using var db = new SampleDb();
     await Assert.ThrowsAsync <SqlException>
         (() => db.Definition.CreateTableAsync <ThingStringKey>());
 }
예제 #19
0
 public async void DropInvalidTable()
 {
     using var db = new SampleDb();
     await Assert.ThrowsAsync <SqlException>(
         () => db.Definition.DropTableAsync <Thing>());
 }
예제 #20
0
 public void ValidConnection()
 {
     using var db = new SampleDb();
     Assert.True(db.Connection?.State == System.Data.ConnectionState.Open);
 }