private AuctionArgs GetAuctionArgs(CreateAuctionCommand request, UserIdentity owner) { var category = _deps.categoryBuilder.FromCategoryNamesList(request.Category); var builder = new AuctionArgs.Builder() .SetStartDate(request.StartDate) .SetEndDate(request.EndDate) .SetCategory(category) .SetProduct(request.Product) .SetTags(request.Tags) .SetName(request.Name) .SetBuyNowOnly(request.BuyNowOnly.Value) .SetOwner(owner); if (request.BuyNowPrice != null) { builder.SetBuyNow(request.BuyNowPrice.Value); } return builder.Build(); }
public void AuctionArgsBuilder_when_invalid_params_throws() { var builder = new AuctionArgs.Builder(); Assert.Throws <DomainException>(() => builder.Build()); builder.SetCategory(new Category("test", 0)); Assert.Throws <DomainException>(() => builder.Build()); builder.SetOwner(new UserIdentity()); Assert.Throws <DomainException>(() => builder.Build()); builder.SetProduct(new Product("test name", "desccription 1111", Condition.New)); Assert.Throws <DomainException>(() => builder.Build()); builder.SetStartDate(DateTime.UtcNow.AddMinutes(20)); Assert.Throws <DomainException>(() => builder.Build()); builder.SetEndDate(DateTime.UtcNow.AddDays(5)); Assert.Throws <DomainException>(() => builder.Build()); builder.SetTags(new [] { "tag1", "tag2" }); Assert.Throws <DomainException>(() => builder.Build()); builder.SetName("Example name"); Assert.DoesNotThrow(() => builder.Build()); builder.SetBuyNow(20.0m); Assert.DoesNotThrow(() => builder.Build()); builder.SetBuyNowOnly(false); Assert.DoesNotThrow(() => builder.Build()); builder.SetBuyNow(20.0m); Assert.DoesNotThrow(() => builder.Build()); }