< Summary - SonghayCore

Information
Class: Songhay.Models.OpenAuthorizationData
Assembly: SonghayCore
File(s): /home/rasx/sourceRoot/SonghayCore/SonghayCore/Models/OpenAuthorizationData.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 33
Coverable lines: 33
Total lines: 95
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 4
Branch coverage: 0%
Method coverage

Method coverage is only available for sponsors.

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
.ctor()100%10%
.ctor(...)100%10%
.ctor(...)0%40%
.ctor(...)100%10%
get_ConsumerKey()100%10%
get_ConsumerSecret()100%10%
get_Nonce()100%10%
get_TimeStamp()100%10%
get_Token()100%10%
get_TokenSecret()100%10%
get_SignatureMethod()100%10%
get_Version()100%10%

File(s)

/home/rasx/sourceRoot/SonghayCore/SonghayCore/Models/OpenAuthorizationData.cs

#LineLine coverage
 1namespace Songhay.Models;
 2
 3/// <summary>
 4/// Defines Authorization Information for OAuth 1.0.
 5/// </summary>
 6public class OpenAuthorizationData
 7{
 8    /// <summary>
 9    /// Initializes a new instance of the <see cref="OpenAuthorizationData"/> class.
 10    /// </summary>
 11    public OpenAuthorizationData()
 012        : this(null, null)
 013    {
 014    }
 15
 16    /// <summary>
 17    /// Initializes a new instance of the <see cref="OpenAuthorizationData"/> class.
 18    /// </summary>
 19    /// <param name="data">The data.</param>
 20    public OpenAuthorizationData(NameValueCollection data)
 021        : this(null, data)
 022    {
 023    }
 24
 25    /// <summary>
 26    /// Initializes a new instance of the <see cref="OpenAuthorizationData" /> class.
 27    /// </summary>
 28    /// <param name="nonce">The nonce.</param>
 29    /// <param name="data">The data.</param>
 030    public OpenAuthorizationData(string? nonce, NameValueCollection? data)
 031    {
 032        Nonce = string.IsNullOrWhiteSpace(nonce)
 033            ? Convert.ToBase64String(new ASCIIEncoding().GetBytes(DateTime.Now.Ticks.ToString()))
 034            : nonce;
 035        SignatureMethod = "HMAC-SHA1";
 036        var timeSpan = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
 037        TimeStamp = Convert.ToInt64(timeSpan.TotalSeconds).ToString();
 038        Version = "1.0";
 39
 040        if (data == null) return;
 041        ConsumerKey = data["TwitterConsumerKey"];
 042        ConsumerSecret = data["TwitterConsumerSecret"];
 043        Token = data["TwitterToken"];
 044        TokenSecret = data["TwitterTokenSecret"];
 045    }
 46
 47    /// <summary>
 48    /// Initializes a new instance of the <see cref="OpenAuthorizationData" /> class.
 49    /// </summary>
 50    /// <param name="nonce">The nonce.</param>
 051    public OpenAuthorizationData(string nonce) : this()
 052    {
 053        Nonce = nonce;
 054    }
 55
 56    /// <summary>
 57    /// Gets or sets the consumer key.
 58    /// </summary>
 059    public string? ConsumerKey { get; set; }
 60
 61    /// <summary>
 62    /// Gets or sets the consumer secret.
 63    /// </summary>
 064    public string? ConsumerSecret { get; set; }
 65
 66    /// <summary>
 67    /// Gets the nonce.
 68    /// </summary>
 069    public string? Nonce { get; set; }
 70
 71    /// <summary>
 72    /// Gets or sets the time stamp.
 73    /// </summary>
 074    public string? TimeStamp { get; set; }
 75
 76    /// <summary>
 77    /// Gets or sets the token.
 78    /// </summary>
 079    public string? Token { get; set; }
 80
 81    /// <summary>
 82    /// Gets or sets the token secret.
 83    /// </summary>
 084    public string? TokenSecret { get; set; }
 85
 86    /// <summary>
 87    /// Gets the signature method.
 88    /// </summary>
 089    public string? SignatureMethod { get; set; }
 90
 91    /// <summary>
 92    /// Gets or sets the version.
 93    /// </summary>
 094    public string? Version { get; set; }
 95}