public void Select_With_All_Possible_Member_Expression_In_Where_Clause()
        {
            string query = null;

            object[] parameters = null;
            var      session    = GetSession((q, v) =>
            {
                query      = q;
                parameters = v;
            }, TestDataHelper.CreateMultipleValuesRowSet(new[] { "id" }, new[] { 5000 }));
            var map = new Map <AllTypesEntity>()
                      .ExplicitColumns()
                      .Column(t => t.DoubleValue, cm => cm.WithName("c0"))
                      .Column(t => t.StringValue, cm => cm.WithName("c1"))
                      .Column(t => t.IntValue, cm => cm.WithName("c2"))
                      .Column(t => t.BooleanValue, cm => cm.WithName("c3"))
                      .Column(t => t.DateTimeValue, cm => cm.WithName("c4"))
                      .Column(t => t.UuidValue, cm => cm.WithName("c5"))
                      .Column(t => t.DecimalValue, cm => cm.WithName("c6"))
                      .Column(t => t.Int64Value, cm => cm.WithName("id"))
                      .PartitionKey(t => t.Int64Value)
                      .TableName("tbl1");
            var table         = GetTable <AllTypesEntity>(session, map);
            var fieldWithProp = new AllTypesEntity {
                Int64Value = long.MaxValue
            };

            ClassWithPublicField.DecimalStaticField++;
            var fieldWithField = new ClassWithPublicField {
                GuidField = Guid.NewGuid()
            };

            _instanceField++;
            InstanceProperty = true;
            var date      = DateTime.UtcNow;
            var linqQuery = from t in table
                            where
                            t.Int64Value == fieldWithProp.Int64Value &&
                            t.DoubleValue == ClassWithPublicField.DoubleConstant &&
                            t.StringValue == fieldWithProp.IntValue.ToString() &&
                            t.IntValue == _instanceField &&
                            t.BooleanValue == InstanceProperty &&
                            t.DateTimeValue == date &&
                            t.UuidValue == fieldWithField.GuidField &&
                            t.DecimalValue == ClassWithPublicField.DecimalStaticField
                            select new { Age = t.DoubleValue, Id = t.Int64Value };

            linqQuery.Execute();
            Assert.AreEqual(
                "SELECT c0, id FROM tbl1 " +
                "WHERE id = ? AND c0 = ? AND c1 = ? AND c2 = ? AND c3 = ? AND c4 = ? AND c5 = ? AND c6 = ?",
                query);
            CollectionAssert.AreEqual(parameters, new object[]
            {
                fieldWithProp.Int64Value, ClassWithPublicField.DoubleConstant, "0",
                _instanceField, InstanceProperty, date, fieldWithField.GuidField,
                ClassWithPublicField.DecimalStaticField
            });
        }
        public void TestResetKeysSingleEntityPrivateSetter()
        {
            //SETUP
            var options = SqliteInMemory.CreateOptions <SpecializedDbContext>();

            using (var context = new SpecializedDbContext(options))
            {
                var entity = new AllTypesEntity();
                entity.SetId(123);

                //ATTEMPT
                var resetter = new DataResetter(context);
                resetter.ResetKeysSingleEntity(entity);

                //VERIFY
                entity.Id.ShouldEqual(0);
            }
        }
        public void TestAllTypesEntity()
        {
            //SETUP
            var logs = new List <LogOutput>();

            //var options = SqliteInMemory.CreateOptionsWithLogging<AllTypesDbContext>(log => logs.Add(log));
#pragma warning disable 618
            var options = this.CreateUniqueClassOptionsWithLogging <AllTypesDbContext>(log => logs.Add(log));
#pragma warning restore 618
            using (var context = new AllTypesDbContext(options))
            {
                context.Database.EnsureCreated();
                logs.Clear();

                var entity = new AllTypesEntity
                {
                    MyGuid           = Guid.NewGuid(),
                    MyDateTime       = new DateTime(2000, 1, 2),
                    MyDateTimeOffset = new DateTimeOffset(new DateTime(2004, 5, 6), new TimeSpan(1, 0, 0)),
                    MyTimeSpan       = new TimeSpan(4, 5, 6),
                    MyByteArray      = new byte[] { 1, 2, 3 }
                };
                context.Add(entity);
                context.SaveChanges();

                //ATTEMPT
                var decoded = logs.Last().DecodeMessage();

                //VERIFY
                var sqlCommand = decoded.Split('\n').Skip(1).Select(x => x.Trim()).ToArray();
                int i          = 0;
                sqlCommand[i++].ShouldEqual("SET NOCOUNT ON;");
                sqlCommand[i++].ShouldEqual("INSERT INTO [AllTypesEntities] ([MyAnsiNonNullString], [MyBool], [MyBoolNullable], [MyByteArray], [MyDateTime], [MyDateTimeNullable], [MyDateTimeOffset], [MyDecimal], [MyDouble], [MyGuid], [MyGuidNullable], [MyInt], [MyIntNullable], [MyString], [MyStringEmptyString], [MyStringNull], [MyTimeSpan])");
                //can't test for new Guid so do before and after
                sqlCommand[i].ShouldStartWith("VALUES ('ascii only', 1, NULL, '0x010203', '2000-01-02T00:00:00.0000000', NULL, '2004-05-06T00:00:00.0000000+01:00', '3456.789', '5678.9012', '");
                sqlCommand[i++].ShouldEndWith("', NULL, '1234', NULL, 'string with '' in it', NULL, NULL, '04:05:06');");
                sqlCommand[i++].ShouldEqual("SELECT [Id]");
                sqlCommand[i++].ShouldEqual("FROM [AllTypesEntities]");
                sqlCommand[i++].ShouldEqual("WHERE @@ROWCOUNT = 1 AND [Id] = scope_identity();");
            }
        }