Skip to content
This repository has been archived by the owner on May 7, 2020. It is now read-only.

Commit

Permalink
some test entities added
Browse files Browse the repository at this point in the history
  • Loading branch information
osoykan committed Feb 8, 2017
1 parent 6335a35 commit 29246fe
Show file tree
Hide file tree
Showing 12 changed files with 194 additions and 85 deletions.
21 changes: 21 additions & 0 deletions test/Stove.Tests.SampleApplication/Domain/Entities/Brand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

using JetBrains.Annotations;

using Stove.Domain.Entities;

namespace Stove.Tests.SampleApplication.Domain.Entities
{
[Table("Brand")]
public class Brand : Entity
{
private Brand()
{
}

[Required]
[NotNull]
public virtual string Name { get; protected set; }
}
}
21 changes: 0 additions & 21 deletions test/Stove.Tests.SampleApplication/Domain/Entities/Cart.cs

This file was deleted.

18 changes: 18 additions & 0 deletions test/Stove.Tests.SampleApplication/Domain/Entities/Category.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

using Stove.Domain.Entities;

namespace Stove.Tests.SampleApplication.Domain.Entities
{
[Table("Category")]
public class Category : Entity
{
private Category()
{
}

[Required]
public virtual string Name { get; protected set; }
}
}
18 changes: 18 additions & 0 deletions test/Stove.Tests.SampleApplication/Domain/Entities/Gender.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

using Stove.Domain.Entities;

namespace Stove.Tests.SampleApplication.Domain.Entities
{
[Table("Gender")]
public class Gender : Entity
{
private Gender()
{
}

[Required]
public virtual string Name { get; protected set; }
}
}
19 changes: 0 additions & 19 deletions test/Stove.Tests.SampleApplication/Domain/Entities/Order.cs

This file was deleted.

26 changes: 0 additions & 26 deletions test/Stove.Tests.SampleApplication/Domain/Entities/OrderDetail.cs

This file was deleted.

40 changes: 27 additions & 13 deletions test/Stove.Tests.SampleApplication/Domain/Entities/Product.cs
Original file line number Diff line number Diff line change
@@ -1,29 +1,43 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

using JetBrains.Annotations;

using Stove.Domain.Entities;
using Stove.Domain.Entities.Auditing;

namespace Stove.Tests.SampleApplication.Domain.Entities
{
[Table(nameof(Product))]
public class Product : AggregateRoot, ICreationAudited
[Table("Product")]
public class Product : Entity
{
[Required]
public virtual string Name { get; set; }
private Product()
{
_productCategories = new List<ProductCategory>();
}

[Required]
public virtual string Code { get; set; }
[NotNull]
public virtual string Name { get; protected set; }

[Required]
public virtual string Description { get; set; }
[NotNull]
[InverseProperty("Product")]
public virtual ProductBrand ProductBrand { get; protected set; }

public ProductDetail ProductDetail { get; set; }
[NotNull]
[InverseProperty("Product")]
public virtual ProductGender ProductGender { get; protected set; }

[Required]
public virtual DateTime CreationTime { get; set; }
[NotNull]
[InverseProperty("Product")]
public virtual ProductDetail ProductDetail { get; protected set; }

[NotNull]
[ForeignKey("ProductId")]
public IReadOnlyCollection<ProductCategory> ProductCategories => _productCategories.ToImmutableList();

public virtual long? CreatorUserId { get; set; }
[NotNull]
protected virtual ICollection<ProductCategory> _productCategories { get; set; }
}
}
27 changes: 27 additions & 0 deletions test/Stove.Tests.SampleApplication/Domain/Entities/ProductBrand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

using JetBrains.Annotations;

using Stove.Domain.Entities;

namespace Stove.Tests.SampleApplication.Domain.Entities
{
[Table("ProductBrand")]
public class ProductBrand : Entity
{
private ProductBrand()
{
}

[NotNull]
[Required]
public virtual Product Product { get; protected set; }
public int ProductId { get; [UsedImplicitly] private set; }

[NotNull]
[Required]
public virtual Brand Brand { get; protected set; }
public int BrandId { get; [UsedImplicitly] private set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

using Stove.Domain.Entities;

namespace Stove.Tests.SampleApplication.Domain.Entities
{
[Table("ProductCategory")]
public class ProductCategory : Entity
{
private ProductCategory()
{
}

[Required]
public virtual Category Category { get; protected set; }

[Required]
public virtual Product Product { get; protected set; }
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

using JetBrains.Annotations;

using Stove.Domain.Entities;

namespace Stove.Tests.SampleApplication.Domain.Entities
{
[Table(nameof(ProductDetail))]
[Table("ProductDetail")]
public class ProductDetail : Entity
{
private ProductDetail()
{
}

[Required]
public Product Product { get; set; }
[NotNull]
public virtual string Description { get; protected set; }

public virtual string Age { get; set; }
[Required]
[NotNull]
public virtual Product Product { get; protected set; }
public int ProductId { get; [UsedImplicitly] private set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

using JetBrains.Annotations;

using Stove.Domain.Entities;

namespace Stove.Tests.SampleApplication.Domain.Entities
{
[Table("ProductGender")]
public class ProductGender : Entity
{
private ProductGender()
{
}

[Required]
[NotNull]
public virtual Gender Gender { get; protected set; }
public int GenderId { get; [UsedImplicitly] private set; }

[Required]
[NotNull]
public virtual Product Product { get; protected set; }
public int ProductId { get; [UsedImplicitly] private set; }
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System.Data.Common;
using System.Data.Entity;

using JetBrains.Annotations;

using Stove.EntityFramework.EntityFramework;
using Stove.Tests.SampleApplication.Domain.Entities;

Expand All @@ -17,14 +19,31 @@ public SampleApplicationDbContext(DbConnection connection)
{
}

[NotNull]
public virtual IDbSet<Product> Products { get; set; }

public virtual IDbSet<User> Users { get; set; }
[NotNull]
public virtual IDbSet<Brand> Brands { get; set; }

[NotNull]
public virtual IDbSet<Category> Categories { get; set; }

[NotNull]
public virtual IDbSet<Gender> Genders { get; set; }

public virtual IDbSet<Order> Orders { get; set; }
[NotNull]
public virtual IDbSet<ProductBrand> ProductBrands { get; set; }

public virtual IDbSet<OrderDetail> OrderDetails { get; set; }
[NotNull]
public virtual IDbSet<ProductCategory> ProductCategories { get; set; }

[NotNull]
public virtual IDbSet<ProductGender> ProductGenders { get; set; }

[NotNull]
public virtual IDbSet<User> Users { get; set; }

[NotNull]
public virtual IDbSet<ProductDetail> ProductDetails { get; set; }
}
}

0 comments on commit 29246fe

Please sign in to comment.