├── Example.DTO
├── Example.DTO.csproj
└── Horse
│ ├── HorseSummary.cs
│ ├── HorseDetail.cs
│ └── HorseCreate.cs
├── Example.Repositories.Interfaces
├── Example.Repositories.Interfaces.csproj
└── IRepository.cs
├── Example.API
├── appsettings.Development.json
├── appsettings.json
├── Attributes
│ └── ValidateModelAttribute.cs
├── Program.cs
├── Example.API.csproj
├── Startup.cs
└── Controllers
│ └── HorsesController.cs
├── Example.Repositories.Tests
├── UnitTest1.cs
└── Example.Repositories.Tests.csproj
├── README.md
├── Example.Models
├── Example.Models.csproj
├── Color.cs
├── ExampleContext.cs
└── Horse.cs
├── Example.Services.Interfaces
├── Example.Services.Interfaces.csproj
└── IHorseService.cs
├── .travis.yml
├── Example.Repositories
├── Example.Repositories.csproj
└── Repository.cs
├── Example.Services
├── Example.Services.csproj
└── HorseService.cs
├── Example.Services.Tests
├── Example.Services.Tests.csproj
├── Factories
│ └── HorseFactory.cs
├── Fakes
│ └── FakeHorseRepository.cs
└── HorseServiceTests
│ ├── Get.cs
│ ├── Create.cs
│ └── GetAll.cs
├── Example.API.Tests
├── Example.API.Tests.csproj
└── HorseControllerTests
│ ├── GetAll.cs
│ ├── Create.cs
│ └── Get.cs
├── LICENSE
├── .gitattributes
├── .gitignore
└── BetterGenericRepository.sln
/Example.DTO/Example.DTO.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp2.0
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Example.DTO/Horse/HorseSummary.cs:
--------------------------------------------------------------------------------
1 | namespace Example.DTO.Horse
2 | {
3 | public class HorseSummary
4 | {
5 | public int Id { get; set; }
6 | public string Name { get; set; }
7 | }
8 | }
--------------------------------------------------------------------------------
/Example.Repositories.Interfaces/Example.Repositories.Interfaces.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp2.0
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Example.API/appsettings.Development.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "IncludeScopes": false,
4 | "LogLevel": {
5 | "Default": "Debug",
6 | "System": "Information",
7 | "Microsoft": "Information"
8 | }
9 | }
10 | }
--------------------------------------------------------------------------------
/Example.Repositories.Tests/UnitTest1.cs:
--------------------------------------------------------------------------------
1 | using Xunit;
2 |
3 | namespace Example.Repositories.Tests
4 | {
5 | public class UnitTest1
6 | {
7 | [Fact]
8 | public void Test1()
9 | {
10 | }
11 | }
12 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # BetterGenericRepository
2 | A Better Generic Repository and Dependency Injection with .NET Core
3 |
4 | [](https://travis-ci.org/ovation22/BetterGenericRepository)
5 |
--------------------------------------------------------------------------------
/Example.Models/Example.Models.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp2.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Example.Services.Interfaces/Example.Services.Interfaces.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp2.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Example.Services.Interfaces/IHorseService.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using Example.DTO.Horse;
3 |
4 | namespace Example.Services.Interfaces
5 | {
6 | public interface IHorseService
7 | {
8 | IEnumerable GetAll();
9 | HorseDetail Get(int id);
10 | void Create(HorseCreate horse);
11 | }
12 | }
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: csharp
2 | mono: none
3 | dotnet: 2.0.0
4 | dist: trusty
5 | sudo: false
6 | solution: BetterGenericRepository.sln
7 |
8 | script:
9 | - dotnet restore
10 | - dotnet build
11 | - dotnet test Example.API.Tests/Example.API.Tests.csproj
12 | - dotnet test Example.Repositories.Tests/Example.Repositories.Tests.csproj
13 | - dotnet test Example.Services.Tests/Example.Services.Tests.csproj
14 |
--------------------------------------------------------------------------------
/Example.Repositories.Interfaces/IRepository.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using System.Linq.Expressions;
4 |
5 | namespace Example.Repositories.Interfaces
6 | {
7 | public interface IRepository
8 | {
9 | T Get(Func predicate);
10 | IQueryable GetAll();
11 | void Add(T entity);
12 | void Save();
13 | IRepository Include(Expression> path);
14 | }
15 | }
--------------------------------------------------------------------------------
/Example.API/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "ConnectionStrings": {
3 | "DefaultConnection": "Server=.\\SQL2016;Database=Example;Trusted_Connection=True;MultipleActiveResultSets=true"
4 | },
5 | "Logging": {
6 | "IncludeScopes": false,
7 | "Debug": {
8 | "LogLevel": {
9 | "Default": "Warning"
10 | }
11 | },
12 | "Console": {
13 | "LogLevel": {
14 | "Default": "Warning"
15 | }
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/Example.DTO/Horse/HorseDetail.cs:
--------------------------------------------------------------------------------
1 | namespace Example.DTO.Horse
2 | {
3 | public class HorseDetail
4 | {
5 | public int Id { get; set; }
6 | public string Name { get; set; }
7 | public int Starts { get; set; }
8 | public int Win { get; set; }
9 | public int Place { get; set; }
10 | public int Show { get; set; }
11 | public int Earnings { get; set; }
12 | public string Color { get; set; }
13 | }
14 | }
--------------------------------------------------------------------------------
/Example.DTO/Horse/HorseCreate.cs:
--------------------------------------------------------------------------------
1 | namespace Example.DTO.Horse
2 | {
3 | public class HorseCreate
4 | {
5 | public string Name { get; set; }
6 | public int Starts { get; set; }
7 | public int Win { get; set; }
8 | public int Place { get; set; }
9 | public int Show { get; set; }
10 | public int Earnings { get; set; }
11 | public byte ColorId { get; set; }
12 | public int? SireId { get; set; }
13 | public int? DamId { get; set; }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/Example.API/Attributes/ValidateModelAttribute.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Mvc;
2 | using Microsoft.AspNetCore.Mvc.Filters;
3 |
4 | namespace Example.API.Attributes
5 | {
6 | public class ValidateModelAttribute : ActionFilterAttribute
7 | {
8 | public override void OnActionExecuting(ActionExecutingContext context)
9 | {
10 | if (!context.ModelState.IsValid)
11 | {
12 | context.Result = new BadRequestObjectResult(context.ModelState);
13 | }
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Example.Repositories.Tests/Example.Repositories.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp2.0
5 |
6 | false
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/Example.Repositories/Example.Repositories.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp2.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/Example.Services/Example.Services.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp2.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/Example.Models/Color.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.ComponentModel.DataAnnotations;
3 |
4 | namespace Example.Models
5 | {
6 | public class Color
7 | {
8 | public Color()
9 | {
10 | Horses = new HashSet();
11 | }
12 |
13 | public byte Id { get; set; }
14 |
15 | [Required]
16 | [StringLength(50)]
17 | public string Name { get; set; }
18 |
19 | [Required]
20 | [StringLength(255)]
21 | public string Description { get; set; }
22 |
23 | public virtual ICollection Horses { get; set; }
24 | }
25 | }
--------------------------------------------------------------------------------
/Example.API/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Threading.Tasks;
6 | using Microsoft.AspNetCore;
7 | using Microsoft.AspNetCore.Hosting;
8 | using Microsoft.Extensions.Configuration;
9 | using Microsoft.Extensions.Logging;
10 |
11 | namespace Example.API
12 | {
13 | public class Program
14 | {
15 | public static void Main(string[] args)
16 | {
17 | BuildWebHost(args).Run();
18 | }
19 |
20 | public static IWebHost BuildWebHost(string[] args) =>
21 | WebHost.CreateDefaultBuilder(args)
22 | .UseStartup()
23 | .Build();
24 | }
25 | }
--------------------------------------------------------------------------------
/Example.Services.Tests/Example.Services.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp2.0
5 |
6 | false
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/Example.API.Tests/Example.API.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp2.0
5 |
6 | false
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Example.Services.Tests/Factories/HorseFactory.cs:
--------------------------------------------------------------------------------
1 | using Example.Models;
2 | using Example.Services.Tests.Fakes;
3 |
4 | namespace Example.Services.Tests.Factories
5 | {
6 | internal static class HorseFactory
7 | {
8 | public static Horse Create(FakeHorseRepository fakeRepository, int id = 1, string name = "Ed")
9 | {
10 | var horse = new Horse
11 | {
12 | Id = id,
13 | Name = name,
14 | };
15 |
16 | fakeRepository.Horses.Add(horse);
17 |
18 | return horse;
19 | }
20 |
21 | public static Horse WithColor(this Horse horse)
22 | {
23 | horse.Color = new Color
24 | {
25 | Id = 1,
26 | Name = "Brown"
27 | };
28 |
29 | return horse;
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 John Callaway
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/Example.Models/ExampleContext.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore;
2 |
3 | namespace Example.Models
4 | {
5 | public class ExampleContext : DbContext
6 | {
7 | public ExampleContext(DbContextOptions options)
8 | : base(options)
9 | {
10 | }
11 |
12 | public virtual DbSet Colors { get; set; }
13 |
14 | public virtual DbSet Horses { get; set; }
15 |
16 | protected override void OnModelCreating(ModelBuilder modelBuilder)
17 | {
18 | modelBuilder.Entity()
19 | .HasOne(p => p.Color)
20 | .WithMany(b => b.Horses)
21 | .HasForeignKey(p => p.ColorId)
22 | .IsRequired();
23 |
24 | modelBuilder.Entity()
25 | .HasMany(p => p.SireOffspring)
26 | .WithOne(b => b.Sire)
27 | .HasForeignKey(p => p.SireId);
28 |
29 | modelBuilder.Entity()
30 | .HasMany(p => p.DamOffspring)
31 | .WithOne(b => b.Dam)
32 | .HasForeignKey(p => p.DamId);
33 | }
34 | }
35 | }
--------------------------------------------------------------------------------
/Example.Models/Horse.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.ComponentModel.DataAnnotations;
3 |
4 | namespace Example.Models
5 | {
6 | public sealed class Horse
7 | {
8 | public Horse()
9 | {
10 | SireOffspring = new HashSet();
11 | DamOffspring = new HashSet();
12 | }
13 |
14 | public int Id { get; set; }
15 |
16 | [Required]
17 | [StringLength(50)]
18 | public string Name { get; set; }
19 |
20 | public byte ColorId { get; set; }
21 |
22 | public int? SireId { get; set; }
23 |
24 | public int? DamId { get; set; }
25 |
26 | public int RaceStarts { get; set; }
27 |
28 | public int RaceWins { get; set; }
29 |
30 | public int RacePlace { get; set; }
31 |
32 | public int RaceShow { get; set; }
33 |
34 | public int Earnings { get; set; }
35 |
36 | public Color Color { get; set; }
37 |
38 | public ICollection SireOffspring { get; set; }
39 |
40 | public Horse Sire { get; set; }
41 |
42 | public ICollection DamOffspring { get; set; }
43 |
44 | public Horse Dam { get; set; }
45 | }
46 | }
--------------------------------------------------------------------------------
/Example.API/Example.API.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp2.0
5 |
6 |
7 |
8 | bin\Debug\netcoreapp2.0\Example.API.xml
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/Example.Services.Tests/Fakes/FakeHorseRepository.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Linq.Expressions;
5 | using Example.Models;
6 | using Example.Repositories.Interfaces;
7 |
8 | namespace Example.Services.Tests.Fakes
9 | {
10 | internal class FakeHorseRepository : IRepository
11 | {
12 | public List Horses = new List();
13 |
14 | public bool GetCalled { get; set; }
15 | public bool GetAllCalled { get; private set; }
16 | public bool AddCalled { get; set; }
17 | public bool SaveCalled { get; set; }
18 | public Horse AddCalledWith { get; set; }
19 |
20 | public Horse Get(Func predicate)
21 | {
22 | GetCalled = true;
23 | return Horses.SingleOrDefault(predicate);
24 | }
25 |
26 | public IQueryable GetAll()
27 | {
28 | GetAllCalled = true;
29 | return Horses.AsQueryable();
30 | }
31 |
32 | public void Add(Horse entity)
33 | {
34 | AddCalled = true;
35 | AddCalledWith = entity;
36 | }
37 |
38 | public void Save()
39 | {
40 | SaveCalled = true;
41 | }
42 |
43 | public IRepository Include(Expression> path)
44 | {
45 | return this;
46 | }
47 | }
48 | }
--------------------------------------------------------------------------------
/Example.Services.Tests/HorseServiceTests/Get.cs:
--------------------------------------------------------------------------------
1 | using Example.Services.Tests.Factories;
2 | using Example.Services.Tests.Fakes;
3 | using Xunit;
4 |
5 | namespace Example.Services.Tests.HorseServiceTests
6 | {
7 | [Trait("Category", "HorseService")]
8 | public class Get
9 | {
10 | private readonly FakeHorseRepository _fakeRepository;
11 |
12 | public Get()
13 | {
14 | _fakeRepository = new FakeHorseRepository();
15 | }
16 |
17 | [Theory]
18 | [InlineData(1, "Ed")]
19 | [InlineData(2, "War Admiral")]
20 | [InlineData(3, "Suzie")]
21 | public void ItReturnsHorseFromRepository(int id, string name)
22 | {
23 | // Arrange
24 | var expectedHorse = HorseFactory.Create(_fakeRepository, id, name).WithColor();
25 | var service = new HorseService(_fakeRepository);
26 |
27 | // Act
28 | var actualHorse = service.Get(expectedHorse.Id);
29 |
30 | // Assert
31 | Assert.True(_fakeRepository.GetCalled);
32 | Assert.Equal(expectedHorse.Id, actualHorse.Id);
33 | Assert.Equal(expectedHorse.Name, actualHorse.Name);
34 | }
35 |
36 | [Fact]
37 | public void GivenHorseNotFoundThenNullHorse()
38 | {
39 | // Arrange
40 | var service = new HorseService(_fakeRepository);
41 |
42 | // Act
43 | var actualHorse = service.Get(-1);
44 |
45 | // Assert
46 | Assert.Null(actualHorse);
47 | }
48 | }
49 | }
--------------------------------------------------------------------------------
/Example.Repositories/Repository.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Example.Repositories.Interfaces;
4 | using Microsoft.EntityFrameworkCore;
5 | using System.Linq;
6 | using System.Linq.Expressions;
7 |
8 | namespace Example.Repositories
9 | {
10 | public class Repository : IRepository where T : class
11 | {
12 | private readonly DbSet _dbSet;
13 | protected readonly DbContext Context;
14 | private readonly IList>> _modifiers;
15 |
16 | public Repository(DbContext context)
17 | {
18 | Context = context;
19 | _dbSet = context.Set();
20 | _modifiers = new List>>();
21 | }
22 |
23 | protected IQueryable DbSet
24 | {
25 | get
26 | {
27 | return _modifiers.Aggregate((IQueryable) _dbSet, (current, include) =>
28 | current.Include(include));
29 | }
30 | }
31 |
32 | public T Get(Func predicate)
33 | {
34 | return DbSet.SingleOrDefault(predicate);
35 | }
36 |
37 | public IQueryable GetAll()
38 | {
39 | return DbSet;
40 | }
41 |
42 | public void Add(T entity)
43 | {
44 | Context.Set().Add(entity);
45 | }
46 |
47 | public void Save()
48 | {
49 | Context.SaveChanges();
50 | }
51 |
52 | public IRepository Include(Expression> path)
53 | {
54 | _modifiers.Add(path);
55 |
56 | return this;
57 | }
58 | }
59 | }
--------------------------------------------------------------------------------
/Example.Services/HorseService.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Linq;
3 | using Example.DTO.Horse;
4 | using Example.Models;
5 | using Example.Repositories.Interfaces;
6 | using Example.Services.Interfaces;
7 |
8 | namespace Example.Services
9 | {
10 | public class HorseService : IHorseService
11 | {
12 | private readonly IRepository _repository;
13 |
14 | public HorseService(IRepository repository)
15 | {
16 | _repository = repository;
17 | }
18 |
19 | public IEnumerable GetAll()
20 | {
21 | return _repository.GetAll().Select(x => new HorseSummary
22 | {
23 | Id = x.Id,
24 | Name = x.Name
25 | });
26 | }
27 |
28 | public HorseDetail Get(int id)
29 | {
30 | var horse = _repository.Include(x => x.Color).Get(x => x.Id == id);
31 |
32 | return horse == null ? null : Map(horse);
33 | }
34 |
35 | public void Create(HorseCreate horse)
36 | {
37 | var horseEntity = new Horse
38 | {
39 | Name = horse.Name,
40 | ColorId = horse.ColorId,
41 | RaceWins = horse.Win,
42 | RacePlace = horse.Place,
43 | RaceShow = horse.Show,
44 | RaceStarts = horse.Starts,
45 | SireId = horse.SireId,
46 | DamId = horse.DamId
47 | };
48 |
49 | _repository.Add(horseEntity);
50 | _repository.Save();
51 | }
52 |
53 | private static HorseDetail Map(Horse horse)
54 | {
55 | return new HorseDetail
56 | {
57 | Id = horse.Id,
58 | Name = horse.Name,
59 | Starts = horse.RaceStarts,
60 | Win = horse.RaceWins,
61 | Place = horse.RacePlace,
62 | Show = horse.RaceShow,
63 | Earnings = horse.Earnings,
64 | Color = horse.Color.Name
65 | };
66 | }
67 | }
68 | }
--------------------------------------------------------------------------------
/Example.Services.Tests/HorseServiceTests/Create.cs:
--------------------------------------------------------------------------------
1 | using Example.DTO.Horse;
2 | using Example.Services.Tests.Fakes;
3 | using Xunit;
4 |
5 | namespace Example.Services.Tests.HorseServiceTests
6 | {
7 | [Trait("Category", "HorseService")]
8 | public class Create
9 | {
10 | private readonly FakeHorseRepository _fakeRepository;
11 |
12 | public Create()
13 | {
14 | _fakeRepository = new FakeHorseRepository();
15 | }
16 |
17 | [Fact]
18 | public void ItCallsRepositoryAdd()
19 | {
20 | // Arrange
21 | var service = new HorseService(_fakeRepository);
22 |
23 | // Act
24 | service.Create(new HorseCreate());
25 |
26 | // Assert
27 | Assert.True(_fakeRepository.AddCalled);
28 | }
29 |
30 | [Fact]
31 | public void ItCallsRepositorySave()
32 | {
33 | // Arrange
34 | var service = new HorseService(_fakeRepository);
35 |
36 | // Act
37 | service.Create(new HorseCreate());
38 |
39 | // Assert
40 | Assert.True(_fakeRepository.SaveCalled);
41 | }
42 |
43 | [Fact]
44 | public void ItMapsHorse()
45 | {
46 | // Arrange
47 | var service = new HorseService(_fakeRepository);
48 | var horse = new HorseCreate
49 | {
50 | Name = "Test",
51 | ColorId = 1,
52 | Win = 2,
53 | Place = 3,
54 | Show = 4,
55 | Starts = 5,
56 | SireId = 6,
57 | DamId = 7
58 | };
59 |
60 | // Act
61 | service.Create(horse);
62 | var actual = _fakeRepository.AddCalledWith;
63 |
64 | // Assert
65 | Assert.Equal(horse.Name, actual.Name);
66 | Assert.Equal(horse.ColorId, actual.ColorId);
67 | Assert.Equal(horse.Win, actual.RaceWins);
68 | Assert.Equal(horse.Place, actual.RacePlace);
69 | Assert.Equal(horse.Show, actual.RaceShow);
70 | Assert.Equal(horse.Starts, actual.RaceStarts);
71 | Assert.Equal(horse.SireId, actual.SireId);
72 | Assert.Equal(horse.DamId, actual.DamId);
73 | }
74 | }
75 | }
--------------------------------------------------------------------------------
/Example.Services.Tests/HorseServiceTests/GetAll.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Linq;
3 | using Example.DTO.Horse;
4 | using Example.Services.Tests.Factories;
5 | using Example.Services.Tests.Fakes;
6 | using Xunit;
7 |
8 | namespace Example.Services.Tests.HorseServiceTests
9 | {
10 | [Collection("HorseService")]
11 | [Trait("Category", "HorseService")]
12 | [Trait("Category", "HorseSummary")]
13 | public class GetAll
14 | {
15 | private readonly HorseService _horseService;
16 | private readonly FakeHorseRepository _fakeRepository;
17 |
18 | public GetAll()
19 | {
20 | _fakeRepository = new FakeHorseRepository();
21 | HorseFactory.Create(_fakeRepository);
22 |
23 | _horseService = new HorseService(_fakeRepository);
24 | }
25 |
26 | [Fact]
27 | public void ItReturnsCollectionOfHorseSummary()
28 | {
29 | // Arrange
30 | // Act
31 | var horses = _horseService.GetAll();
32 |
33 | // Assert
34 | Assert.NotNull(horses);
35 | Assert.IsAssignableFrom>(horses);
36 | }
37 |
38 | [Fact]
39 | public void ItReturnsAllHorses()
40 | {
41 | // Arrange
42 | // Act
43 | var horses = _horseService.GetAll();
44 |
45 | // Assert
46 | Assert.NotNull(horses);
47 | Assert.IsAssignableFrom>(horses);
48 | Assert.Equal(_fakeRepository.Horses.Count, horses.Count());
49 | }
50 |
51 | [Fact]
52 | public void ItReturnsAllHorsesWithProperties()
53 | {
54 | // Arrange
55 | // Act
56 | var horses = _horseService.GetAll().ToList();
57 |
58 | // Assert
59 | Assert.NotNull(horses);
60 | Assert.IsAssignableFrom>(horses);
61 |
62 | for (var i = 0; i < horses.Count; i++)
63 | {
64 | Assert.NotNull(_fakeRepository.Horses[i].Name);
65 | Assert.Equal(_fakeRepository.Horses[i].Name, horses[i].Name);
66 | Assert.NotNull(_fakeRepository.Horses[i].Id);
67 | Assert.Equal(_fakeRepository.Horses[i].Id, horses[i].Id);
68 | }
69 | }
70 | }
71 | }
--------------------------------------------------------------------------------
/Example.API.Tests/HorseControllerTests/GetAll.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Linq;
3 | using Moq;
4 | using Xunit;
5 | using Example.API.Controllers;
6 | using Example.DTO;
7 | using Example.DTO.Horse;
8 | using Example.Services.Interfaces;
9 | using Microsoft.AspNetCore.Mvc;
10 |
11 | namespace Example.API.Tests.HorseControllerTests
12 | {
13 | [Collection("HorseController")]
14 | [Trait("Category", "HorseController")]
15 | public class GetAll
16 | {
17 | private readonly HorsesController _controller;
18 | private static Mock _horseServiceMock;
19 | private readonly List _horses;
20 |
21 | public GetAll()
22 | {
23 | _horses = new List
24 | {
25 | new HorseSummary
26 | {
27 | Name = "test"
28 | }
29 | };
30 |
31 | _horseServiceMock = new Mock();
32 | _horseServiceMock.Setup(x => x.GetAll())
33 | .Returns(() => _horses);
34 |
35 | _controller = new HorsesController(_horseServiceMock.Object);
36 | }
37 |
38 | [Fact]
39 | public void ItReturnsOkObjectResult()
40 | {
41 | // Arrange
42 | // Act
43 | var result = _controller.Get();
44 |
45 | // Assert
46 | Assert.NotNull(result);
47 | Assert.IsType(result);
48 | }
49 |
50 | [Fact]
51 | public void ItReturnsCollectionOfHorseSummary()
52 | {
53 | // Arrange
54 | // Act
55 | var result = _controller.Get() as OkObjectResult;
56 |
57 | // Assert
58 | Assert.NotNull(result);
59 | Assert.NotNull(result.Value);
60 | Assert.IsAssignableFrom>(result.Value);
61 | }
62 |
63 | [Fact]
64 | public void ItCallsGetAllServiceOnce()
65 | {
66 | // Arrange
67 | // Act
68 | _controller.Get();
69 |
70 | // Assert
71 | _horseServiceMock.Verify(mock => mock.GetAll(), Times.Once());
72 | }
73 |
74 | [Fact]
75 | public void GivenHorseServiceThenResultsReturned()
76 | {
77 | // Arrange
78 | // Act
79 | var result = _controller.Get() as OkObjectResult;
80 |
81 | // Assert
82 | Assert.NotNull(result);
83 | var horses = ((IEnumerable) result.Value).ToList();
84 | Assert.Equal(_horses, horses);
85 | }
86 | }
87 | }
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/Example.API.Tests/HorseControllerTests/Create.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using Example.API.Attributes;
3 | using Moq;
4 | using Xunit;
5 | using Example.API.Controllers;
6 | using Example.DTO.Horse;
7 | using Example.Services.Interfaces;
8 | using Microsoft.AspNetCore.Mvc;
9 |
10 | namespace Example.API.Tests.HorseControllerTests
11 | {
12 | [Collection("HorseController")]
13 | [Trait("Category", "HorseController")]
14 | public class Create
15 | {
16 | private readonly HorsesController _controller;
17 | private static Mock _horseServiceMock;
18 | private readonly HorseCreate _horse;
19 |
20 | public Create()
21 | {
22 | _horse = new HorseCreate
23 | {
24 | Name = "Horse"
25 | };
26 |
27 | _horseServiceMock = new Mock();
28 | _horseServiceMock.Setup(x => x.Create(It.IsAny()))
29 | .Verifiable();
30 |
31 | _controller = new HorsesController(_horseServiceMock.Object);
32 | }
33 |
34 | [Fact]
35 | public void ItAcceptsHorseCreate()
36 | {
37 | // Arrange
38 | // Act
39 | _controller.Create(_horse);
40 | }
41 |
42 | [Fact]
43 | public void ItReturnsOkObjectResult()
44 | {
45 | // Arrange
46 | // Act
47 | var result = _controller.Create(_horse);
48 |
49 | // Assert
50 | Assert.IsType(result);
51 | }
52 |
53 | [Fact]
54 | public void ItCallsCreateServiceOnce()
55 | {
56 | // Arrange
57 | // Act
58 | _controller.Create(_horse);
59 |
60 | // Assert
61 | _horseServiceMock.Verify(mock => mock.Create(It.IsAny()), Times.Once());
62 | }
63 |
64 | [Fact]
65 | public void ItCallsCreateServiceWithProvidedHorse()
66 | {
67 | // Arrange
68 | // Act
69 | _controller.Create(_horse);
70 |
71 | // Assert
72 | _horseServiceMock.Verify(mock => mock.Create(_horse), Times.Once());
73 | }
74 |
75 | [Fact]
76 | public void ItHasValidateModelAttribute()
77 | {
78 | // Arrange
79 | // Act
80 | var method = typeof(HorsesController).GetMethods()
81 | .SingleOrDefault(x => x.Name == nameof(HorsesController.Create));
82 |
83 | var attribute = method?.GetCustomAttributes(typeof(ValidateModelAttribute), true)
84 | .Single() as ValidateModelAttribute;
85 |
86 | // Assert
87 | Assert.NotNull(attribute);
88 | }
89 | }
90 | }
--------------------------------------------------------------------------------
/Example.API/Startup.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 | using Example.Models;
3 | using Example.Repositories;
4 | using Example.Repositories.Interfaces;
5 | using Example.Services;
6 | using Example.Services.Interfaces;
7 | using Microsoft.AspNetCore.Builder;
8 | using Microsoft.AspNetCore.Hosting;
9 | using Microsoft.EntityFrameworkCore;
10 | using Microsoft.Extensions.Configuration;
11 | using Microsoft.Extensions.DependencyInjection;
12 | using Microsoft.Extensions.PlatformAbstractions;
13 | using Swashbuckle.AspNetCore.Swagger;
14 |
15 | namespace Example.API
16 | {
17 | public class Startup
18 | {
19 | public Startup(IConfiguration configuration)
20 | {
21 | Configuration = configuration;
22 | }
23 |
24 | public IConfiguration Configuration { get; }
25 |
26 | // This method gets called by the runtime. Use this method to add services to the container.
27 | public void ConfigureServices(IServiceCollection services)
28 | {
29 | services.AddDbContextPool(options =>
30 | options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
31 |
32 | services.AddMvc();
33 |
34 | services.AddSingleton(Configuration);
35 | services.AddSingleton(typeof(DbContext), typeof(ExampleContext));
36 | services.AddScoped(typeof(IRepository<>), typeof(Repository<>));
37 | services.AddTransient();
38 |
39 | // Register the Swagger generator, defining one or more Swagger documents
40 | services.AddSwaggerGen(c =>
41 | {
42 | c.SwaggerDoc("v1", new Info {Title = "Better Generic Repository Example API", Version = "v1"});
43 | });
44 |
45 | services.ConfigureSwaggerGen(c =>
46 | {
47 | c.IncludeXmlComments(GetXmlCommentsPath(PlatformServices.Default.Application));
48 | });
49 | }
50 |
51 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
52 | public void Configure(IApplicationBuilder app, IHostingEnvironment env)
53 | {
54 | if (env.IsDevelopment())
55 | {
56 | app.UseDeveloperExceptionPage();
57 | }
58 |
59 | app.UseMvc();
60 |
61 | // Enable middleware to serve generated Swagger as a JSON endpoint.
62 | app.UseSwagger();
63 |
64 | // Enable middleware to serve swagger-ui (HTML, JS, CSS etc.), specifying the Swagger JSON endpoint.
65 | app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "Better Generic Repository Example API"); });
66 | }
67 |
68 | private static string GetXmlCommentsPath(ApplicationEnvironment appEnvironment)
69 | {
70 | return Path.Combine(appEnvironment.ApplicationBasePath, "Example.API.xml");
71 | }
72 | }
73 | }
--------------------------------------------------------------------------------
/Example.API/Controllers/HorsesController.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using Example.API.Attributes;
3 | using Example.DTO.Horse;
4 | using Microsoft.AspNetCore.Mvc;
5 | using Example.Services.Interfaces;
6 | using Microsoft.AspNetCore.Http;
7 |
8 | namespace Example.API.Controllers
9 | {
10 | [Route("api/[controller]")]
11 | public class HorsesController : Controller
12 | {
13 | private readonly IHorseService _horseService;
14 |
15 | public HorsesController(IHorseService horseService)
16 | {
17 | _horseService = horseService;
18 | }
19 |
20 | ///
21 | /// Gets the full list of horses
22 | ///
23 | /// Horses found
24 | /// Oops! Something went horribly wrong
25 | /// IEnumerable<Models.HorseSummary>
26 | [HttpGet]
27 | [Produces("application/json", Type = typeof(IEnumerable))]
28 | [ProducesResponseType(typeof(IEnumerable), StatusCodes.Status200OK)]
29 | [ProducesResponseType(typeof(void), StatusCodes.Status500InternalServerError)]
30 | public IActionResult Get()
31 | {
32 | var horses = _horseService.GetAll();
33 |
34 | return Ok(horses);
35 | }
36 |
37 | ///
38 | /// Gets an individual horse's information
39 | ///
40 | ///
41 | /// Horse found
42 | /// Horse not found
43 | /// Oops! Something went horribly wrong
44 | /// string
45 | [HttpGet("{id}")]
46 | [Produces("application/json", Type = typeof(HorseDetail))]
47 | [ProducesResponseType(typeof(HorseDetail), StatusCodes.Status200OK)]
48 | [ProducesResponseType(typeof(string), StatusCodes.Status404NotFound)]
49 | [ProducesResponseType(typeof(void), StatusCodes.Status500InternalServerError)]
50 | public IActionResult Get(int id)
51 | {
52 | var horse = _horseService.Get(id);
53 |
54 | if (horse == null)
55 | {
56 | return NotFound("Horse Not Found");
57 | }
58 |
59 | return Ok(horse);
60 | }
61 |
62 | ///
63 | /// Creates a new horse
64 | ///
65 | ///
66 | /// Horse accepted
67 | /// BadRequest or underlying services has failed, check error message
68 | /// Oops! Something went horribly wrong
69 | /// string
70 | [HttpPost]
71 | [ValidateModel]
72 | [ProducesResponseType(StatusCodes.Status202Accepted)]
73 | [ProducesResponseType(typeof(string), StatusCodes.Status400BadRequest)]
74 | [ProducesResponseType(typeof(void), StatusCodes.Status500InternalServerError)]
75 | public IActionResult Create([FromBody] HorseCreate horse)
76 | {
77 | _horseService.Create(horse);
78 |
79 | return Accepted();
80 | }
81 | }
82 | }
--------------------------------------------------------------------------------
/Example.API.Tests/HorseControllerTests/Get.cs:
--------------------------------------------------------------------------------
1 | using Moq;
2 | using Xunit;
3 | using Example.API.Controllers;
4 | using Example.DTO.Horse;
5 | using Example.Services.Interfaces;
6 | using Microsoft.AspNetCore.Mvc;
7 |
8 | namespace Example.API.Tests.HorseControllerTests
9 | {
10 | [Collection("HorseController")]
11 | [Trait("Category", "HorseController")]
12 | public class Get
13 | {
14 | private readonly HorsesController _controller;
15 | private static Mock _horseServiceMock;
16 | private readonly HorseDetail _horse;
17 |
18 | public Get()
19 | {
20 | _horse = new HorseDetail
21 | {
22 | Name = "Horse"
23 | };
24 |
25 | _horseServiceMock = new Mock();
26 | _horseServiceMock.Setup(x => x.Get(It.IsAny()))
27 | .Returns(() => _horse);
28 | _horseServiceMock.Setup(x => x.Get(-1))
29 | .Returns(() => null);
30 |
31 | _controller = new HorsesController(_horseServiceMock.Object);
32 | }
33 |
34 | [Fact]
35 | public void ItAcceptsInteger()
36 | {
37 | // Arrange
38 | // Act
39 | _controller.Get(1);
40 | }
41 |
42 | [Fact]
43 | public void ItReturnsOkObjectResult()
44 | {
45 | // Arrange
46 | // Act
47 | var result = _controller.Get(1);
48 |
49 | // Assert
50 | Assert.IsType(result);
51 | }
52 |
53 | [Fact]
54 | public void ItReturnsHorseDetail()
55 | {
56 | // Arrange
57 | // Act
58 | var result = _controller.Get(1) as OkObjectResult;
59 |
60 | // Assert
61 | Assert.NotNull(result);
62 | Assert.NotNull(result.Value);
63 | Assert.IsType(result.Value);
64 | }
65 |
66 | [Fact]
67 | public void ItCallsGetServiceOnce()
68 | {
69 | // Arrange
70 | // Act
71 | _controller.Get(1);
72 |
73 | // Assert
74 | _horseServiceMock.Verify(mock => mock.Get(It.IsAny()), Times.Once());
75 | }
76 |
77 | [Fact]
78 | public void ItCallsGetServiceWithProvidedId()
79 | {
80 | // Arrange
81 | const int id = 1;
82 |
83 | // Act
84 | _controller.Get(id);
85 |
86 | // Assert
87 | _horseServiceMock.Verify(mock => mock.Get(id), Times.Once());
88 | }
89 |
90 | [Fact]
91 | public void GivenHorseServiceThenResultsReturned()
92 | {
93 | // Arrange
94 | // Act
95 | var result = _controller.Get(1) as OkObjectResult;
96 |
97 | // Assert
98 | Assert.NotNull(result);
99 | var horse = ((HorseDetail) result.Value);
100 | Assert.Equal(_horse, horse);
101 | }
102 |
103 | [Fact]
104 | public void GivenHorseNotFoundExceptionThenNotFoundObjectResult()
105 | {
106 | // Arrange
107 | // Act
108 | var result = _controller.Get(-1);
109 |
110 | // Assert
111 | Assert.IsAssignableFrom(result);
112 | }
113 |
114 | [Fact]
115 | public void GivenHorseNotFoundExceptionThenMessageReturned()
116 | {
117 | // Arrange
118 | // Act
119 | var result = _controller.Get(-1) as NotFoundObjectResult;
120 |
121 | // Assert
122 | Assert.NotNull(result);
123 | Assert.Equal("Horse Not Found", result.Value);
124 | }
125 | }
126 | }
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.suo
8 | *.user
9 | *.userosscache
10 | *.sln.docstates
11 |
12 | # User-specific files (MonoDevelop/Xamarin Studio)
13 | *.userprefs
14 |
15 | # Build results
16 | [Dd]ebug/
17 | [Dd]ebugPublic/
18 | [Rr]elease/
19 | [Rr]eleases/
20 | x64/
21 | x86/
22 | bld/
23 | [Bb]in/
24 | [Oo]bj/
25 | [Ll]og/
26 |
27 | # Visual Studio 2015 cache/options directory
28 | .vs/
29 | # Uncomment if you have tasks that create the project's static files in wwwroot
30 | #wwwroot/
31 |
32 | # MSTest test Results
33 | [Tt]est[Rr]esult*/
34 | [Bb]uild[Ll]og.*
35 |
36 | # NUNIT
37 | *.VisualState.xml
38 | TestResult.xml
39 |
40 | # Build Results of an ATL Project
41 | [Dd]ebugPS/
42 | [Rr]eleasePS/
43 | dlldata.c
44 |
45 | # .NET Core
46 | project.lock.json
47 | project.fragment.lock.json
48 | artifacts/
49 | **/Properties/launchSettings.json
50 |
51 | *_i.c
52 | *_p.c
53 | *_i.h
54 | *.ilk
55 | *.meta
56 | *.obj
57 | *.pch
58 | *.pdb
59 | *.pgc
60 | *.pgd
61 | *.rsp
62 | *.sbr
63 | *.tlb
64 | *.tli
65 | *.tlh
66 | *.tmp
67 | *.tmp_proj
68 | *.log
69 | *.vspscc
70 | *.vssscc
71 | .builds
72 | *.pidb
73 | *.svclog
74 | *.scc
75 |
76 | # Chutzpah Test files
77 | _Chutzpah*
78 |
79 | # Visual C++ cache files
80 | ipch/
81 | *.aps
82 | *.ncb
83 | *.opendb
84 | *.opensdf
85 | *.sdf
86 | *.cachefile
87 | *.VC.db
88 | *.VC.VC.opendb
89 |
90 | # Visual Studio profiler
91 | *.psess
92 | *.vsp
93 | *.vspx
94 | *.sap
95 |
96 | # TFS 2012 Local Workspace
97 | $tf/
98 |
99 | # Guidance Automation Toolkit
100 | *.gpState
101 |
102 | # ReSharper is a .NET coding add-in
103 | _ReSharper*/
104 | *.[Rr]e[Ss]harper
105 | *.DotSettings.user
106 |
107 | # JustCode is a .NET coding add-in
108 | .JustCode
109 |
110 | # TeamCity is a build add-in
111 | _TeamCity*
112 |
113 | # DotCover is a Code Coverage Tool
114 | *.dotCover
115 |
116 | # Visual Studio code coverage results
117 | *.coverage
118 | *.coveragexml
119 |
120 | # NCrunch
121 | _NCrunch_*
122 | .*crunch*.local.xml
123 | nCrunchTemp_*
124 | *.ncrunchproject
125 | *.ncrunchsolution
126 |
127 | # MightyMoose
128 | *.mm.*
129 | AutoTest.Net/
130 |
131 | # Web workbench (sass)
132 | .sass-cache/
133 |
134 | # Installshield output folder
135 | [Ee]xpress/
136 |
137 | # DocProject is a documentation generator add-in
138 | DocProject/buildhelp/
139 | DocProject/Help/*.HxT
140 | DocProject/Help/*.HxC
141 | DocProject/Help/*.hhc
142 | DocProject/Help/*.hhk
143 | DocProject/Help/*.hhp
144 | DocProject/Help/Html2
145 | DocProject/Help/html
146 |
147 | # Click-Once directory
148 | publish/
149 |
150 | # Publish Web Output
151 | *.[Pp]ublish.xml
152 | *.azurePubxml
153 | # TODO: Comment the next line if you want to checkin your web deploy settings
154 | # but database connection strings (with potential passwords) will be unencrypted
155 | *.pubxml
156 | *.publishproj
157 |
158 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
159 | # checkin your Azure Web App publish settings, but sensitive information contained
160 | # in these scripts will be unencrypted
161 | PublishScripts/
162 |
163 | # NuGet Packages
164 | *.nupkg
165 | # The packages folder can be ignored because of Package Restore
166 | **/packages/*
167 | # except build/, which is used as an MSBuild target.
168 | !**/packages/build/
169 | # Uncomment if necessary however generally it will be regenerated when needed
170 | #!**/packages/repositories.config
171 | # NuGet v3's project.json files produces more ignorable files
172 | *.nuget.props
173 | *.nuget.targets
174 |
175 | # Microsoft Azure Build Output
176 | csx/
177 | *.build.csdef
178 |
179 | # Microsoft Azure Emulator
180 | ecf/
181 | rcf/
182 |
183 | # Windows Store app package directories and files
184 | AppPackages/
185 | BundleArtifacts/
186 | Package.StoreAssociation.xml
187 | _pkginfo.txt
188 |
189 | # Visual Studio cache files
190 | # files ending in .cache can be ignored
191 | *.[Cc]ache
192 | # but keep track of directories ending in .cache
193 | !*.[Cc]ache/
194 |
195 | # Others
196 | ClientBin/
197 | ~$*
198 | *~
199 | *.dbmdl
200 | *.dbproj.schemaview
201 | *.jfm
202 | *.pfx
203 | *.publishsettings
204 | orleans.codegen.cs
205 |
206 | # Since there are multiple workflows, uncomment next line to ignore bower_components
207 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
208 | #bower_components/
209 |
210 | # RIA/Silverlight projects
211 | Generated_Code/
212 |
213 | # Backup & report files from converting an old project file
214 | # to a newer Visual Studio version. Backup files are not needed,
215 | # because we have git ;-)
216 | _UpgradeReport_Files/
217 | Backup*/
218 | UpgradeLog*.XML
219 | UpgradeLog*.htm
220 |
221 | # SQL Server files
222 | *.mdf
223 | *.ldf
224 | *.ndf
225 |
226 | # Business Intelligence projects
227 | *.rdl.data
228 | *.bim.layout
229 | *.bim_*.settings
230 |
231 | # Microsoft Fakes
232 | FakesAssemblies/
233 |
234 | # GhostDoc plugin setting file
235 | *.GhostDoc.xml
236 |
237 | # Node.js Tools for Visual Studio
238 | .ntvs_analysis.dat
239 | node_modules/
240 |
241 | # Typescript v1 declaration files
242 | typings/
243 |
244 | # Visual Studio 6 build log
245 | *.plg
246 |
247 | # Visual Studio 6 workspace options file
248 | *.opt
249 |
250 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
251 | *.vbw
252 |
253 | # Visual Studio LightSwitch build output
254 | **/*.HTMLClient/GeneratedArtifacts
255 | **/*.DesktopClient/GeneratedArtifacts
256 | **/*.DesktopClient/ModelManifest.xml
257 | **/*.Server/GeneratedArtifacts
258 | **/*.Server/ModelManifest.xml
259 | _Pvt_Extensions
260 |
261 | # Paket dependency manager
262 | .paket/paket.exe
263 | paket-files/
264 |
265 | # FAKE - F# Make
266 | .fake/
267 |
268 | # JetBrains Rider
269 | .idea/
270 | *.sln.iml
271 |
272 | # CodeRush
273 | .cr/
274 |
275 | # Python Tools for Visual Studio (PTVS)
276 | __pycache__/
277 | *.pyc
278 |
279 | # Cake - Uncomment if you are using it
280 | # tools/**
281 | # !tools/packages.config
282 |
283 | # Telerik's JustMock configuration file
284 | *.jmconfig
285 |
286 | # BizTalk build output
287 | *.btp.cs
288 | *.btm.cs
289 | *.odx.cs
290 | *.xsd.cs
291 |
--------------------------------------------------------------------------------
/BetterGenericRepository.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.26730.12
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Example.API", "Example.API\Example.API.csproj", "{BF1F816F-6716-452C-9162-02BC08E9C44B}"
7 | EndProject
8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Example.API.Tests", "Example.API.Tests\Example.API.Tests.csproj", "{4ABFC631-C301-4140-9658-CEA7882AD973}"
9 | EndProject
10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Example.DTO", "Example.DTO\Example.DTO.csproj", "{1EA98FCE-7B26-428A-A9A0-3C360EF94E70}"
11 | EndProject
12 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Example.Models", "Example.Models\Example.Models.csproj", "{A7780532-D8E4-46A0-9672-C30B827194FE}"
13 | EndProject
14 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Example.Repositories", "Example.Repositories\Example.Repositories.csproj", "{DE424D37-6774-4F76-8AC2-0E418179AC57}"
15 | EndProject
16 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Example.Repositories.Interfaces", "Example.Repositories.Interfaces\Example.Repositories.Interfaces.csproj", "{DDF6B605-89DA-4FE5-BDF5-ABCB526D9ECE}"
17 | EndProject
18 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Example.Repositories.Tests", "Example.Repositories.Tests\Example.Repositories.Tests.csproj", "{4021B1B8-6854-45AB-AD17-68FAD5E09BA6}"
19 | EndProject
20 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Example.Services", "Example.Services\Example.Services.csproj", "{2FF8B64B-955A-4C6B-941E-EB87DB28616C}"
21 | EndProject
22 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Example.Services.Interfaces", "Example.Services.Interfaces\Example.Services.Interfaces.csproj", "{EF916080-7A15-4890-864F-9B5F4F1F04FE}"
23 | EndProject
24 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Example.Services.Tests", "Example.Services.Tests\Example.Services.Tests.csproj", "{B3697CE9-FF35-4714-922F-1CBFAF2903BE}"
25 | EndProject
26 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{3808B6B3-0679-430B-9B2B-6F1F6C9D2D88}"
27 | EndProject
28 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Interfaces", "Interfaces", "{E33EF4C2-314A-4F48-8FF6-7ED5FFE4A719}"
29 | EndProject
30 | Global
31 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
32 | Debug|Any CPU = Debug|Any CPU
33 | Release|Any CPU = Release|Any CPU
34 | EndGlobalSection
35 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
36 | {BF1F816F-6716-452C-9162-02BC08E9C44B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
37 | {BF1F816F-6716-452C-9162-02BC08E9C44B}.Debug|Any CPU.Build.0 = Debug|Any CPU
38 | {BF1F816F-6716-452C-9162-02BC08E9C44B}.Release|Any CPU.ActiveCfg = Release|Any CPU
39 | {BF1F816F-6716-452C-9162-02BC08E9C44B}.Release|Any CPU.Build.0 = Release|Any CPU
40 | {4ABFC631-C301-4140-9658-CEA7882AD973}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
41 | {4ABFC631-C301-4140-9658-CEA7882AD973}.Debug|Any CPU.Build.0 = Debug|Any CPU
42 | {4ABFC631-C301-4140-9658-CEA7882AD973}.Release|Any CPU.ActiveCfg = Release|Any CPU
43 | {4ABFC631-C301-4140-9658-CEA7882AD973}.Release|Any CPU.Build.0 = Release|Any CPU
44 | {1EA98FCE-7B26-428A-A9A0-3C360EF94E70}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
45 | {1EA98FCE-7B26-428A-A9A0-3C360EF94E70}.Debug|Any CPU.Build.0 = Debug|Any CPU
46 | {1EA98FCE-7B26-428A-A9A0-3C360EF94E70}.Release|Any CPU.ActiveCfg = Release|Any CPU
47 | {1EA98FCE-7B26-428A-A9A0-3C360EF94E70}.Release|Any CPU.Build.0 = Release|Any CPU
48 | {A7780532-D8E4-46A0-9672-C30B827194FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
49 | {A7780532-D8E4-46A0-9672-C30B827194FE}.Debug|Any CPU.Build.0 = Debug|Any CPU
50 | {A7780532-D8E4-46A0-9672-C30B827194FE}.Release|Any CPU.ActiveCfg = Release|Any CPU
51 | {A7780532-D8E4-46A0-9672-C30B827194FE}.Release|Any CPU.Build.0 = Release|Any CPU
52 | {DE424D37-6774-4F76-8AC2-0E418179AC57}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
53 | {DE424D37-6774-4F76-8AC2-0E418179AC57}.Debug|Any CPU.Build.0 = Debug|Any CPU
54 | {DE424D37-6774-4F76-8AC2-0E418179AC57}.Release|Any CPU.ActiveCfg = Release|Any CPU
55 | {DE424D37-6774-4F76-8AC2-0E418179AC57}.Release|Any CPU.Build.0 = Release|Any CPU
56 | {DDF6B605-89DA-4FE5-BDF5-ABCB526D9ECE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
57 | {DDF6B605-89DA-4FE5-BDF5-ABCB526D9ECE}.Debug|Any CPU.Build.0 = Debug|Any CPU
58 | {DDF6B605-89DA-4FE5-BDF5-ABCB526D9ECE}.Release|Any CPU.ActiveCfg = Release|Any CPU
59 | {DDF6B605-89DA-4FE5-BDF5-ABCB526D9ECE}.Release|Any CPU.Build.0 = Release|Any CPU
60 | {4021B1B8-6854-45AB-AD17-68FAD5E09BA6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
61 | {4021B1B8-6854-45AB-AD17-68FAD5E09BA6}.Debug|Any CPU.Build.0 = Debug|Any CPU
62 | {4021B1B8-6854-45AB-AD17-68FAD5E09BA6}.Release|Any CPU.ActiveCfg = Release|Any CPU
63 | {4021B1B8-6854-45AB-AD17-68FAD5E09BA6}.Release|Any CPU.Build.0 = Release|Any CPU
64 | {2FF8B64B-955A-4C6B-941E-EB87DB28616C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
65 | {2FF8B64B-955A-4C6B-941E-EB87DB28616C}.Debug|Any CPU.Build.0 = Debug|Any CPU
66 | {2FF8B64B-955A-4C6B-941E-EB87DB28616C}.Release|Any CPU.ActiveCfg = Release|Any CPU
67 | {2FF8B64B-955A-4C6B-941E-EB87DB28616C}.Release|Any CPU.Build.0 = Release|Any CPU
68 | {EF916080-7A15-4890-864F-9B5F4F1F04FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
69 | {EF916080-7A15-4890-864F-9B5F4F1F04FE}.Debug|Any CPU.Build.0 = Debug|Any CPU
70 | {EF916080-7A15-4890-864F-9B5F4F1F04FE}.Release|Any CPU.ActiveCfg = Release|Any CPU
71 | {EF916080-7A15-4890-864F-9B5F4F1F04FE}.Release|Any CPU.Build.0 = Release|Any CPU
72 | {B3697CE9-FF35-4714-922F-1CBFAF2903BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
73 | {B3697CE9-FF35-4714-922F-1CBFAF2903BE}.Debug|Any CPU.Build.0 = Debug|Any CPU
74 | {B3697CE9-FF35-4714-922F-1CBFAF2903BE}.Release|Any CPU.ActiveCfg = Release|Any CPU
75 | {B3697CE9-FF35-4714-922F-1CBFAF2903BE}.Release|Any CPU.Build.0 = Release|Any CPU
76 | EndGlobalSection
77 | GlobalSection(SolutionProperties) = preSolution
78 | HideSolutionNode = FALSE
79 | EndGlobalSection
80 | GlobalSection(NestedProjects) = preSolution
81 | {4ABFC631-C301-4140-9658-CEA7882AD973} = {3808B6B3-0679-430B-9B2B-6F1F6C9D2D88}
82 | {DDF6B605-89DA-4FE5-BDF5-ABCB526D9ECE} = {E33EF4C2-314A-4F48-8FF6-7ED5FFE4A719}
83 | {4021B1B8-6854-45AB-AD17-68FAD5E09BA6} = {3808B6B3-0679-430B-9B2B-6F1F6C9D2D88}
84 | {EF916080-7A15-4890-864F-9B5F4F1F04FE} = {E33EF4C2-314A-4F48-8FF6-7ED5FFE4A719}
85 | {B3697CE9-FF35-4714-922F-1CBFAF2903BE} = {3808B6B3-0679-430B-9B2B-6F1F6C9D2D88}
86 | EndGlobalSection
87 | GlobalSection(ExtensibilityGlobals) = postSolution
88 | SolutionGuid = {BA874949-0D2E-447D-A8DE-BAC9CBCDC2AC}
89 | EndGlobalSection
90 | EndGlobal
91 |
--------------------------------------------------------------------------------