2 using System
.Threading
.Tasks
;
3 using Microsoft
.VisualStudio
.TestTools
.UnitTesting
;
5 using SMSApi
.Api
.Response
;
10 public class SmsTest
: TestBase
12 private SMSFactory _factory
;
15 public void DeletingSentMessage_ExceptionThrown()
18 _factory
.ActionSend().SetText("test message").SetTo(_validTestNumber
).Execute();
20 string[] ids
= new string[sendResponse
.Count
];
22 for (int i
= 0; i
< sendResponse
.List
.Count
; i
++)
24 ids
[i
] = sendResponse
.List
[i
].ID
;
27 Assert
.ThrowsException
<ActionException
>(() => _factory
.ActionDelete().Id(ids
[0]).Execute());
31 public void ScheduledSend_Get_Delete()
34 _factory
.ActionSend().
35 SetText("test message").
36 SetTo(_validTestNumber
).
37 SetDateSent(DateTime
.Now
.AddHours(2)).
40 Assert
.AreEqual(1, sendResponse
.Count
);
41 Assert
.IsTrue(sendResponse
.List
[0].Points
> 0, "Points must be greather then 0");
42 Assert
.IsNotNull(sendResponse
.Message
);
43 Assert
.IsNotNull(sendResponse
.Parts
);
45 string[] ids
= new string[sendResponse
.Count
];
47 for (int i
= 0, l
= 0; i
< sendResponse
.List
.Count
; i
++)
49 if (!sendResponse
.List
[i
].isError())
51 //Nie wystąpił błąd podczas wysyłki (numer|treść|parametry... prawidłowe)
52 if (!sendResponse
.List
[i
].isFinal())
54 //Status nie jest koncowy, może ulec zmianie
55 ids
[l
] = sendResponse
.List
[i
].ID
;
62 _factory
.ActionGet().Ids(ids
).Execute();
64 Assert
.AreEqual(sendResponse
.Count
, getResponse
.Count
);
65 Assert
.AreEqual(_validTestNumber
, getResponse
.List
[0].Number
);
66 Assert
.AreEqual(sendResponse
.List
[0].ID
, getResponse
.List
[0].ID
);
67 Assert
.AreEqual(sendResponse
.List
[0].IDx
, getResponse
.List
[0].IDx
);
68 Assert
.AreEqual(sendResponse
.List
[0].Points
, getResponse
.List
[0].Points
);
69 Assert
.AreEqual(sendResponse
.List
[0].Status
, getResponse
.List
[0].Status
);
71 Countable deletedResponse
=
72 _factory
.ActionDelete().Id(ids
[0]).Execute();
74 Assert
.AreEqual(sendResponse
.Count
, deletedResponse
.Count
);
78 public void SendMessageWithParams()
81 _factory
.ActionSend().
82 SetText("test [%1%] message [%2%]").
83 SetTo(_validTestNumber
).
89 Assert
.AreEqual(1, sendResponse
.Count
);
90 Assert
.IsTrue(sendResponse
.List
[0].Points
> 0, "Points must be greather then 0");
91 Assert
.IsNotNull(sendResponse
.List
[0].ID
);
95 public override void SetUp()
98 _factory
= new SMSFactory(_client
, _proxyAddress
);