Inheritance: INotifyPropertyChanged
        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
            });
        }
Esempio n. 2
0
        private void GivenClassWithPublicField_ReturnsCorrectNumberOfMembers(ClassWithPublicField instance)
        {
            // arrange

            // act
            var memberDictionary = instance.ToDictionary();

            // assert
            Assert.Equal(1, memberDictionary.Count);
        }
        private void GivenClassWithPublicField_ReturnsCorrectNumberOfMembers(ClassWithPublicField instance)
        {
            // arrange

            // act
            var memberDictionary = instance.ToDictionary();

            // assert
            Assert.Equal(1, memberDictionary.Count);
        }
 public void E_PassingAnObjectOfAClassIsByReference()
 {
     // Passing an object of a class to a function is by reference.
     // This means that if the object is at address X in memory, X is
     // passed to the function.
     ClassWithPublicField obj = new ClassWithPublicField();
     obj.n = 1;
     Assign5ToN(obj);
     Assert.Equal(FILL_ME_IN, obj.n);
 }
        public void PassingAnObjectOfAClassIsByReference()
        {
            // Passing an object of a class to a function is by reference.
            // This means that if the object is at address X in memory, X is
            // passed to the function.
            ClassWithPublicField obj = new ClassWithPublicField();

            obj.n = 1;
            Assign5ToN(obj);
            Assert.Equal(5, obj.n);
        }
 public void F_ObjectPassedToAFunctionCannotBeReassigned()
 {
     // If a function is passed a reference to an object of a class, and
     // reassigns it to a new object, this change is not seen by the
     // caller because if the first object is at address X and the second
     // at address Y, Y will be assigned to objInFunction while obj in the
     // calling function still holds X, because the function does not
     // have access to obj.
     ClassWithPublicField obj = new ClassWithPublicField();
     obj.n = 1;
     RecreateObject(obj);
     Assert.Equal(FILL_ME_IN, obj.n);
 }
 public void D_VariablesHoldReferencesToObjectsOfClasses()
 {
     // If you create an object of a class and assign it to a variable,
     // the variable has a reference to the object. This means that if
     // the object at the address X in memory, the variable holds the
     // value of X. If you assign it to another variable, that new
     // variable will hold the address X, so changes to it are also seen
     // with the first variable.
     ClassWithPublicField obj1 = new ClassWithPublicField();
     obj1.n = 1;
     ClassWithPublicField obj2 = obj1;
     obj2.n = 5;
     Assert.Equal(FILL_ME_IN, obj1.n);
 }
        public void ObjectPassedToAFunctionCannotBeReassigned()
        {
            // If a function is passed a reference to an object of a class, and
            // reassigns it to a new object, this change is not seen by the
            // caller because if the first object is at address X and the second
            // at address Y, Y will be assigned to objInFunction while obj in the
            // calling function still holds X, because the function does not
            // have access to obj.
            ClassWithPublicField obj = new ClassWithPublicField();

            obj.n = 1;
            RecreateObject(obj);
            Assert.Equal(1, obj.n);
        }
        public void VariablesHoldReferencesToObjectsOfClasses()
        {
            // If you create an object of a class and assign it to a variable,
            // the variable has a reference to the object. This means that if
            // the object at the address X in memory, the variable holds the
            // value of X. If you assign it to another variable, that new
            // variable will hold the address X, so changes to it are also seen
            // with the first variable.
            ClassWithPublicField obj1 = new ClassWithPublicField();

            obj1.n = 1;
            ClassWithPublicField obj2 = obj1;

            obj2.n = 5;
            Assert.Equal(5, obj1.n);
        }
Esempio n. 10
0
            public void BuildAccessorForPublicField_ItCanReadAndWrite()
            {
                var field = GetField <ClassWithPublicField>();

                var accessor = FieldAccessorBuilder.BuildFor(typeof(ClassWithPublicField), field, true);

                Assert.That(accessor.CanGet && accessor.CanSet);
                var data = new ClassWithPublicField {
                    field = RandomInt()
                };

                Assert.That(accessor.GetMember(data), Is.EqualTo(data.field));
                var fieldValue = RandomInt();

                accessor.SetMember(data, fieldValue);
                Assert.That(data.field, Is.EqualTo(fieldValue));
            }
 public void Write(ClassWithPublicField application)
 {
     Debug.WriteLine(application.Property1.ToString());
 }
 void RecreateObject(ClassWithPublicField objInFunction)
 {
     objInFunction = new ClassWithPublicField();
     objInFunction.n = 5;
 }
 void Assign5ToN(ClassWithPublicField objInFunction)
 {
     objInFunction.n = 5;
 }
 public void TestGenerate_KeyRefersToPublicField_SubstitutesValue()
 {
     FormatCompiler compiler = new FormatCompiler();
     const string format = @"Hello, {{Field}}!!!";
     Generator generator = compiler.Compile(format);
     ClassWithPublicField instance = new ClassWithPublicField() { Field = "Bob" };
     string result = generator.Render(instance);
     Assert.AreEqual("Hello, Bob!!!", result, "The wrong text was generated.");
 }
 public void Write(ClassWithPublicField application)
 {
     Debug.WriteLine(application.Property1.ToString());
 }
 void Assign5ToN(ClassWithPublicField objInFunction)
 {
     objInFunction.n = 5;
 }
 void RecreateObject(ClassWithPublicField objInFunction)
 {
     objInFunction   = new ClassWithPublicField();
     objInFunction.n = 5;
 }