public void HashCodeShouldHaveSameBehaviorOfNetType()
		{
			var type = new DateTimeOffsetType();
			var now = DateTimeOffset.Now;
			var exactClone = new DateTimeOffset(now.Ticks, now.Offset);
			(now.GetHashCode() == exactClone.GetHashCode()).Should().Be.EqualTo(now.GetHashCode() == type.GetHashCode(exactClone, EntityMode.Poco));
		}
Example #2
0
        public static void Equals(DateTimeOffset dateTimeOffset1, object obj, bool expectedEquals, bool expectedEqualsExact)
        {
            Assert.Equal(expectedEquals, dateTimeOffset1.Equals(obj));
            if (obj is DateTimeOffset)
            {
                DateTimeOffset dateTimeOffset2 = (DateTimeOffset)obj;
                Assert.Equal(expectedEquals, dateTimeOffset1.Equals(dateTimeOffset2));
                Assert.Equal(expectedEquals, DateTimeOffset.Equals(dateTimeOffset1, dateTimeOffset2));

                Assert.Equal(expectedEquals, dateTimeOffset1.GetHashCode().Equals(dateTimeOffset2.GetHashCode()));
                Assert.Equal(expectedEqualsExact, dateTimeOffset1.EqualsExact(dateTimeOffset2));

                Assert.Equal(expectedEquals, dateTimeOffset1 == dateTimeOffset2);
                Assert.Equal(!expectedEquals, dateTimeOffset1 != dateTimeOffset2);
            }
        }
Example #3
0
 private static DateTimeOffset ChangeTime(DateTimeOffset date, object more)
 {
     var random = new Random(date.GetHashCode() + more.GetHashCode());
     return new DateTimeOffset(date.Year, date.Month, date.Day, random.Next(0, 23), random.Next(0, 59), random.Next(0, 59), random.Next(0, 999), date.Offset);
 }
Example #4
0
 private static async Task CreateContactAsync(DbConnection connection, Guid saleHeaderId, string employee, DateTimeOffset date, int index)
 {
     var random = new Random(date.GetHashCode() + saleHeaderId.GetHashCode() + employee.GetHashCode() + index);
     var method = methods[random.Next(0, methods.Count - 1)];
     await connection.CreateCommand("INSERT INTO [tc_customer_contact]([id],[sale_id],[method],[value],[created],[created_by],[modified],[modified_by])" +
         "VALUES(@id,@sale_id,@method,@value,@created,@created_by,@modified,@modified_by)")
         .AddParameter("@id", DbType.Guid, 0, Guid.NewGuid())
         .AddParameter("@sale_id", DbType.Guid, 0, saleHeaderId)
         .AddParameter("@method", DbType.Byte, 0, method)
         .AddParameter("@value", DbType.String, 1024, GenerateRandomMethodValue(random, method))
         .AddParameter("@status", DbType.Byte, 0, states[random.Next(0, states.Count - 1)])
         .AddParameter("@created", DbType.DateTimeOffset, 0, date)
         .AddParameter("@created_by", DbType.String, 64, employee)
         .AddParameter("@modified", DbType.DateTimeOffset, 0, date)
         .AddParameter("@modified_by", DbType.String, 64, employee)
         .ExecuteNonQueryAsync();
 }
