Ejemplo n.º 1
0
        public void SQLDBLoggerCanBeCreated()
        {
            IDatabase database = new StubDatabase();
            Dictionary<Type, int> messageCodesMap = new Dictionary<Type, int> {
                    {typeof(GeneralMessage), 1 },
                    {typeof(WarningMessage), 2 },
                    {typeof(ErrorMessage), 3 },
                };
            SQLDBLogger dblogger = new SQLDBLogger(database, messageCodesMap);

            Assert.IsNotNull(dblogger);
            Assert.IsInstanceOfType(dblogger, typeof(ILogger));
            Assert.AreEqual(messageCodesMap, dblogger.MessageCodesMap);
        }
Ejemplo n.º 2
0
        public void SQLDBLoggerCanLogToDatabase()
        {
            StubDatabase database = new StubDatabase();
            Dictionary<Type, int> messageCodesMap = new Dictionary<Type, int> {
                    {typeof(GeneralMessage), 1 },
                    {typeof(WarningMessage), 2 },
                    {typeof(ErrorMessage), 3 },
                };

            SQLDBLogger dblogger = new SQLDBLogger(database, messageCodesMap);

            dblogger.Log(new ErrorMessage(emsg_text));

            Assert.AreEqual(emsg_text, database.Parameters["?message"]);
            Assert.AreEqual(messageCodesMap[typeof(ErrorMessage)].ToString(), database.Parameters["?messageCode"]);
        }