public void Initialize() { // Item navigation properties _header = new Header() { Title = string.Empty.PadRight(50, 'H'), UserId = 1 }; _entry = new Entry() { Message = string.Empty.PadRight(2000, 'M') }; // Mock _mockItemRepository = new Mock<IRepository<Item>>(); _mockUow = new Mock<IUnitOfWork>(); _mockUow .Setup(uow => uow.GetRepository<Item>()) .Returns(_mockItemRepository.Object); _mockUow .Setup(u => u.Commit()) .Returns(3); _mockItemRepository .Setup(r => r.Insert(It.IsAny<Item>())) .Returns(_item); // Sut _sut = new ItemDomainService(_mockItemRepository.Object); }
static int InsertItem() { Console.WriteLine("Inserting item..."); var header = new Header() { Title = string.Empty.PadRight(50, 'X'), UserId = 1, Created = Timestamp, Updated = Timestamp }; var entry = new Entry() { Message = string.Empty.PadRight(2000, 'Y'), Created = Timestamp, Updated = Timestamp }; var item = new Item() { Header = header, Entry = entry, CategoryId = 2, UserId = 1, Amount = 300, Section = ItemSection.ForSale, Condition = ItemCondition.BrandNew, Warranty = ItemWarranty.Personal, Created = Timestamp, Updated = Timestamp, Expiry = Timestamp.AddDays(30) }; using (var uow = new TpcUnitOfWork(Context)) { // Insert item... var itemRepository = uow.GetRepository<Item>(); itemRepository.Insert(item); return uow.Commit(); } }