Ejemplo n.º 1
0
        public async Task Insert_With_Assigned_Key(Type dataContextType)
        {
            // Arrange
            using IDataContext dataContext = DataContextTestHelper.SetupDataContext(dataContextType);

            // Act
            CityManual city = await dataContext.Create(new CityManual()
            {
                CityCode = "BRI", CityName = "Brighton"
            });

            // Assert
            Assert.AreEqual("BRI", city.CityCode);
            Assert.AreEqual("Brighton", city.CityName);
        }
        public async Task Insert_With_Assigned_Key()
        {
            using (IDbConnection connection = LocalDbTestHelper.OpenTestConnection(TestContext.CurrentContext.Test.FullName))
            {
                // Act
                CityManual city = await connection.Create <CityManual>(new CityManual()
                {
                    CityCode = "BRI",
                    CityName = "Brighton"
                }).ConfigureAwait(false);

                // Assert
                Assert.AreEqual("BRI", city.CityCode);
                Assert.AreEqual("Brighton", city.CityName);
            }
        }
Ejemplo n.º 3
0
        public async Task Read_By_Id_With_Assigned_Single_Typed_Argument(Type dataContextType)
        {
            // Arrange
            using IDataContext dataContext = DataContextTestHelper.SetupDataContext(dataContextType);
            await dataContext.Create(new CityManual()
            {
                CityCode = "PUP", CityName = "Portsmouth"
            });

            await dataContext.Create(new CityManual()
            {
                CityCode = "NYC", CityName = "New York City"
            });

            // Act
            CityManual city = await dataContext.Read <CityManual>("NYC");

            // Assert
            Assert.AreEqual("NYC", city.CityCode);
            Assert.AreEqual("New York City", city.CityName);
        }
Ejemplo n.º 4
0
        public async Task Read_By_Id_With_Assigned_Property_Bag(Type dataContextType)
        {
            // Arrange
            IDataContext dataContext = DataContextTestHelper.GetDataContext(dataContextType);
            await dataContext.Create(new CityManual()
            {
                CityCode = "PUP", CityName = "Portsmouth"
            });

            await dataContext.Create(new CityManual()
            {
                CityCode = "NYC", CityName = "New York City"
            });

            // Act
            CityManual city = await dataContext.Read <CityManual>(new { CityCode = "NYC" });

            // Assert
            Assert.AreEqual("NYC", city.CityCode);
            Assert.AreEqual("New York City", city.CityName);
        }
Ejemplo n.º 5
0
        public async Task Read_By_Id_With_Assigned_Single_Typed_Argument()
        {
            using (IDbConnection connection = LocalDbTestHelper.OpenTestConnection(TestContext.CurrentContext.Test.FullName))
            {
                // Arrange
                await connection.Create(new CityManual()
                {
                    CityCode = "PUP", CityName = "Portsmouth"
                });

                await connection.Create(new CityManual()
                {
                    CityCode = "NYC", CityName = "New York City"
                });

                // Act
                CityManual city = await connection.Read <CityManual>("NYC");

                // Assert
                Assert.AreEqual("NYC", city.CityCode);
                Assert.AreEqual("New York City", city.CityName);
            }
        }