コード例 #1
0
        public async Task Get_retrieves_buckets_with_requested_idsAsync()
        {
            //Arrange
            var id1 = 42;
            var id2 = 27;

            var bucket1 = new FileStoredBucket
            {
                Id = id1
            };

            var bucket2 = new FileStoredBucket
            {
                Id = id2
            };

            var bucket3 = new FileStoredBucket
            {
                Id = 123
            };

            var storagefolder = new Mock <IStorageFolder <FileStoredBucket> >();

            storagefolder
            .Setup(fake => fake.GetStoredItemsAsync())
            .Returns(MakeAsync(new[] { bucket1, bucket2, bucket3 }));

            var folderprovider = new Mock <IStorageFolderProvider>();

            folderprovider
            .Setup(fake => fake.GetStorageFolder <FileStoredBucket>(It.IsAny <string>()))
            .Returns(storagefolder.Object);

            var storyStore = new Mock <IDataStore <Story> >();

            var datastore = new InMemoryFileBackedBucketDataStore(folderprovider.Object, storyStore.Object);

            await datastore.InitializeAsync();

            //Act
            var result = datastore.GetAsync(new[] { id1, id2 }).Result;

            //Assert
            var containsBucket1 = result.Any(b => b.Id == id1);
            var containsBucket2 = result.Any(b => b.Id == id2);

            Assert.IsTrue(containsBucket1);
            Assert.IsTrue(containsBucket2);
            Assert.AreEqual(2, result.Count());
        }