コード例 #1
0
        public void Create_provider_name_with_too_long_string_value_should_return_an_error()
        {
            Result <ProviderName> providerNameResult = ProviderName.Create("GeneDrinks-GeneDrinks-GeneDrinks-GeneDrinks-GeneDrinks-GeneDrinks-GeneDrinks-GeneDrinks-GeneDrinks-GeneDrinks-GeneDrinks-GeneDrinks-GeneDrinks-GeneDrinks-GeneDrinks-GeneDrinks-GeneDrinks-GeneDrinks-GeneDrinks-GeneDrinks-GeneDrinks-GeneDrinks-GeneDrinks-GeneDrinks-GeneDrinks-GeneDrinks-GeneDrinks-GeneDrinks-GeneDrinks-GeneDrinks-GeneDrinks-GeneDrinks-GeneDrinks-GeneDrinks-GeneDrinks");

            providerNameResult.IsFailure.ShouldBeTrue();

            providerNameResult.Error.ShouldNotBeEmpty();
        }
コード例 #2
0
        public void Create_provider_name_without_error()
        {
            Result <ProviderName> providerNameResult = ProviderName.Create("GeneDrinks");

            providerNameResult.IsFailure.ShouldBeFalse();

            ProviderName providerName = providerNameResult.Value;

            providerName.Value.ShouldBeEqualTo("GeneDrinks");
        }
コード例 #3
0
        public void Create_beer_provider_with_null_beer_provider_quantity_should_raise_an_exception()
        {
            var brewery = new Brewery(BreweryName.Create("Abbaye de Leffe").Value);

            var beer = new Beer(BeerName.Create("Leffe Blonde").Value,
                                BeerPrice.Create(2.55m).Value,
                                BeerAlcoholDegree.Create(5.5m).Value,
                                brewery);

            var provider     = new Provider(ProviderName.Create("GeneDrinks").Value);
            var beerProvider = new BeerProvider(null, beer, provider);
        }
コード例 #4
0
        public void Create_beer_provider_without_error()
        {
            var brewery = new Brewery(BreweryName.Create("Abbaye de Leffe").Value);

            var beer = new Beer(BeerName.Create("Leffe Blonde").Value,
                                BeerPrice.Create(2.55m).Value,
                                BeerAlcoholDegree.Create(5.5m).Value,
                                brewery);

            var provider = new Provider(ProviderName.Create("GeneDrinks").Value);

            BeerProvider beerProvider = new BeerProvider(BeerProviderQuantity.Create(10).Value, beer, provider);

            beerProvider.ShouldNotBeNull();
        }
コード例 #5
0
        public void Add_beer_without_error()
        {
            var provider = new Provider(ProviderName.Create("GeneDrinks").Value);

            var brewery = new Brewery(BreweryName.Create("Abbaye de Leffe").Value);

            var beer = new Beer(BeerName.Create("Leffe Blonde").Value,
                                BeerPrice.Create(2.55m).Value,
                                BeerAlcoholDegree.Create(5.5m).Value,
                                brewery);

            Result <Provider> providerResult = provider.ProvideBeer(beer, BeerProviderQuantity.Create(10).Value);

            providerResult.IsFailure.ShouldBeFalse();
        }
コード例 #6
0
 protected override void OnModelCreating(ModelBuilder modelBuilder)
 {
     modelBuilder.Entity <Beer>(x =>
     {
         x.ToTable("Beer").HasKey(k => k.Id);
         x.Property(p => p.Id).HasColumnName("Id");
         x.Property(p => p.Name)
         .HasConversion(p => p.Value, p => BeerName.Create(p).Value);
         x.Property(p => p.Price)
         .HasConversion(p => p.Value, p => BeerPrice.Create(p).Value);
         x.Property(p => p.AlcoholDegree)
         .HasConversion(p => p.Value, p => BeerAlcoholDegree.Create(p).Value);
         x.HasOne(p => p.Brewery).WithMany(p => p.Beers);
     });
     modelBuilder.Entity <Provider>(x =>
     {
         x.ToTable("Provider").HasKey(k => k.Id);
         x.Property(p => p.Id).HasColumnName("Id");
         x.Property(p => p.Name)
         .HasConversion(p => p.Value, p => ProviderName.Create(p).Value);
     });
     modelBuilder.Entity <BeerProvider>(x =>
     {
         x.ToTable("BeerProvider").HasKey(k => k.Id);
         x.Property(p => p.Id).HasColumnName("Id");
         x.Property(p => p.BeerProviderQuantity)
         .HasConversion(p => p.Value, p => BeerProviderQuantity.Create(p).Value).HasColumnName("AvailableQuantity");
         x.HasOne(bp => bp.Beer).WithMany(b => b.BeerProviders);
         x.HasOne(bp => bp.Provider).WithMany(p => p.BeerProviders);
     });
     modelBuilder.Entity <Brewery>(x =>
     {
         x.ToTable("Brewery").HasKey(k => k.Id);
         x.Property(p => p.Id).HasColumnName("Id");
         x.Property(p => p.Name)
         .HasConversion(p => p.Value, p => BreweryName.Create(p).Value);
     });
 }
コード例 #7
0
 public void Create_beer_provider_with_null_beer_should_raise_an_exception()
 {
     var provider     = new Provider(ProviderName.Create("GeneDrinks").Value);
     var beerProvider = new BeerProvider(BeerProviderQuantity.Create(10).Value, null, provider);
 }
コード例 #8
0
        public void Create_provider_without_error()
        {
            var provider = new Provider(ProviderName.Create("GeneDrinks").Value);

            provider.ShouldNotBeNull();
        }