Exemplo n.º 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();

            requestContext = Context.Anonymous(Mocks.App(AppNamedId));

            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 });
        }
Exemplo n.º 2
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);
        }