コード例 #1
0
        public void TestCanViewInventoryItems()
        {
            var inventoryItems        = FakeInventories.GetItems().AsQueryable();
            var visibleInventoryItems = inventoryItems.CanViewContent(FakeUsers.GetPublic().AsModel());

            visibleInventoryItems.Should().HaveCount(2);
        }
コード例 #2
0
ファイル: ServiceMocks.cs プロジェクト: carlingkirk/emergence
        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);
        }
コード例 #3
0
        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();
        }