MakeDefaultTableStorage() публичный статический Метод

public static MakeDefaultTableStorage ( ) : TableStorage
Результат TableStorage
Пример #1
0
 public Logger()
 {
     this.ts       = TableStorage.MakeDefaultTableStorage();
     this.settings = GenUtils.GetSettingsFromAzureTable();
     this.loglevel = Convert.ToInt32(settings["loglevel"]);
     this.Start();
 }
Пример #2
0
 public Logger(int milliseconds, int max_messages)
 {
     this.ts = TableStorage.MakeDefaultTableStorage();
     this.wait_milliseconds = milliseconds;
     this.Start();
     //this.max_messages = max_messages;
 }
Пример #3
0
        static public string RunTests(string dll_name)
        {
            var tests_failed = 0;

            var results = new StringBuilder();

            try
            {
                LogMsg("info", "GenUtils.RunTests", "starting");
                var ts           = TableStorage.MakeDefaultTableStorage();
                var a            = System.Reflection.Assembly.Load(dll_name);
                var types        = a.GetExportedTypes().ToList();
                var test_classes = types.FindAll(type => type.Name.EndsWith("Test")).ToList();
                test_classes.Sort((x, y) => x.Name.CompareTo(y.Name));

                foreach (Type test_class in test_classes)                  // e.g. DeliciousTest
                {
                    object o = Activator.CreateInstance(test_class);

                    var members = test_class.GetMembers().ToList();
                    members.Sort((x, y) => x.Name.CompareTo(y.Name));

                    foreach (var member in members)
                    {
                        var attrs   = member.GetCustomAttributes(false).ToList();
                        var is_test = attrs.Exists(attr => attr.GetType() == typeof(NUnit.Framework.TestAttribute));
                        if (is_test == false)
                        {
                            continue;
                        }

                        var entity        = new Dictionary <string, object>();
                        var partition_key = test_class.FullName;
                        var row_key       = member.Name;
                        entity["PartitionKey"] = partition_key;
                        entity["RowKey"]       = row_key;

                        try
                        {
                            test_class.InvokeMember(member.Name, invokeAttr: BindingFlags.InvokeMethod, binder: null, target: o, args: null);
                            entity["outcome"] = "OK";
                            entity["reason"]  = "";
                        }
                        catch (Exception e)
                        {
                            var msg = e.Message + e.StackTrace;
                            entity["outcome"] = "Fail";
                            entity["reason"]  = e.InnerException.Message + e.InnerException.StackTrace;
                            tests_failed     += 1;
                            results.AppendLine(row_key);
                            results.AppendLine((string)entity["reason"]);
                            results.AppendLine();
                        }

                        var tablename = Configurator.test_results_tablename;
                        if (ts.ExistsEntity(tablename, partition_key, row_key))
                        {
                            ts.MergeEntity(tablename, partition_key, row_key, entity);
                        }
                        else
                        {
                            ts.InsertEntity(tablename, entity);
                        }
                    }
                }
                LogMsg("info", "GenUtils.RunTests", "done");
            }
            catch (Exception e)
            {
                PriorityLogMsg("exception", "RunTests", e.Message + e.StackTrace);
                tests_failed = 999;
            }
            return(tests_failed > 0 ? results.ToString() : "");
        }