Exemple #1
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 });
        }
        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 });
        }
Exemple #3
0
        public AssetDomainObjectTests()
        {
            A.CallTo(() => assetQuery.FindAssetFolderAsync(AppId, parentId))
            .Returns(new List <IAssetFolderEntity> {
                A.Fake <IAssetFolderEntity>()
            });

            A.CallTo(() => tagService.NormalizeTagsAsync(AppId, TagGroups.Assets, A <HashSet <string> > ._, A <HashSet <string> > ._))
            .ReturnsLazily(x => Task.FromResult(x.GetArgument <HashSet <string> >(2)?.ToDictionary(x => x) !));

            sut = new AssetDomainObject(Store, A.Dummy <ISemanticLog>(), tagService, assetQuery, contentRepository);
            sut.Setup(Id);
        }