コード例 #1
0
        public static ManyDataTypesEntity GetRandomInstance()
        {
            Dictionary<string, long> dictionaryStringLong = new Dictionary<string, long>() { { "key_" + Randomm.RandomAlphaNum(10), (long)1234321 } };
            Dictionary<string, string> dictionaryStringString = new Dictionary<string, string>() { { "key_" + Randomm.RandomAlphaNum(10), "value_" + Randomm.RandomAlphaNum(10) } };
            List<Guid> listOfGuidsType = new List<Guid>() { Guid.NewGuid(), Guid.NewGuid() };
            List<string> listOfStringsType = new List<string>() { Randomm.RandomAlphaNum(20), Randomm.RandomAlphaNum(12), "" };


            ManyDataTypesEntity randomRow = new ManyDataTypesEntity
            {
                StringType = "StringType_val_" + Randomm.RandomAlphaNum(10),
                GuidType = Guid.NewGuid(),
                DateTimeType = DateTime.Now.ToUniversalTime(),
                DateTimeOffsetType = new DateTimeOffset(),
                BooleanType = false,
                DecimalType = (decimal)98765432.0,
                DoubleType = (double)9876543,
                FloatType = (float)987654,
                NullableIntType = null,
                IntType = 98765,
                Int64Type = (Int64)9876,
                //TimeUuidType = TimeUuid.NewId(),
                //NullableTimeUuidType = null,
                DictionaryStringLongType = dictionaryStringLong,
                DictionaryStringStringType = dictionaryStringString,
                ListOfGuidsType = listOfGuidsType,
                ListOfStringsType = listOfStringsType,
            };
            return randomRow;
        }
コード例 #2
0
 private string GetSimpleStatementInsertString(ManyDataTypesEntity entity)
 {
     string strForSimpleStatement = string.Format(_simpleStatementInsertFormat, 
         new object[] {
         entity.StringType, entity.GuidType, entity.BooleanType, entity.DecimalType, 
         entity.DoubleType, entity.FloatType, entity.IntType, entity.Int64Type
         });
     return strForSimpleStatement;
 }
コード例 #3
0
 public static bool ListContains(List <ManyDataTypesEntity> expectedEntities, ManyDataTypesEntity actualEntity)
 {
     foreach (var expectedEntity in expectedEntities)
     {
         try
         {
             expectedEntity.AssertEquals(actualEntity);
             return(true);
         }
         catch (AssertionException) { }
     }
     return(false);
 }
コード例 #4
0
        public static ManyDataTypesEntity GetRandomInstance()
        {
            Dictionary <string, long> dictionaryStringLong = new Dictionary <string, long>()
            {
                { "key_" + Randomm.RandomAlphaNum(10), (long)1234321 }
            };
            Dictionary <string, string> dictionaryStringString = new Dictionary <string, string>()
            {
                { "key_" + Randomm.RandomAlphaNum(10), "value_" + Randomm.RandomAlphaNum(10) }
            };
            List <Guid> listOfGuidsType = new List <Guid>()
            {
                Guid.NewGuid(), Guid.NewGuid()
            };
            List <string> listOfStringsType = new List <string>()
            {
                Randomm.RandomAlphaNum(20), Randomm.RandomAlphaNum(12), ""
            };


            ManyDataTypesEntity randomRow = new ManyDataTypesEntity
            {
                StringType         = "StringType_val_" + Randomm.RandomAlphaNum(10),
                GuidType           = Guid.NewGuid(),
                DateTimeType       = DateTime.Now.ToUniversalTime(),
                DateTimeOffsetType = new DateTimeOffset(),
                BooleanType        = false,
                DecimalType        = (decimal)98765432.0,
                DoubleType         = (double)9876543,
                FloatType          = (float)987654,
                NullableIntType    = null,
                IntType            = 98765,
                Int64Type          = (Int64)9876,
                //TimeUuidType = TimeUuid.NewId(),
                //NullableTimeUuidType = null,
                DictionaryStringLongType   = dictionaryStringLong,
                DictionaryStringStringType = dictionaryStringString,
                ListOfGuidsType            = listOfGuidsType,
                ListOfStringsType          = listOfStringsType,
            };

            return(randomRow);
        }
