public void Test_Process_BadDeviceToken() { using (TransactionScope scope = new TransactionScope()) { DataSet.TitleRow title = PrepareBasic(); RequestProcessor rp = new RequestProcessor(); try { rp.Process("malformeddevicetokenmalformeddevicetokenmalformeddevicetokenmalf"); Expect(false); } catch (BadDeviceTokenException) { // OK } APNsTableAdapter ata = new APNsTableAdapter(); DataSet.APNsDataTable adt = ata.GetDataByTitleId(title.Id); Expect(adt.Count, Is.EqualTo(0)); SubscriberTableAdapter sta = new SubscriberTableAdapter(); DataSet.SubscriberDataTable sdt = sta.GetDataByTitleId(title.Id); Expect(sdt.Count, Is.EqualTo(0)); } }
public void Test_Properties() { using (TransactionScope scope = new TransactionScope()) { TitleTableAdapter tta = new TitleTableAdapter(); tta.Insert("test title", "test push message", basePath + @"\copyDirectory_dist", basePath + @"\copyDirectory_orig"); DataSet.TitleRow title = tta.GetDataByName("test title")[0]; SubscriberTableAdapter sta = new SubscriberTableAdapter(); sta.Insert(title.Id, "test authkey", "web", Constant.Ago); sta.Insert(title.Id, "test authkey 2", "web", new DateTime(2011, 10, 13)); DataSet.SubscriberDataTable sdt = sta.GetDataByTitleId(title.Id); DataSet.SubscriberRow s1, s2; if (sdt[0].AuthenticationKey == "test authkey") { s1 = sdt[0]; s2 = sdt[1]; } else { s2 = sdt[0]; s1 = sdt[1]; } TokenTableAdapter kta = new TokenTableAdapter(); kta.Insert(s1.Id, new DateTime(2011, 10, 12, 0, 0, 0), "deadbeef"); kta.Insert(s2.Id, new DateTime(2011, 10, 12, 4, 59, 50), "deadbeef2"); DataSet.TokenRow k1, k2; k1 = kta.GetDataByBody("deadbeef")[0]; k2 = kta.GetDataByBody("deadbeef2")[0]; Expect(SiteConstant.IsConfigurationOK, Is.EqualTo(true)); DateTime now = new DateTime(2011, 10, 12, 5, 0, 0); TokenPublisher p1 = new TokenPublisher(s1, now); DataSet.TokenRow pk1 = p1.Publish(); Expect(pk1.Id, Is.Not.EqualTo(k1.Id)); TokenPublisher p2 = new TokenPublisher(s2, now); DataSet.TokenRow pk2 = p2.Publish(); Expect(pk2.Id, Is.EqualTo(k2.Id)); kta.Insert(s2.Id, new DateTime(2011, 10, 12, 4, 59, 10), "deadbeef3"); kta.Insert(s2.Id, new DateTime(2011, 10, 12, 4, 59, 20), "deadbeef4"); TokenPublisher p2_2 = new TokenPublisher(s2, now); try { p2_2.Publish(); Expect(false); } catch (DoubtfulAuthBehaviorException) { // OK } Expect(kta.GetDataBySubscriberId(s2.Id).Count, Is.EqualTo(3)); } }
protected void Page_Load(object sender, EventArgs e) { TitleTableAdapter tta = new TitleTableAdapter(); DataSet.TitleRow title = tta.GetDataByName("debug title")[0]; SubscriberTableAdapter sta = new SubscriberTableAdapter(); DataSet.SubscriberDataTable sdt = sta.GetDataByTitleId(title.Id); if (sdt.Count == 0) { sdt.AddSubscriberRow(title, "debug auth key", AuthScheme.Web.ToString(), Constant.Ago); sta.Update(sdt); } subscriber = sdt[0]; }
public void Test_ApnsFeedback() { Settings.TestSettings(null, typeof(FeedbackServiceStub)); using (TransactionScope scope = new TransactionScope()) { TitleTableAdapter tta = new TitleTableAdapter(); tta.Insert("test title", "test push message", "test site root path", "test standby path"); DataSet.TitleRow title = tta.GetDataByName("test title")[0]; SubscriberTableAdapter sta = new SubscriberTableAdapter(); sta.Insert(title.Id, "test authkey", "web", Constant.Ago); DataSet.SubscriberRow subscriber = sta.GetDataByTitleId(title.Id)[0]; APNsTableAdapter ata = new APNsTableAdapter(); ata.Insert(subscriber.Id, "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef", false, 0, false); ApnsFeedback fb = new ApnsFeedback(title); fb.Run(); DataSet.APNsDataTable adt = ata.GetDataByTitleId(title.Id); Expect(adt[0].Failed, Is.EqualTo(true)); } }
public void Test_Process_NewSubscriber() { using (TransactionScope scope = new TransactionScope()) { DataSet.TitleRow title = PrepareBasic(); RequestProcessor rp = new RequestProcessor(); rp.Process("deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef"); APNsTableAdapter ata = new APNsTableAdapter(); DataSet.APNsDataTable adt = ata.GetDataByTitleId(title.Id); Expect(adt.Count, Is.EqualTo(1)); Expect(adt[0].DeviceToken, Is.EqualTo("deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef")); SubscriberTableAdapter sta = new SubscriberTableAdapter(); DataSet.SubscriberDataTable sdt = sta.GetDataByTitleId(title.Id); Expect(sdt.Count, Is.EqualTo(1)); DataSet.SubscriberRow subscriber = sdt[0]; Expect(subscriber.AuthScheme, Is.EqualTo(AuthScheme.iOS_APNs.ToString())); TokenTableAdapter tta = new TokenTableAdapter(); DataSet.TokenDataTable tdt = tta.GetDataBySubscriberId(subscriber.Id); Expect(tdt.Count, Is.EqualTo(1)); } }