using System; using System.Text; using System.Threading; using BWP.ABCClient.Businesses; using BWP.ABCClient.Businesses.Type; using NUnit.Framework; namespace BWP.ABCClient { [TestFixture] public class LogTest { [Test] public void CommitAndLoadTest() { var log = new AbcLog("test"); log.Clear(); log.AddNewLine("开始交易:"); log.AddNewLine("检查配置:"); log.Add("正确"); log.Commit(); Assert.AreEqual(string.Format("\r\n{0} 开始交易:\r\n{0} 检查配置:正确", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")), log.Load()); } [Test] public void ThreadTest() { new AbcLog("test").Clear(); var t = new Thread(ThreadProc); t.Start(); for (int i = 0; i < 9; i++) { var log = new AbcLog("test"); log.AddNewLine("接受农行回馈:" + i); log.Add("正确"); log.Commit(); Thread.Sleep(1); } t.Join(); Console.WriteLine(new AbcLog("test").Load()); } static void ThreadProc() { for (var i = 0; i < 10; i++) { var log = new AbcLog("test"); log.AddNewLine("开始交易:" + i); log.AddNewLine("检查配置:"); log.Add("正确"); log.Commit(); Thread.Sleep(1); } } [Test] public void B2BLogTest() { var log = new AbcLog(BusinessTypes.B2B.Name); log.Clear(); B2BReceivingPaymentTest.EnsureCertsExists(); var collections = new B2BReceivingPayment(); collections.MerchantID = "337100000000066"; collections.Date = DateTime.Now; collections.Amount = 234.5m; collections.AccountNo = "622587263489712639846"; collections.ResultNotifyURL = "http://a.b.c.d"; collections.SequenceNo = "209329384902834"; collections.RequestUrl = "http://localhost:5000/B2B/"; using (new MockWebServer("http://localhost:5000/B2B/", Encoding.UTF8, Encoding.UTF8, false)) { collections.Request(); ; } Console.WriteLine(log.Load()); } } }