コード例 #5
0
 public void AssertEquals(ManyDataTypesEntity actualRow)
 {
     Assert.AreEqual(StringType, actualRow.StringType);
     Assert.AreEqual(GuidType, actualRow.GuidType);
     Assert.AreEqual(DateTimeType.ToString(), actualRow.DateTimeType.ToString()); // 'ToString' rounds to the nearest second
     Assert.AreEqual(DateTimeOffsetType.ToString(), actualRow.DateTimeOffsetType.ToString());
     Assert.AreEqual(BooleanType, actualRow.BooleanType);
     Assert.AreEqual(DecimalType, actualRow.DecimalType);
     Assert.AreEqual(DoubleType, actualRow.DoubleType);
     Assert.AreEqual(FloatType, actualRow.FloatType);
     Assert.AreEqual(IntType, actualRow.IntType);
     Assert.AreEqual(Int64Type, actualRow.Int64Type);
     //Assert.AreEqual(TimeUuidType, actualRow.TimeUuidType);
     //Assert.AreEqual(NullableTimeUuidType, actualRow.NullableTimeUuidType);
     Assert.AreEqual(DictionaryStringLongType, actualRow.DictionaryStringLongType);
     Assert.AreEqual(DictionaryStringStringType, actualRow.DictionaryStringStringType);
     Assert.AreEqual(ListOfGuidsType, actualRow.ListOfGuidsType);
     Assert.AreEqual(ListOfStringsType, actualRow.ListOfStringsType);
 }
コード例 #6
0
 public void AssertEquals(ManyDataTypesEntity actualRow)
 {
     Assert.AreEqual(StringType, actualRow.StringType);
     Assert.AreEqual(GuidType, actualRow.GuidType);
     Assert.AreEqual(DateTimeType.ToString(), actualRow.DateTimeType.ToString()); // 'ToString' rounds to the nearest second
     Assert.AreEqual(DateTimeOffsetType.ToString(), actualRow.DateTimeOffsetType.ToString());
     Assert.AreEqual(BooleanType, actualRow.BooleanType);
     Assert.AreEqual(DecimalType, actualRow.DecimalType);
     Assert.AreEqual(DoubleType, actualRow.DoubleType);
     Assert.AreEqual(FloatType, actualRow.FloatType);
     Assert.AreEqual(IntType, actualRow.IntType);
     Assert.AreEqual(Int64Type, actualRow.Int64Type);
     //Assert.AreEqual(TimeUuidType, actualRow.TimeUuidType);
     //Assert.AreEqual(NullableTimeUuidType, actualRow.NullableTimeUuidType);
     Assert.AreEqual(DictionaryStringLongType, actualRow.DictionaryStringLongType);
     Assert.AreEqual(DictionaryStringStringType, actualRow.DictionaryStringStringType);
     Assert.AreEqual(ListOfGuidsType, actualRow.ListOfGuidsType);
     Assert.AreEqual(ListOfStringsType, actualRow.ListOfStringsType);
 }
コード例 #7
0
        private static object[] ConvertEntityToObjectArray(ManyDataTypesEntity mdtp)
        {
            // ToString() Example output: 
            // INSERT INTO "ManyDataTypesPoco" ("StringType", "GuidType", "DateTimeType", "DateTimeOffsetType", "BooleanType", 
            // "DecimalType", "DoubleType", "FloatType", "NullableIntType", "IntType", "Int64Type", 
            // "TimeUuidType", "NullableTimeUuidType", "DictionaryStringLongType", "DictionaryStringStringType", "ListOfGuidsType", "ListOfStringsType") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)

            object[] vals =  
            {
                mdtp.StringType, mdtp.GuidType, mdtp.DateTimeType, mdtp.DateTimeOffsetType, mdtp.BooleanType, 
                mdtp.DecimalType, mdtp.DoubleType, mdtp.FloatType, mdtp.NullableIntType, mdtp.IntType, mdtp.Int64Type,
                // mdtp.TimeUuidType, 
                // mdtp.NullableTimeUuidType, 
                mdtp.DictionaryStringLongType, mdtp.DictionaryStringStringType, mdtp.ListOfGuidsType, mdtp.ListOfStringsType,
            };

            return vals;
        }
コード例 #8
0
 private BoundStatement GetBoundInsertStatementBasedOnEntity(ManyDataTypesEntity entity)
 {
     BoundStatement boundStatement = _preparedStatement.Bind(ConvertEntityToObjectArray(entity));
     return boundStatement;
 }
コード例 #9
0
 public static void AssertListContains(List <ManyDataTypesEntity> expectedEntities, ManyDataTypesEntity actualEntity)
 {
     Assert.IsTrue(ListContains(expectedEntities, actualEntity));
 }
コード例 #10
0
 public static void AssertListContains(List<ManyDataTypesEntity> expectedEntities, ManyDataTypesEntity actualEntity)
 {
     Assert.IsTrue(ListContains(expectedEntities, actualEntity));
 }
コード例 #11
0
 public static bool ListContains(List<ManyDataTypesEntity> expectedEntities, ManyDataTypesEntity actualEntity)
 {
     foreach (var expectedEntity in expectedEntities)
     {
         try
         {
             expectedEntity.AssertEquals(actualEntity);
             return true;
         }
         catch (AssertionException) { }
     }
     return false;
 }