public User(int userId, string loginName, string realName, Uri avatarUri) { this.UserId = EnsureArg.IsNotDefault(userId, nameof(userId)); this.LoginName = EnsureArg.IsNotNullOrWhiteSpace(loginName, nameof(loginName)); this.RealName = EnsureArg.IsNotNull(realName, nameof(realName)); this.AvatarUri = EnsureArg.IsNotNull(avatarUri, nameof(avatarUri)); }
public CartItem(Guid productId, int quantity) { EnsureArg.IsNotDefault(productId, nameof(productId)); this.ProductId = productId; this.Quantity = quantity; }
public void IsNotDefault_WhenIsNotDefault_It_should_not_throw() { const int value = 42; ShouldNotThrow( () => Ensure.That(value, ParamName).IsNotDefault(), () => EnsureArg.IsNotDefault(value, ParamName)); }
public Cart(Guid cartId, Guid customerId) : this() { EnsureArg.IsNotDefault(cartId, nameof(cartId)); EnsureArg.IsNotDefault(customerId, nameof(customerId)); this.RaiseEvent(new CartCreatedEvent(cartId, customerId)); }
public Post(Guid id, Guid threadId, DateTime created, string name, string comment, bool isSage, string ipAddress) : base(id) { ThreadId = EnsureArg.IsNotEmpty(threadId, nameof(threadId)); Created = EnsureArg.IsNotDefault(created, nameof(created)); Name = EnsureArg.IsNotNullOrWhiteSpace(name, nameof(name)); Comment = EnsureArg.IsNotNullOrWhiteSpace(comment, nameof(comment)); IsSage = isSage; IpAddress = EnsureArg.IsNotNull(ipAddress, nameof(ipAddress)); }
public void IsNotDefault_WhenIsNotDefault_ShouldNotThrow() { var value = 42; ShouldNotThrow( () => Ensure.Any.IsNotDefault(value, ParamName), () => EnsureArg.IsNotDefault(value, ParamName), () => Ensure.That(value, ParamName).IsNotDefault()); }
public Attempt(Guid id, int userId, Guid holeId, string code, int score, DateTime timeStamp) { this.Id = EnsureArg.IsNotEmpty(id, nameof(id)); this.UserId = EnsureArg.IsNotDefault(userId, nameof(userId)); this.HoleId = EnsureArg.IsNotEmpty(holeId, nameof(holeId)); this.Code = EnsureArg.IsNotNull(code, nameof(code)); this.Score = score; this.TimeStamp = EnsureArg.IsNotDefault(timeStamp, nameof(timeStamp)); }
public PostOverView(Guid id, DateTime created, string name, string ipHash, string comment, Option <File> file) { Id = EnsureArg.IsNotEmpty(id, nameof(id)); Created = EnsureArg.IsNotDefault(created, nameof(created)); Name = EnsureArg.IsNotNullOrWhiteSpace(name, nameof(name)); IpHash = EnsureArg.IsNotNull(ipHash, nameof(ipHash)); Comment = EnsureArg.IsNotNullOrWhiteSpace(comment, nameof(comment)); File = file; }
public AttemptDto(int rank, Guid id, string loginName, string avatar, int score, DateTime timeStamp) { this.Rank = rank; this.Id = EnsureArg.IsNotEmpty(id, nameof(id)); this.LoginName = EnsureArg.IsNotEmpty(loginName, nameof(loginName)); this.Score = score; this.Avatar = EnsureArg.IsNotEmpty(avatar, nameof(avatar)); this.TimeStamp = EnsureArg.IsNotDefault(timeStamp, nameof(timeStamp)); }
public void IsNotDefault_WhenDefault_ThrowsArgumentException() { const int value = default(int); ShouldThrow <ArgumentException>( ExceptionMessages.ValueTypes_IsNotDefault_Failed, () => Ensure.That(value, ParamName).IsNotDefault(), () => EnsureArg.IsNotDefault(value, ParamName)); }
public void AddProduct(Guid productId, int quantity) { EnsureArg.IsNotDefault(productId, nameof(productId)); if (this.ContainsProduct(productId)) { throw new CartException($"product {productId} already added"); } this.CheckQuantity(productId, quantity); this.RaiseEvent(new ProductAddedEvent(productId, quantity)); }
protected Entity(TKey id, DateTime creationDate) { EnsureArg.IsNotDefault(id, nameof(id), o => o.WithException(new RequiredArgumentException(nameof(id)))); Id = id; EnsureArg.IsTrue(creationDate.Kind == DateTimeKind.Utc, nameof(creationDate), o => o.WithException(new ArgumentException(nameof(creationDate), "Date must be of type UTC"))); EnsureArg.IsLte(creationDate, DateTime.UtcNow, nameof(creationDate), o => o.WithException(new ArgumentException(nameof(creationDate), "Date must not be in the future"))); CreationDate = creationDate; }
public void IsNotDefault_WhenIsNotDefault_It_should_not_throw() { var value = 42; var returned = Ensure.That(value, ParamName).IsNotDefault(); AssertReturnedAsExpected(returned, value); Action a = () => EnsureArg.IsNotDefault(value, ParamName); a.ShouldNotThrow(); }
public ExportJobResult(DateTimeOffset transactionTime, Uri requestUri, bool requiresAccessToken, IList <ExportFileInfo> output, IList <ExportFileInfo> errors) { EnsureArg.IsNotDefault <DateTimeOffset>(transactionTime, nameof(transactionTime)); EnsureArg.IsNotNull(requestUri, nameof(requestUri)); EnsureArg.IsNotNull(output, nameof(output)); EnsureArg.IsNotNull(errors, nameof(errors)); TransactionTime = transactionTime; RequestUri = requestUri; RequiresAccessToken = requiresAccessToken; Output = output; Error = errors; }
private void CheckQuantity(Guid productId, int quantity) { EnsureArg.IsNotDefault(@productId, nameof(@productId)); if (quantity <= 0) { throw new ArgumentException("quantity must be greater than zero", nameof(quantity)); } if (quantity > ProductQuantityThreshold) { throw new CartException($"quantity for product {productId} must be less than or equal to {ProductQuantityThreshold}"); } }
public ExportJobResult(DateTimeOffset transactionTime, Uri requestUri, bool requiresAccessToken, IList <ExportOutputResponse> output, IList <ExportOutputResponse> errors, IList <Core.Models.OperationOutcomeIssue> issues) { EnsureArg.IsNotDefault <DateTimeOffset>(transactionTime, nameof(transactionTime)); EnsureArg.IsNotNull(requestUri, nameof(requestUri)); EnsureArg.IsNotNull(output, nameof(output)); EnsureArg.IsNotNull(errors, nameof(errors)); TransactionTime = transactionTime; RequestUri = requestUri; RequiresAccessToken = requiresAccessToken; Output = output; Error = errors; Issues = issues; }
public BannedIp(Guid id, string ipHash, string reason, DateTime expiry) : base(id) { IpHash = EnsureArg.IsNotNull(ipHash, nameof(ipHash)); Reason = EnsureArg.IsNotNull(reason, nameof(reason)); Expiry = EnsureArg.IsNotDefault(expiry, nameof(expiry)); }
private CartItem GetCartItemByProduct(Guid productId) { EnsureArg.IsNotDefault(@productId, nameof(@productId)); return(this.Items.Single(x => x.ProductId == productId)); }
private bool ContainsProduct(Guid productId) { EnsureArg.IsNotDefault(@productId, nameof(@productId)); return(this.Items.Any(x => x.ProductId == productId)); }
/// <summary> /// Set the asset Guid. /// </summary> /// <param name="guid">Asset Global Unique Identifier. Required parameter.</param> /// <exception cref="RequiredArgumentException">Thrown if required arguments are null or empty.</exception> private void SetGuid(Guid guid) { EnsureArg.IsNotDefault(guid, nameof(guid), o => o.WithException(new RequiredArgumentException(nameof(guid)))); Guid = guid; }
public HoleInstance(Guid holeId, DateTime start, DateTime?end) { this.HoleId = EnsureArg.IsNotEmpty(holeId, nameof(holeId)); this.Start = EnsureArg.IsNotDefault(start, nameof(start)); this.End = end; }
public Task DeleteCategoryByIdAsync(Guid categoriId, CancellationToken cancellationToken = default) { EnsureArg.IsNotDefault(categoriId, nameof(categoriId)); return(categoriesClient.DeleteCategoryByIdAsync(categoriId, GetHeaders(), cancellationToken)); }