Esempio n. 1
0
        public void InProcess()
        {
            using (var context = new UnitTestContext(this))
            {
                // Create base instance
                var baseSample = new BaseSample();
                baseSample.RecordName  = "InProcess";
                baseSample.RecordIndex = 1;
                baseSample.Init(context);

                // Invoke handlers of the base class
                baseSample.NonVirtualBaseHandler();
                baseSample.VirtualBaseHandler();

                // Create derived instance
                var derivedSample = new DerivedSample();
                derivedSample.Init(context);

                // Invoke handlers of the derived class
                derivedSample.NonVirtualDerivedHandler();
                derivedSample.VirtualBaseHandler();
            }
        }
Esempio n. 2
0
        /// <summary>Save derived record.</summary>
        private TemporalId SaveDerivedRecord(Context context, string dataSetName, string recordName, int recordIndex)
        {
            var rec = new DerivedSample();

            rec.RecordName           = recordName;
            rec.RecordIndex          = recordIndex;
            rec.DoubleElement        = 300.0;
            rec.LocalDateElement     = new LocalDate(2003, 5, 1);
            rec.LocalTimeElement     = new LocalTime(10, 15, 30);                                         // 10:15:30
            rec.LocalMinuteElement   = new LocalMinute(10, 15);                                           // 10:15
            rec.LocalDateTimeElement = new LocalDateTime(2003, 5, 1, 10, 15);                             // 2003-05-01T10:15:00
            rec.InstantElement       = new LocalDateTime(2003, 5, 1, 10, 15).ToInstant(DateTimeZone.Utc); // 2003-05-01T10:15:00
            rec.StringElement2       = String.Empty;                                                      // Test how empty value is recorded
            rec.DoubleElement2       = 200.0;

            // String collections
            rec.ArrayOfString = new string[] { "A", "B", "C" };
            rec.ListOfString  = new List <string>()
            {
                "A", "B", "C"
            };

            // Double collections
            rec.ArrayOfDouble = new double[] { 1.0, 2.0, 3.0 };
            rec.ListOfDouble  = new List <double>()
            {
                1.0, 2.0, 3.0
            };
            rec.ListOfNullableDouble = new List <double?>();
            rec.ListOfNullableDouble.Add(10.0);
            rec.ListOfNullableDouble.Add(null);
            rec.ListOfNullableDouble.Add(30.0);

            // Data element
            rec.DataElement = new ElementSample();
            rec.DataElement.DoubleElement3 = 1.0;
            rec.DataElement.StringElement3 = "AA";

            // Data element list
            rec.DataElementList = new List <ElementSample>();
            var elementList0 = new ElementSample();

            elementList0.DoubleElement3 = 1.0;
            elementList0.StringElement3 = "A0";
            rec.DataElementList.Add(elementList0);
            var elementList1 = new ElementSample();

            elementList1.DoubleElement3 = 2.0;
            elementList1.StringElement3 = "A1";
            rec.DataElementList.Add(elementList1);

            // Key element
            rec.KeyElement             = new BaseSampleKey();
            rec.KeyElement.RecordName  = "BB";
            rec.KeyElement.RecordIndex = 2;

            // Key element list
            rec.KeyElementList = new List <BaseSampleKey>();
            var keyList0 = new BaseSampleKey();

            keyList0.RecordName  = "B0";
            keyList0.RecordIndex = 3;
            rec.KeyElementList.Add(keyList0);
            var keyList1 = new BaseSampleKey();

            keyList1.RecordName  = "B1";
            keyList1.RecordIndex = 4;
            rec.KeyElementList.Add(keyList1);

            var dataSet = context.GetDataSet(dataSetName);

            context.SaveOne(rec, dataSet);
            return(rec.Id);
        }