Example #1
0
        public void TestErrorLogging(IConnectionManager conn)
        {
            //Arrange
            CreateLogTableTask.Create(conn, "test_log");
            ControlFlow.AddLoggingDatabaseToConfig(conn, NLog.LogLevel.Trace, "test_log");
            //Act
            LogTask.Error(conn, "Error!");
            LogTask.Warn(conn, "Warn!");
            LogTask.Info(conn, "Info!");
            LogTask.Debug(conn, "Debug!");
            LogTask.Trace(conn, "Trace!");
            LogTask.Fatal(conn, "Fatal!");
            //Assert
            Assert.Equal(1, RowCountTask.Count(conn, ControlFlow.LogTable,
                                               $"{conn.QB}message{conn.QE} = 'Error!' AND {conn.QB}level{conn.QE} = 'Error' AND {conn.QB}task_action{conn.QE} = 'LOG'"));
            Assert.Equal(1, RowCountTask.Count(conn, ControlFlow.LogTable,
                                               $"{conn.QB}message{conn.QE} = 'Warn!' AND {conn.QB}level{conn.QE} = 'Warn' AND {conn.QB}task_action{conn.QE} = 'LOG'"));
            Assert.Equal(1, RowCountTask.Count(conn, ControlFlow.LogTable,
                                               $"{conn.QB}message{conn.QE} = 'Info!' AND {conn.QB}level{conn.QE} = 'Info' AND {conn.QB}task_action{conn.QE} = 'LOG'"));
            Assert.Equal(1, RowCountTask.Count(conn, ControlFlow.LogTable,
                                               $"{conn.QB}message{conn.QE} = 'Debug!' AND {conn.QB}level{conn.QE} = 'Debug' AND {conn.QB}task_action{conn.QE} = 'LOG'"));
            Assert.Equal(1, RowCountTask.Count(conn, ControlFlow.LogTable,
                                               $"{conn.QB}message{conn.QE} = 'Trace!' AND {conn.QB}level{conn.QE} = 'Trace' AND {conn.QB}task_action{conn.QE} = 'LOG'"));
            Assert.Equal(1, RowCountTask.Count(conn, ControlFlow.LogTable,
                                               $"{conn.QB}message{conn.QE} = 'Fatal!' AND {conn.QB}level{conn.QE} = 'Fatal' AND {conn.QB}task_action{conn.QE} = 'LOG'"));

            //Cleanup
            DropTableTask.Drop(conn, ControlFlow.LogTable);
        }
        public void CompareWithHiddenReflection(int objectsToCreate, double deviation)
        {
            //Arrange

            //Act
            var timeWithReflection = BigDataHelper.LogExecutionTime("Creation with Reflection",
                                                                    () =>
            {
                for (int i = 0; i < objectsToCreate; i++)
                {
                    MergeableTestRow row = new MergeableTestRow()
                    {
                        ColKey1   = i,
                        ColKey2   = "Test",
                        ColValue1 = "X1" + i,
                        ColValue2 = "T1" + i
                    };
                    string id    = row.UniqueId;
                    bool isequal = row.Equals(row);
                    LogTask.Trace("Id:" + id + " Equals:" + isequal.ToString());
                }
                ;
            });

            output.WriteLine("Elapsed " + timeWithReflection.TotalSeconds + " seconds for creation with reflection.");

            var timeWithoutReflection = BigDataHelper.LogExecutionTime("Creation without Reflection",
                                                                       () =>
            {
                for (int i = 0; i < objectsToCreate; i++)
                {
                    MergeableTestHidingRefĺection row = new MergeableTestHidingRefĺection()
                    {
                        ColKey1   = i,
                        ColKey2   = "Test",
                        ColValue1 = "X2" + i,
                        ColValue2 = "T2" + i
                    };
                    string id    = row.UniqueId;
                    bool isequal = row.Equals(row);
                    LogTask.Trace("Id:" + id + " Equals:" + isequal.ToString());
                }
            });

            output.WriteLine("Elapsed " + timeWithoutReflection.TotalSeconds + " seconds for creation without reflection.");

            //Assert
            Assert.True(timeWithoutReflection < timeWithReflection);
            Assert.True(timeWithoutReflection.TotalMilliseconds * (deviation + 1) > timeWithReflection.TotalMilliseconds);
        }