public AssetCommandMiddlewareTests()
        {
            file = new AssetFile("my-image.png", "image/png", 1024, () => stream);

            var assetDomainObject = new AssetDomainObject(Store, tagService, assetQuery, A.Dummy <ISemanticLog>());

            A.CallTo(() => serviceProvider.GetService(typeof(AssetDomainObject)))
            .Returns(assetDomainObject);

            asset = new AssetDomainObjectGrain(serviceProvider, null !);
            asset.ActivateAsync(Id).Wait();

            A.CallTo(() => contextProvider.Context)
            .Returns(requestContext);

            A.CallTo(() => assetEnricher.EnrichAsync(A <IAssetEntity> .Ignored, requestContext))
            .ReturnsLazily(() => SimpleMapper.Map(asset.Snapshot, new AssetEntity()));

            A.CallTo(() => assetQuery.QueryByHashAsync(A <Context> .That.Matches(x => x.ShouldEnrichAsset()), AppId, A <string> .Ignored))
            .Returns(new List <IEnrichedAssetEntity>());

            A.CallTo(() => grainFactory.GetGrain <IAssetGrain>(Id, null))
            .Returns(asset);

            sut = new AssetCommandMiddleware(grainFactory,
                                             assetEnricher,
                                             assetFileStore,
                                             assetQuery,
                                             contextProvider, new[] { assetMetadataSource });
        }
Esempio n. 2
0
        public AssetCommandMiddlewareTests()
        {
            file = new NoopAssetFile();

            var assetDomainObject = new AssetDomainObject(Store, A.Dummy <ISemanticLog>(), tagService, assetQuery, contentRepository);

            A.CallTo(() => serviceProvider.GetService(typeof(AssetDomainObject)))
            .Returns(assetDomainObject);

            asset = new AssetDomainObjectGrain(serviceProvider, null !);
            asset.ActivateAsync(Id.ToString()).Wait();

            A.CallTo(() => contextProvider.Context)
            .Returns(requestContext);

            A.CallTo(() => assetEnricher.EnrichAsync(A <IAssetEntity> ._, requestContext))
            .ReturnsLazily(() => SimpleMapper.Map(asset.Snapshot, new AssetEntity()));

            A.CallTo(() => assetQuery.FindByHashAsync(A <Context> ._, A <string> ._, A <string> ._, A <long> ._))
            .Returns(Task.FromResult <IEnrichedAssetEntity?>(null));

            A.CallTo(() => grainFactory.GetGrain <IAssetGrain>(Id.ToString(), null))
            .Returns(asset);

            sut = new AssetCommandMiddleware(grainFactory,
                                             assetEnricher,
                                             assetFileStore,
                                             assetQuery,
                                             contextProvider, new[] { assetMetadataSource });
        }