protected override void ExecuteExample() { IProductRepository repository = new AuditedProductRepository(new ProductRepository(), new ConsoleLogger()); repository.Add(new Product { Id = 1, Name = "Product A", Price = 5.99m }); repository.Add(new Product { Id = 2, Name = "Product B", Price = 25.99m }); }
public void Add_AddsToRepository() { var prodRepo = new Mock <IProductRepository>(); var auditedRepo = new AuditedProductRepository(prodRepo.Object, new Mock <ILogger>().Object); auditedRepo.Add(new Product { Id = 1, Name = "Product A", Price = 5.99m }); prodRepo.Verify(repo => repo.Add(It.IsAny <Product>())); }
public void Remove_LogsMessage() { var logger = new Mock <ILogger>(); var auditedRepo = new AuditedProductRepository(new Mock <IProductRepository>().Object, logger.Object); auditedRepo.Remove(new Product { Id = 1, Name = "Product A", Price = 5.99m }); logger.Verify(l => l.Info(It.IsAny <string>())); }