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()); }
public void AuctionConstructor_when_invalid_tags_throws() { var builder = new AuctionArgs.Builder() .SetBuyNow(90.00m) .SetStartDate(DateTime.UtcNow.AddMinutes(20)) .SetEndDate(DateTime.UtcNow.AddDays(5)) .SetOwner(new UserIdentity()) .SetProduct(new Product("test name", "desccription 1111", Condition.New)) .SetCategory(new Category("test", 0)) .SetBuyNowOnly(false) .SetName("Test name"); var args = builder .SetTags(Enumerable.Range(0, Auction.MIN_TAGS - 1) .Select(i => $"tag1{i}") .ToArray()) .Build(); Assert.Throws <DomainException>(() => new Auction(args)); }