Example #5
0
 private static async Task CreateSaleLineAsync(DbConnection connection, Guid saleHeaderId, string employee, DateTimeOffset date, int index)
 {
     var random = new Random(date.GetHashCode() + saleHeaderId.GetHashCode() + employee.GetHashCode() + index);
     var product = products[random.Next(0, products.Count - 1)];
     await connection.CreateCommand("INSERT INTO [tc_sale_line]([id],[sale_id],[product_name],[product_description],[product_detail],[unit_price],[quantity],[status],[created],[created_by],[modified],[modified_by])" +
         "VALUES(@id,@sale_id,@product_name,@product_description,@product_detail,@unit_price,@quantity,@status,@created,@created_by,@modified,@modified_by)")
         .AddParameter("@id", DbType.Guid, 0, Guid.NewGuid())
         .AddParameter("@sale_id", DbType.Guid, 0, saleHeaderId)
         .AddParameter("@product_name", DbType.String, 64, product)
         .AddParameter("@product_description", DbType.String, 1024, descriptions[random.Next(0, descriptions.Count - 1)])
         .AddParameter("@product_detail", DbType.Xml, 0, GenerateProductDetail(random, product))
         .AddParameter("@unit_price", DbType.Currency, 0, (decimal)Math.Round((random.NextDouble() + .1D) * random.Next(10000, 10000 * 10000)))
         .AddParameter("@quantity", DbType.Int32, 0, random.Next(1, 3))
         .AddParameter("@status", DbType.Byte, 0, states[random.Next(0, states.Count - 1)])
         .AddParameter("@created", DbType.DateTimeOffset, 0, date)
         .AddParameter("@created_by", DbType.String, 64, employee)
         .AddParameter("@modified", DbType.DateTimeOffset, 0, date)
         .AddParameter("@modified_by", DbType.String, 64, employee)
         .ExecuteNonQueryAsync();
 }
Example #6
0
 private static async Task<Guid> CreateSaleHeaderAsync(DbConnection connection, string employee, DateTimeOffset date)
 {
     var random = new Random(date.GetHashCode() + employee.GetHashCode());
     int maxDayNumber, maxTotalNumber;
     {
         var raw = await connection.CreateCommand("SELECT MAX(sale_day_number) FROM tc_sale_header WHERE [created] >= CONVERT(DATETIMEOFFSET, @from) AND [created] < CONVERT(DATETIMEOFFSET, @to)")
             .AddParameter("@from", DbType.AnsiString, 64, date.ToString("d", CultureInfo.InvariantCulture))
             .AddParameter("@to", DbType.AnsiString, 64, date.AddDays(1).ToString("d", CultureInfo.InvariantCulture))
             .ExecuteScalarAsync();
         maxDayNumber = Convert.IsDBNull(raw) ? 0 : (int)raw;
     }
     {
         var raw = await connection.CreateCommand("SELECT MAX(sale_total_number) FROM tc_sale_header")
             .ExecuteScalarAsync();
         maxTotalNumber = Convert.IsDBNull(raw) ? 0 : (int)raw;
     }
     var id = Guid.NewGuid();
     await connection.CreateCommand("INSERT INTO [tc_sale_header]([id],[sale_number],[sale_day_number],[sale_total_number],[sales_person_name],[customer_name],[status],[created],[created_by],[modified],[modified_by])" +
         "VALUES(@id,@number_text,@day_number,@total_number,@sales_person_name,@customer_name,@status,@created,@created_by,@modified,@modified_by)")
         .AddParameter("@id", DbType.Guid, 0, id)
         .AddParameter("@number_text", DbType.AnsiString, 64, GenerateNumberText(date, maxDayNumber + 1, maxTotalNumber + 1))
         .AddParameter("@day_number", DbType.Int32, 0, maxDayNumber + 1)
         .AddParameter("@total_number", DbType.Int32, 0, maxTotalNumber + 1)
         .AddParameter("@sales_person_name", DbType.String, 64, employee)
         .AddParameter("@customer_name", DbType.String, 64, names[random.Next(0, names.Count - 1)])
         .AddParameter("@status", DbType.Byte, 0, states[random.Next(0, states.Count - 1)])
         .AddParameter("@created", DbType.DateTimeOffset, 0, date)
         .AddParameter("@created_by", DbType.String, 64, employee)
         .AddParameter("@modified", DbType.DateTimeOffset, 0, date)
         .AddParameter("@modified_by", DbType.String, 64, employee)
         .ExecuteNonQueryAsync();
     return id;
 }