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;
        }
 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;
 }
Example #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);
 }
Example #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);
        }
Example #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);
 }
 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);
 }
        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;
        }
 private BoundStatement GetBoundInsertStatementBasedOnEntity(ManyDataTypesEntity entity)
 {
     BoundStatement boundStatement = _preparedStatement.Bind(ConvertEntityToObjectArray(entity));
     return boundStatement;
 }
Example #9
0
 public static void AssertListContains(List <ManyDataTypesEntity> expectedEntities, ManyDataTypesEntity actualEntity)
 {
     Assert.IsTrue(ListContains(expectedEntities, actualEntity));
 }
 public static void AssertListContains(List<ManyDataTypesEntity> expectedEntities, ManyDataTypesEntity actualEntity)
 {
     Assert.IsTrue(ListContains(expectedEntities, actualEntity));
 }
 public static bool ListContains(List<ManyDataTypesEntity> expectedEntities, ManyDataTypesEntity actualEntity)
 {
     foreach (var expectedEntity in expectedEntities)
     {
         try
         {
             expectedEntity.AssertEquals(actualEntity);
             return true;
         }
         catch (AssertionException) { }
     }
     return false;
 }