public void CheckJsonOutput() { // Arrange var data = new CheckCredits("Userkey", "Password"); // Act var json = data.GetAsJson(); // Assert Assert.Equal("Userkey", data.UserName); Assert.Equal("Password", data.Password); Assert.NotEmpty(json); }
public void On(Event <LogEventData> evt) { // Create MessageText var message = $"{evt.Data.LocalTimestamp.LocalDateTime} ({evt.Data.Level}) {evt.Data.RenderedMessage}"; // Fill in data var data = new SendTextSMS( Username, Password, Originator, Recipients, message, FlashingSMS, URLBufferedMessageNotification, URLDeliveryNotification, URLNonDeliveryNotification, AffiliateID, Host.InstanceName); // Send SMS using (var client = new WebClient()) { try { var result = client.UploadString($"{_postUrl}SendTextSMS", data.GetAsJson()); if (!LogStatus) { return; } try { var obj = new Result(result); if (LogAvailableCredits) { var credits = new CheckCredits(Username, Password); var creditResult = new Result(client.UploadString($"{_postUrl}CheckCredits", credits.GetAsJson())); Log.Information("SMS sent with {StatusCode} {StatusInfo} ({AvailableCredits} Credits left)", obj.StatusCode, obj.StatusInfo, creditResult.Credits); } else { Log.Information("SMS sent with {StatusCode} {StatusInfo}", obj.StatusCode, obj.StatusInfo); } } catch (Exception ex) { Log.Error(ex, "Can't parse status code from result", result); } } catch (Exception ex) { Log.Error(ex, "There was a problem sending SMS"); } } }