Exemplo n.º 1
0
        protected override void Run()
        {
            try
            {
                mDebugger.Send("Run");

                StringTest.Execute();
                ByteTest.Execute();
                SByteTest.Execute();
                Int16Test.Execute();
                UInt16Test.Execute();
                Int32Test.Execute();
                UInt32Test.Execute();
                Int64Test.Execute();
                UInt64Test.Execute();
                CharTest.Execute();
                BooleanTest.Execute();
                SingleTest.Execute();
                BitConverterTest.Execute();
                DoubleTest.Execute();
                DecimalTest.Execute();
                System.Collections.Generic.ListTest.Execute();
                System.Collections.Generic.QueueTest.Execute();
                System.DelegatesTest.Execute();
                System.UInt64Test.Execute();
                TestController.Completed();
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception occurred");
                Console.WriteLine(e.Message);
                mDebugger.Send("Exception occurred: " + e.Message);
                TestController.Failed();
            }
        }
Exemplo n.º 2
0
        protected override void Run()
        {
            try
            {
                mDebugger.Send("Run");

                // C#
                WhileLoopTests.Execute();
                ForeachLoopTests.Execute();

                // System
                ObjectTests.Execute();
                ArrayTests.Execute();
                StringTest.Execute();
                ByteTest.Execute();
                SByteTest.Execute();
                Int16Test.Execute();
                UInt16Test.Execute();
                Int32Test.Execute();
                UInt32Test.Execute();
                Int64Test.Execute();
                UInt64Test.Execute();
                CharTest.Execute();
                BooleanTest.Execute();
                SingleTest.Execute();
                DoubleTest.Execute();
                MathTest.Execute();
                ConvertTests.Execute();

                //mDebugger.Send("Thread test start of 500 ms");
                //ThreadTest.Execute();
                //mDebugger.Send("Thread test end");

                //DecimalTest.Execute();
                BitConverterTest.Execute();
                UnsafeCodeTest.Execute();
                DelegatesTest.Execute();
                RandomTests.Execute();

                // System.Collections.Generic
                ListTest.Execute();
                QueueTest.Execute();
                DictionaryTest.Execute();

                // System.Text
                EncodingTest.Execute();

                TestController.Completed();
            }
            catch (Exception e)
            {
                mDebugger.Send("Exception occurred: " + e.Message);
                mDebugger.Send(e.Message);
                Console.WriteLine("Exception occurred");
                Console.WriteLine(e.Message);
                TestController.Failed();
            }
        }
    public static double[] Test()
    {
        var result = new double[4];
        var i      = 0;

        for (var n = 1000; i < 4; n += n)
        {
            result[i] = DoubleTest.TimeTrial(n);
            i++;
        }
        return(result);
    }
Exemplo n.º 4
0
        public static double[] Test()
        {
            double[] result = new double[4];
            int      i      = 0;

            for (int n = 1000; i < 4; n += n)
            {
                result[i] = DoubleTest.TimeTrial(n);
                i++;
            }
            return(result);
        }
Exemplo n.º 5
0
        public void UserTypeAutoCast()
        {
            Execute_AutoCast(() =>
            {
                Variable doubleTestVariable = DefaultModule.GetVariable("doubleTest");

                Assert.IsType <DoubleTest>(doubleTestVariable);

                DoubleTest doubleTest = (DoubleTest)doubleTestVariable;

                Assert.Equal(3.5, doubleTest.d);
                Assert.Equal(2.5, doubleTest.f);
                Assert.Equal(5, doubleTest.i);
            });
        }
Exemplo n.º 6
0
        public static void TestLinqEnumerationOnDouble()
        {
            {
                var test = new DoubleTest(1);

                var count = 0;
                foreach (var i in test)
                {
                    count++;
                }

                Assert.AreEqual(2, count, "0 - 1 in steps of 1 results in two iterations.");

                count = 0;
                foreach (var i in (IEnumerable <double>)test)
                {
                    count++;
                }
                Assert.AreEqual(11, count, "0 - 1 in steps of 0.1 results in eleven iterations.");

                count = 0;
                foreach (var i in ((IEnumerable <double>)test).Select(d => d))
                {
                    count++;
                }
                Assert.AreEqual(11, count, "0 - 1 in steps of 0.1 results in eleven iterations.");
            }

            {
                IEnumerable <double> test = new DoubleTest(1);
                var count = 0;

                foreach (var i in test)
                {
                    count++;
                }
                Assert.AreEqual(11, count, "0 - 1 in steps of 0.1 results in eleven iterations.");

                count = 0;
                foreach (var i in test.Select(d => d))
                {
                    count++;
                }
                Assert.AreEqual(11, count, "0 - 1 in steps of 0.1 results in eleven iterations.");
            }
        }
