Exemplo n.º 1
0
        public void WriteTest()
        {
            string fileName = string.Empty; // TODO: Initialize to an appropriate value
            fileName = "temp.appsettings";
            ConfigTempFile target = new ConfigTempFile(fileName); // TODO: Initialize to an appropriate value
            string key = string.Empty; // TODO: Initialize to an appropriate value
            object oldVal = null; // TODO: Initialize to an appropriate value
            object newVal = null; // TODO: Initialize to an appropriate value
            Exception ex = null;
            try
            {
                target.Write(key, oldVal, newVal);
            }
            catch (Exception e)
            {
                ex = e;
            }
            Assert.IsNotNull(ex, "出现异常!");

            ex = null;
            key = "lala";
            oldVal = "gaga";
            newVal = "haha";
            try
            {
                target.Write(key, oldVal, newVal);
            }
            catch (Exception e)
            {
                ex = e;
            }
            Assert.IsNull(ex);
        }
Exemplo n.º 2
0
 public void GetTest()
 {
     string fileName = string.Empty; // TODO: Initialize to an appropriate value
     fileName = "temp.appsettings";
     ConfigTempFile target = new ConfigTempFile(fileName); // TODO: Initialize to an appropriate value
     string key = string.Empty; // TODO: Initialize to an appropriate value
     object expected = null; // TODO: Initialize to an appropriate value
     object actual;
     actual = target.Get(key);
     Assert.AreEqual(expected, actual);
     //key不存在
     key = "abc";
     actual = target.Get(key);
     Assert.AreEqual(expected, actual);
     //key存在本地的临时文件中
     key = "test";
     actual = target.Get(key);
     Assert.AreNotEqual(expected, actual);
 }