public void Initialize() { //Arrange for Tests var mapperConfig = new MapperConfiguration(cnfig => { cnfig.AddProfile(new RepositoryMapper()); }); _mapper = mapperConfig.CreateMapper(); _mockContext = new FakeDatabaseEntitiesContext { Products = { new data.Product { Id = new Guid("8f2e9176-35ee-4f0a-ae55-83023d2db1a3"), Name = "Samsung Galaxy S7", Description = "Newest mobile product from Samsung.", Price = 1024.99M, DeliveryPrice = 16.99M }, new data.Product { Id = new Guid("de1287c0-4b15-4a7b-9d8a-dd21b3cafec3"), Name = "Apple iPhone 6S", Description = "Newest mobile product from Apple.", Price = 1299.99M, DeliveryPrice = 15.99M } } }; _logging = new LoggingService(); }
public void Initialize() { //Arrange for Tests var mapperConfig = new MapperConfiguration(cnfig => { cnfig.AddProfile(new RepositoryMapper()); }); _mapper = mapperConfig.CreateMapper(); _mockContext = new FakeDatabaseEntitiesContext { Products = { new data.Product { Id = new Guid("8f2e9176-35ee-4f0a-ae55-83023d2db1a3"), Name = "Samsung Galaxy S7", Description = "Newest mobile product from Samsung.", Price = 1024.99M, DeliveryPrice = 16.99M }, new data.Product { Id = new Guid("de1287c0-4b15-4a7b-9d8a-dd21b3cafec3"), Name = "Apple iPhone 6S", Description = "Newest mobile product from Apple.", Price = 1299.99M, DeliveryPrice = 15.99M } }, ProductOptions = { new data.ProductOption { Id = new Guid("0643ccf0-ab00-4862-b3c5-40e2731abcc9"), ProductId = new Guid("8f2e9176-35ee-4f0a-ae55-83023d2db1a3"), Name = "White", Description = "White Samsung Galaxy S7" }, new data.ProductOption { Id = new Guid("a21d5777-a655-4020-b431-624bb331e9a2"), ProductId = new Guid("8f2e9176-35ee-4f0a-ae55-83023d2db1a3"), Name = "Black", Description = "Black Samsung Galaxy S7" }, new data.ProductOption { Id = new Guid("5c2996ab-54ad-4999-92d2-89245682d534"), ProductId = new Guid("de1287c0-4b15-4a7b-9d8a-dd21b3cafec3"), Name = "Rose Gold", Description = "Gold Apple iPhone 6S" } } }; _logging = new LoggingService(); var productOptionRepository = new ProductOptionRepository(_mapper, _mockContext, _logging); var productRepository = new ProductRepository(_mapper, _mockContext, _logging); var productOptionService = new ProductOptionService(productOptionRepository); var productService = new ProductService(productRepository); _Controller = new ProductsController(productService, productOptionService, _logging); }
public void Initialize() { //Arrange for Tests var mapperConfig = new MapperConfiguration(cnfig => { cnfig.AddProfile(new RepositoryMapper()); }); _mapper = mapperConfig.CreateMapper(); _mockContext = new FakeDatabaseEntitiesContext { ProductOptions = { new data.ProductOption { Id= new Guid("0643ccf0-ab00-4862-b3c5-40e2731abcc9"),ProductId=new Guid("8f2e9176-35ee-4f0a-ae55-83023d2db1a3"),Name="White",Description="White Samsung Galaxy S7"}, new data.ProductOption { Id= new Guid("a21d5777-a655-4020-b431-624bb331e9a2"),ProductId=new Guid("8f2e9176-35ee-4f0a-ae55-83023d2db1a3"),Name="Black", Description="Black Samsung Galaxy S7" }, new data.ProductOption { Id= new Guid("5c2996ab-54ad-4999-92d2-89245682d534"),ProductId=new Guid("de1287c0-4b15-4a7b-9d8a-dd21b3cafec3"),Name="Rose Gold",Description="Gold Apple iPhone 6S" } } }; _logging = new LoggingService(); }
/// <summary> /// Initializes a new instance of the <see cref="ProductOptionRepository"/> class. /// </summary> /// <param name="mapper">The mapper.</param> /// <param name="dbContext">The database context.</param> /// <param name="logging">The logging.</param> public ProductOptionRepository(IMapper mapper, IDatabaseEntities dbContext, ILoggingService logging) { _mapper = mapper; _dbContext = dbContext; }
//here db is being provided to the ctor by your //DI Library e.g. StructureMap, SimpleInjector, .Net Core Injection, etc. public ValuesController(IDatabaseEntities db) { _db = db; //null check left out for brevity }