public void SmallerThanOperatorWithEqualObjects() { var first = new UploadToken(); var second = first.Clone(); Assert.IsFalse(first < second); }
public void SmallerThanOperatorWithFirstObjectSmaller() { var first = new UploadToken(1); var second = new UploadToken(2); Assert.IsTrue(first < second); }
public void SmallerThanOperatorWithSecondObjectNull() { UploadToken first = new UploadToken(); UploadToken second = null; Assert.IsFalse(first < second); }
public void SmallerThanOperatorWithBothObjectsNull() { UploadToken first = null; UploadToken second = null; Assert.IsFalse(first < second); }
public void SmallerThanOperatorWithFirstObjectNull() { UploadToken first = null; UploadToken second = new UploadToken(); Assert.IsTrue(first < second); }
public void LargerThanOperatorWithFirstObjectSmaller() { var first = new UploadToken(1); var second = new UploadToken(2); Assert.IsFalse(first > second); }
public void LargerThanOperatorWithSecondObjectNull() { UploadToken first = new UploadToken(); UploadToken second = null; Assert.IsTrue(first > second); }
public void Clone() { UploadToken first = new UploadToken(); UploadToken second = first.Clone(); Assert.AreEqual(first, second); }
public void CompareToWithNullObject() { UploadToken first = new UploadToken(); object second = null; Assert.AreEqual(1, first.CompareTo(second)); }
public void CompareToOperatorWithEqualObjects() { var first = new UploadToken(); object second = first.Clone(); Assert.AreEqual(0, first.CompareTo(second)); }
public void LargerThanOperatorWithFirstObjectNull() { UploadToken first = null; UploadToken second = new UploadToken(); Assert.IsFalse(first > second); }
public void DeregisterWithUnknownToken() { var token = new UploadToken(); var uploads = new WaitingUploads(); Assert.Throws <FileRegistrationNotFoundException>(() => uploads.Deregister(token)); }
public void ReregisterWithEmptyPath() { var token = new UploadToken(); var uploads = new WaitingUploads(); Assert.Throws <ArgumentException>(() => uploads.Reregister(token, string.Empty)); }
public void CompareToWithUnequalObjectTypes() { UploadToken first = new UploadToken(); object second = new object(); Assert.Throws <ArgumentException>(() => first.CompareTo(second)); }
public void CompareToWithSmallerFirstObject() { var first = new UploadToken(1); var second = new UploadToken(2); Assert.IsTrue(first.CompareTo(second) < 0); }
public void ReregisterWithExistingToken() { var token = new UploadToken(); var file = @"c:\temp\myfile.txt"; var uploads = new WaitingUploads(); uploads.Reregister(token, file); Assert.Throws <UploadNotDeregisteredException>(() => uploads.Reregister(token, @"c:\temp\otherfile.txt")); }
public void Reregister() { var token = new UploadToken(); var file = @"c:\temp\myfile.txt"; var uploads = new WaitingUploads(); uploads.Reregister(token, file); Assert.IsTrue(uploads.HasRegistration(token)); Assert.AreEqual(file, uploads.Deregister(token)); }
/// <summary> /// Registers a new file path for uploading /// and returns a new token for use with the path. /// </summary> /// <param name="path">The full path to the file that should be uploaded.</param> /// <returns> /// The token that can be used to retrieve the file path. /// </returns> public UploadToken Register(string path) { { Lokad.Enforce.Argument(() => path); Lokad.Enforce.Argument(() => path, Lokad.Rules.StringIs.NotEmpty); } var token = new UploadToken(); m_Uploads.Add(token, path); return(token); }
/// <summary> /// Deregisters the file from upload and returns the path. /// </summary> /// <param name="token">The token.</param> /// <returns>The file path that was registered with the given token.</returns> public string Deregister(UploadToken token) { if (!m_Uploads.ContainsKey(token)) { throw new FileRegistrationNotFoundException(token); } var result = m_Uploads[token]; m_Uploads.Remove(token); return(result); }
/// <summary> /// Reregisters a file path for uploading with a given path. /// </summary> /// <param name="token">The token.</param> /// <param name="path">The full path to the file that should be uploaded.</param> public void Reregister(UploadToken token, string path) { { Lokad.Enforce.Argument(() => path); Lokad.Enforce.Argument(() => path, Lokad.Rules.StringIs.NotEmpty); } if (m_Uploads.ContainsKey(token)) { throw new UploadNotDeregisteredException(token); } m_Uploads.Add(token, path); }
/// <summary> /// Initializes a new instance of the <see cref="UploadNotDeregisteredException"/> class. /// </summary> /// <param name="token">The token.</param> internal UploadNotDeregisteredException(UploadToken token) : this(string.Format(CultureInfo.InvariantCulture, Resources.Exceptions_Messages_UploadNotDeregistered_WithToken, token)) { }
/// <summary> /// Determines if a path is stored for the given token. /// </summary> /// <param name="token">The token.</param> /// <returns> /// <see langword="true" /> if a path is stored for the given token; /// otherwise, <see langword="false" />. /// </returns> public bool HasRegistration(UploadToken token) { return(m_Uploads.ContainsKey(token)); }
/// <summary> /// Initializes a new instance of the <see cref="FileRegistrationNotFoundException"/> class. /// </summary> /// <param name="token">The token.</param> internal FileRegistrationNotFoundException(UploadToken token) : this(string.Format(CultureInfo.InvariantCulture, Resources.Exceptions_Messages_FileRegistrationNotFound_WithToken, token)) { }