public async Task <IHttpActionResult> GetModels(CancellationToken cancellationToken) { Trace.TraceVerbose("Listing all models in the registry"); ModelsRegistry modelsRegistry = WebAppContext.ModelsRegistry; IList <Model> models = await modelsRegistry.ListModelsAsync(cancellationToken); return(Ok(models)); }
public async Task ListModelsAsyncTest() { ITable table = Substitute.For <ITable>(); var modelsRegistry = new ModelsRegistry(table); table.ListEntitiesAsync <ModelTableEntity>(CancellationToken.None, Arg.Any <string[]>()) .Returns(Task.FromResult <IList <ModelTableEntity> >(new List <ModelTableEntity>())); var models = await modelsRegistry.ListModelsAsync(CancellationToken.None); Assert.IsNotNull(models); Assert.AreEqual(0, models.Count); table.ListEntitiesAsync <ModelTableEntity>(CancellationToken.None, Arg.Any <string[]>()) .Returns(Task.FromResult <IList <ModelTableEntity> >(new[] { new ModelTableEntity(Guid.NewGuid()), new ModelTableEntity(Guid.NewGuid()) })); models = await modelsRegistry.ListModelsAsync(CancellationToken.None); Assert.IsNotNull(models); Assert.AreEqual(2, models.Count); }