Exemplo n.º 7
0
        public void OutputTest()
        {
            // DoubleTest double value for testing
            const double DoubleTest = 0.264;

            // Creating a StringWriter
            using (StringWriter WriterTest = new StringWriter())
            {
                Program.Output(DoubleTest, WriterTest);

                /* Getting the written value by output_result function from the WriterTest
                 * StringWriter and comparing it to the expected string value */
                string OutputTestString = WriterTest.GetStringBuilder().ToString();
                OutputTestString = OutputTestString.Remove(OutputTestString.Length - 2);
                Assert.AreEqual(OutputTestString, DoubleTest.ToString());
            }
        }
Exemplo n.º 8
0
        protected override void Run()
        {
            try
            {
                mDebugger.Send("Run");

                CSharp.WhileLoopTests.Execute();
                CSharp.ForeachLoopTests.Execute();

                //ObjectTests.Execute(); Stack corruption on method Clone()
                ArrayTests.Execute();
                StringTest.Execute();
                ByteTest.Execute();
                SByteTest.Execute();
                Int16Test.Execute();
                UInt16Test.Execute();
                Int32Test.Execute();
                UInt32Test.Execute();
                Int64Test.Execute();
                UInt64Test.Execute();
                CharTest.Execute();
                BooleanTest.Execute();
                SingleTest.Execute();
                DoubleTest.Execute();
                MathTest.Execute();
                //DecimalTest.Execute();
                BitConverterTest.Execute();
                UnsafeCodeTest.Execute();
                DelegatesTest.Execute();

                System.Collections.Generic.ListTest.Execute();
                System.Collections.Generic.QueueTest.Execute();
                //System.Collections.Generic.DictionaryTest.Execute();

                TestController.Completed();
            }
            catch (Exception e)
            {
                mDebugger.Send("Exception occurred: " + e.Message);
                mDebugger.Send(e.Message);
                Console.WriteLine("Exception occurred");
                Console.WriteLine(e.Message);
                TestController.Failed();
            }
        }
Exemplo n.º 9
0
        // The program itself break the DRY principle(Do not repeat yourself).
        // There are available optimal options for generalization but making the test methods generic directly through interface sadly is not supported.
        // See also: http://stackoverflow.com/questions/32664/is-there-a-constraint-that-restricts-my-generic-method-to-numeric-types
        public static void Main()
        {
            // First block parameters
            const int PrimeOperationsNumber     = 500;
            const int SecondaryOperationsNumber = 2;

            const int FirstCountOfRepeats  = 100;
            const int SecondCountOfRepeats = 500;
            const int ThirdCountOfRepeats  = 1000;

            using (StreamWriter streamWriter = new StreamWriter(@"Basic operations test information.txt", false))
            {
                // n=100
                streamWriter.Write(
                    IntTest.PerformTests(FirstCountOfRepeats, PrimeOperationsNumber, SecondaryOperationsNumber));
                streamWriter.Write(
                    LongTest.PerformTests(FirstCountOfRepeats, PrimeOperationsNumber, SecondaryOperationsNumber));
                streamWriter.Write(
                    DoubleTest.PerformTests(FirstCountOfRepeats, PrimeOperationsNumber, SecondaryOperationsNumber));
                streamWriter.Write(
                    FloatTest.PerformTests(FirstCountOfRepeats, PrimeOperationsNumber, SecondaryOperationsNumber));

                // n = 500
                streamWriter.Write(
                    IntTest.PerformTests(SecondCountOfRepeats, PrimeOperationsNumber, SecondaryOperationsNumber));
                streamWriter.Write(
                    LongTest.PerformTests(SecondCountOfRepeats, PrimeOperationsNumber, SecondaryOperationsNumber));
                streamWriter.Write(
                    DoubleTest.PerformTests(SecondCountOfRepeats, PrimeOperationsNumber, SecondaryOperationsNumber));
                streamWriter.Write(
                    FloatTest.PerformTests(SecondCountOfRepeats, PrimeOperationsNumber, SecondaryOperationsNumber));

                // n = 1000
                streamWriter.Write(
                    IntTest.PerformTests(ThirdCountOfRepeats, PrimeOperationsNumber, SecondaryOperationsNumber));
                streamWriter.Write(
                    LongTest.PerformTests(ThirdCountOfRepeats, PrimeOperationsNumber, SecondaryOperationsNumber));
                streamWriter.Write(
                    DoubleTest.PerformTests(ThirdCountOfRepeats, PrimeOperationsNumber, SecondaryOperationsNumber));
                streamWriter.Write(
                    FloatTest.PerformTests(ThirdCountOfRepeats, PrimeOperationsNumber, SecondaryOperationsNumber));
            }
        }
