public void TestCanViewInventoryItems() { var inventoryItems = FakeInventories.GetItems().AsQueryable(); var visibleInventoryItems = inventoryItems.CanViewContent(FakeUsers.GetPublic().AsModel()); visibleInventoryItems.Should().HaveCount(2); }
public static Mock <IInventoryService> GetStandardMockInventoryService(IEnumerable <InventoryItem> itemsResult = null) { var mockInventoryService = new Mock <IInventoryService>(); mockInventoryService.Setup(s => s.GetInventoryItemsByIdsAsync(It.IsAny <IEnumerable <int> >())) .ReturnsAsync(itemsResult ?? FakeInventories.GetItems().Select(i => i.AsModel())); return(mockInventoryService); }
public async Task TestGetSomeWithIncludeAsync() { var inventoryItemsDbSetMock = MockEmergenceDbContext.CreateDbSetMock(x => x.InventoryItems, FakeInventories.GetItems()); MockEmergenceDbContext.Setup(c => c.Set <InventoryItem>()).Returns(inventoryItemsDbSetMock.Object); var inventoriesDbSetMock = MockEmergenceDbContext.CreateDbSetMock(x => x.Inventories, FakeInventories.Get()); MockEmergenceDbContext.Setup(c => c.Set <Inventory>()).Returns(inventoriesDbSetMock.Object); var lifeformsDbSetMock = MockEmergenceDbContext.CreateDbSetMock(x => x.Lifeforms, FakeLifeforms.Get()); MockEmergenceDbContext.Setup(c => c.Set <Lifeform>()).Returns(lifeformsDbSetMock.Object); var specimenRepository = new Repository <Specimen>(MockEmergenceDbContext.Object); var specimen = await specimenRepository.GetAsync(s => s.Id == 1, track : false); specimen.InventoryItemId.Should().Be(1); specimen.SpecimenStage.Should().Be("Seed"); specimen.InventoryItem.Should().NotBeNull(); specimen.InventoryItem.Inventory.Should().NotBeNull(); specimen.Lifeform.Should().NotBeNull(); }