Ejemplo n.º 1
0
        public void GetElementByPkAndRkTest()
        {
            #region arrange
            string[] log_args = new string[4] {
                "UseDevelopmentStorage=true",
                "TestTable",
                "LogName",
                "internal_id"
            };
            string partitionKey = "MyTestTable";
            string rowKey       = "2518152595287108267";
            #endregion

            #region act
            TableStorageLog   TSlog          = new TableStorageLog(log_args);
            TableStorageEntry entry          = TSlog.Get(partitionKey, rowKey);
            LogEntry          actualLogEntry = entry.ToEntity <LogEntry>("LogName", "internal_id");
            #endregion

            #region assert
            Assert.IsNotNull(actualLogEntry);
            #endregion
        }
Ejemplo n.º 2
0
        public void InsertGetDeleteTableStorageWithPkAndRkTest()
        {
            #region insert
            #region arrange
            bool     expected = true;
            string[] log_args = new string[4] {
                "UseDevelopmentStorage=true",
                "TestTable",
                "LogName",
                "internal_id"
            };
            Dictionary <string, string> _internal_parameters = new Dictionary <string, string>();
            _internal_parameters.Add("param1", "value_param1");
            _internal_parameters.Add("param2", "value_param2");

            string partitionKey = "MyTestTable";
            string rowKey       = Log.Utilities.getInvertedTimeKey(DateTime.Now);
            #endregion

            #region act
            ILog     log       = new TableStorageLog(log_args);
            LogEntry _logEntry = new LogEntry
            {
                LogName             = partitionKey,
                internal_id         = rowKey,
                requestTime         = DateTime.Now.AddSeconds(-10),
                responseTime        = DateTime.Now,
                request             = "myrequest",
                response            = "myresponse",
                internal_parameters = JsonConvert.SerializeObject(_internal_parameters)
            };
            bool actual = log.Track(_logEntry);
            #endregion

            #region assert
            Assert.AreEqual(expected, actual);
            #endregion

            #endregion

            #region get

            #region act
            TableStorageLog   TSlog          = (TableStorageLog)log;
            TableStorageEntry entry          = TSlog.Get(partitionKey, rowKey);
            LogEntry          actualLogEntry = entry.ToEntity <LogEntry>("LogName", "internal_id");
            #endregion

            #region assert
            Assert.AreEqual(_logEntry.LogName, actualLogEntry.LogName);
            Assert.AreEqual(_logEntry.internal_id, actualLogEntry.internal_id);
            Assert.AreEqual(_logEntry.request, actualLogEntry.request);
            Assert.AreEqual(_logEntry.response, actualLogEntry.response);
            Assert.AreEqual(_logEntry.requestTime, actualLogEntry.requestTime);
            Assert.AreEqual(_logEntry.responseTime, actualLogEntry.responseTime);
            Assert.AreEqual(_logEntry.internal_parameters, actualLogEntry.internal_parameters);
            #endregion

            #endregion

            #region delete

            #endregion
        }