Exemplo n.º 10
0
 public DoubleEnumerator(DoubleTest test)
 {
     _max    = test.Max;
     Current = -.1;
 }
Exemplo n.º 11
0
 public IntEnumerator(DoubleTest test)
 {
     _max    = test.Max;
     Current = -1;
 }
Exemplo n.º 12
0
        public override string SaveEntity()
        {
            string journalString = $"JournalID{ID},PatientID{( ( PatientData != null ) ? ( PatientData.ID.ToString () ) : ( "Null" ) )},{( int ) JournalDestination}{Environment.NewLine}";

            #region MenstrualInfo [Line 1]
            journalString += $"{MenstrualInfo.IsCalculationSafe.ToString ()},{MenstrualInfo.LastMentruationalDay.ToString ()},{( ( MenstrualInfo.MenstruationalCycle != null ) ? ( MenstrualInfo.MenstruationalCycle.Replace (",", COMMAIDENTIFIER) ) : ( string.Empty ) )}{Environment.NewLine}";
            #endregion

            journalString += $"{NaegelsRule.ToString ()},{UltrasoundTermin.ToString ()}{Environment.NewLine}";

            #region WeightInfo [Line 3]
            journalString += $"{WeightInfo.BMI.ToString (new CultureInfo ("en-US"))},{WeightInfo.HeightInCM.ToString (new CultureInfo ("en-US"))},{WeightInfo.WeightBeforePregnancyInKG.ToString (new CultureInfo ("en-US"))}{Environment.NewLine}";
            #endregion

            journalString += $"{MothersRhesusFactor.ToString ()},{ChildsRhesusFactor.ToString ()}{Environment.NewLine}";

            #region HepB [Line 5]
            journalString += $"{HepB.Date.ToString ()},{( int ) HepB.Result}{Environment.NewLine}";
            #endregion

            journalString += $"{BloodTypeDetermined.ToString ()},{AntibodyByRhesusNegative.ToString ()},{IrregularAntibody.ToString ()}{Environment.NewLine}";

            #region AntiDImmunoglobulinGiven [Line 7]
            journalString += $"{AntiDImmunoglobulinGiven.Date.ToString ()},{( ( AntiDImmunoglobulinGiven.Initials != null ) ? ( AntiDImmunoglobulinGiven.Initials.Replace (",", COMMAIDENTIFIER) ) : ( string.Empty ) )},{( ( AntiDImmunoglobulinGiven.Value != null ) ? ( AntiDImmunoglobulinGiven.Value.Replace (",", COMMAIDENTIFIER) ) : ( string.Empty ) )}{Environment.NewLine}";
            #endregion

            #region UrinCulture [Line 8]
            journalString += $"{UrineCulture.Date.ToString ()},{( ( UrineCulture.Initials != null ) ? ( UrineCulture.Initials.Replace (",", COMMAIDENTIFIER) ) : ( string.Empty ) )},{( ( UrineCulture.Value != null ) ? ( UrineCulture.Value.Replace (",", COMMAIDENTIFIER) ) : ( string.Empty ) )}{Environment.NewLine}";
            #endregion

            #region journalStamps [Line 9]
            string stampsData = string.Empty;
            for (int i = 0; i < journalStamps.Count; i++)
            {
                stampsData += $"{( ( journalStamps[ i ].BloodPressure != null ) ? ( journalStamps[ i ].BloodPressure.Replace (",", COMMAIDENTIFIER) ) : ( string.Empty ) )},{journalStamps[ i ].Date.ToString ()},{journalStamps[ i ].Edema.ToString ()},{( ( journalStamps[ i ].ExaminationLocation != null ) ? ( journalStamps[ i ].ExaminationLocation.Replace (",", COMMAIDENTIFIER) ) : ( string.Empty ) )},{journalStamps[ i ].FetusActivity.ToString ()},{( ( journalStamps[ i ].FetusGender != null ) ? ( journalStamps[ i ].FetusGender.Replace (",", COMMAIDENTIFIER) ) : ( string.Empty ) )},{( ( journalStamps[ i ].FosterRepresentation != null ) ? ( journalStamps[ i ].FosterRepresentation.Replace (",", COMMAIDENTIFIER) ) : ( string.Empty ) )},{( ( journalStamps[ i ].GestationAge != null ) ? ( journalStamps[ i ].GestationAge.Replace (",", COMMAIDENTIFIER) ) : ( string.Empty ) )},{( ( journalStamps[ i ].Initials != null ) ? ( journalStamps[ i ].Initials.Replace (",", COMMAIDENTIFIER) ) : ( string.Empty ) )},{( ( journalStamps[ i ].UrinSample != null ) ? ( journalStamps[ i ].UrinSample.Replace (",", COMMAIDENTIFIER) ) : ( string.Empty ) )},{journalStamps[ i ].UterusSizeInCM.ToString (new CultureInfo ("en-US"))},{journalStamps[ i ].Weight.ToString (new CultureInfo ("en-US"))}";

                if (i != journalStamps.Count - 1)
                {
                    stampsData += COLITEMSEPERATOR;
                }
            }
            #endregion

            #region JournalComments [Line 10]
            string commentsData = string.Empty;
            for (int i = 0; i < journalComments.Count; i++)
            {
                commentsData += $"{( ( journalComments[ i ].Comment != null ) ? ( journalComments[ i ].Comment.Replace (",", COMMAIDENTIFIER) ) : ( string.Empty ) )},{journalComments[ i ].Date.ToString ()}";

                if (i != journalComments.Count - 1)
                {
                    commentsData += COLITEMSEPERATOR;
                }
            }
            #endregion

            #region UltraSoundScans [Line 11]
            string ultraData = string.Empty;
            for (int i = 0; i < UltraSoundScans.Count; i++)
            {
                ultraData += $"{ultraSoundScans[ i ].AmnioticFluidAmount.ToString (new CultureInfo ("en-US"))},{ultraSoundScans[ i ].Date.ToString ()},{( ( ultraSoundScans[ i ].ExaminationLocation != null ) ? ( ultraSoundScans[ i ].ExaminationLocation.Replace (",", COMMAIDENTIFIER) ) : ( string.Empty ) )},{( ( ultraSoundScans[ i ].Flow != null ) ? ( ultraSoundScans[ i ].Flow.Replace (",", COMMAIDENTIFIER) ) : ( string.Empty ) )},{( ( ultraSoundScans[ i ].FosterRepresentation != null ) ? ( ultraSoundScans[ i ].FosterRepresentation.Replace (",", COMMAIDENTIFIER) ) : ( string.Empty ) )},{( ( ultraSoundScans[ i ].GestationAge != null ) ? ( ultraSoundScans[ i ].GestationAge.Replace (",", COMMAIDENTIFIER) ) : ( string.Empty ) )},{( ( ultraSoundScans[ i ].Initials != null ) ? ( ultraSoundScans[ i ].Initials.Replace (",", COMMAIDENTIFIER) ) : ( string.Empty ) )},{ultraSoundScans[ i ].USWeight.ToString (new CultureInfo ("en-US"))},{ultraSoundScans[ i ].WeightDifference.ToString (new CultureInfo ("en-US"))}";

                if (i != UltraSoundScans.Count - 1)
                {
                    ultraData += COLITEMSEPERATOR;
                }
            }
            #endregion

            journalString += $"{stampsData}{Environment.NewLine}{commentsData}{Environment.NewLine}{ultraData}{Environment.NewLine}";

            journalString += $"{NuchalFoldScan.ToString ()},{DoubleTest.ToString ()},{TripleTest.ToString ()}{Environment.NewLine}";

            #region OddsForDS [Line 13]
            journalString += $"{OddsForDS.Date.ToString ()},{( ( OddsForDS.Initials != null ) ? ( OddsForDS.Initials.Replace (",", COMMAIDENTIFIER) ) : ( string.Empty ) )},{( ( OddsForDS.Value != null ) ? ( OddsForDS.Value.Replace (",", COMMAIDENTIFIER) ) : ( string.Empty ) )}{Environment.NewLine}";
            #endregion

            #region PlacentaTest [Line 14]
            journalString += $"{PlacentaTest.Date.ToString ()},{( ( PlacentaTest.Initials != null ) ? ( PlacentaTest.Initials.Replace (",", COMMAIDENTIFIER) ) : ( string.Empty ) )},{( ( PlacentaTest.Value != null ) ? ( PlacentaTest.Value.Replace (",", COMMAIDENTIFIER) ) : ( string.Empty ) )}{Environment.NewLine}";
            #endregion

            #region AmnioticFluidTest [Line 15]
            journalString += $"{AmnioticFluidTest.Date.ToString ()},{( ( AmnioticFluidTest.Initials != null ) ? ( AmnioticFluidTest.Initials.Replace (",", COMMAIDENTIFIER) ) : ( string.Empty ) )},{( ( AmnioticFluidTest.Value != null ) ? ( AmnioticFluidTest.Value.Replace (",", COMMAIDENTIFIER) ) : ( string.Empty ) )}{Environment.NewLine}";
            #endregion

            #region OralGlukoseToleranceTest [Line 16]
            string glycData   = $"{OralGlukoseToleranceTest.Glycosuria.Date.ToString ()},{( ( OralGlukoseToleranceTest.Glycosuria.Initials != null ) ? ( OralGlukoseToleranceTest.Glycosuria.Initials.Replace (",", COMMAIDENTIFIER) ) : ( string.Empty ) )},{( ( OralGlukoseToleranceTest.Glycosuria.Value != null ) ? ( OralGlukoseToleranceTest.Glycosuria.Value.Replace (",", COMMAIDENTIFIER) ) : ( string.Empty ) )}";
            string Week18Data = $"{OralGlukoseToleranceTest.Week18_20.Date.ToString ()},{( ( OralGlukoseToleranceTest.Week18_20.Initials != null ) ? ( OralGlukoseToleranceTest.Week18_20.Initials.Replace (",", COMMAIDENTIFIER) ) : ( string.Empty ) )},{( ( OralGlukoseToleranceTest.Week18_20.Value != null ) ? ( OralGlukoseToleranceTest.Week18_20.Value.Replace (",", COMMAIDENTIFIER) ) : ( string.Empty ) )}";
            string Week28Data = $"{OralGlukoseToleranceTest.Week28_30.Date.ToString ()},{( ( OralGlukoseToleranceTest.Week28_30.Initials != null ) ? ( OralGlukoseToleranceTest.Week28_30.Initials.Replace (",", COMMAIDENTIFIER) ) : ( string.Empty ) )},{( ( OralGlukoseToleranceTest.Week28_30.Value != null ) ? ( OralGlukoseToleranceTest.Week28_30.Value.Replace (",", COMMAIDENTIFIER) ) : ( string.Empty ) )}";

            string oralData = $"{glycData}{OBJECTSEPERATOR}{Week18Data}{OBJECTSEPERATOR}{Week28Data}{Environment.NewLine}";

            journalString += oralData;
            #endregion

            journalString += $"{( ( AdditonalContext != null ) ? ( AdditonalContext.Replace (",", COMMAIDENTIFIER) ) : ( string.Empty ) )}{Environment.NewLine}";

            journalString += $"{( ( BirthplaceInfo.BirthplaceWish != null ) ? ( BirthplaceInfo.BirthplaceWish.Replace (",", COMMAIDENTIFIER) ) : ( string.Empty ) )},{BirthplaceInfo.BirthPreperationWish.ToString ()},{( ( BirthplaceInfo.ChangedBirthplace != null ) ? ( BirthplaceInfo.ChangedBirthplace.Replace (",", COMMAIDENTIFIER) ) : ( string.Empty ) )},{( int ) BirthplaceInfo.ConFormat},{( ( BirthplaceInfo.MidwifeCenterCity != null ) ? ( BirthplaceInfo.MidwifeCenterCity.Replace (",", COMMAIDENTIFIER) ) : ( string.Empty ) )},{( ( BirthplaceInfo.MidwifeCenterHouseNumber != null ) ? ( BirthplaceInfo.MidwifeCenterHouseNumber.Replace (",", COMMAIDENTIFIER) ) : ( string.Empty ) )},{( ( BirthplaceInfo.MidwifeCenterName != null ) ? ( BirthplaceInfo.MidwifeCenterName.Replace (",", COMMAIDENTIFIER) ) : ( string.Empty ) )},{( ( BirthplaceInfo.MidwifeCenterPhone != null ) ? ( BirthplaceInfo.MidwifeCenterPhone.Replace (",", COMMAIDENTIFIER) ) : ( string.Empty ) )},{( ( BirthplaceInfo.MidwifeCenterPostalCode != null ) ? ( BirthplaceInfo.MidwifeCenterPostalCode.Replace (",", COMMAIDENTIFIER) ) : ( string.Empty ) )},{( ( BirthplaceInfo.MidwifeCenterStreet != null ) ? ( BirthplaceInfo.MidwifeCenterStreet.Replace (",", COMMAIDENTIFIER) ) : ( string.Empty ) )},{( ( BirthplaceInfo.MidwifeConsultationWish != null ) ? ( BirthplaceInfo.MidwifeConsultationWish.Replace (",", COMMAIDENTIFIER) ) : ( string.Empty ) )},{( ( BirthplaceInfo.PrimaryExpectedBirthplace != null ) ? ( BirthplaceInfo.PrimaryExpectedBirthplace.Replace (",", COMMAIDENTIFIER) ) : ( string.Empty ) )}";

            return(journalString);
        }