public AppDomainObjectTests()
        {
            A.CallTo(() => user.Id)
            .Returns(contributorId);

            A.CallTo(() => userResolver.FindByIdOrEmailAsync(contributorId))
            .Returns(user);

            A.CallTo(() => appPlansProvider.GetFreePlan())
            .Returns(new ConfigAppLimitsPlan {
                Id = planIdFree, MaxContributors = 10
            });

            A.CallTo(() => appPlansProvider.GetPlan(planIdFree))
            .Returns(new ConfigAppLimitsPlan {
                Id = planIdFree, MaxContributors = 10
            });

            A.CallTo(() => appPlansProvider.GetPlan(planIdPaid))
            .Returns(new ConfigAppLimitsPlan {
                Id = planIdPaid, MaxContributors = 30
            });

            initialPatterns = new InitialPatterns
            {
                { patternId1, new AppPattern("Number", "[0-9]") },
                { patternId2, new AppPattern("Numbers", "[0-9]*") }
            };

            sut = new AppDomainObject(initialPatterns, Store, A.Dummy <ISemanticLog>(), appPlansProvider, appPlansBillingManager, userResolver);
            sut.Setup(Id);
        }
示例#2
0
        public AppDomainObject(IStore <DomainId> store, ISemanticLog log,
                               InitialPatterns initialPatterns,
                               IAppPlansProvider appPlansProvider,
                               IAppPlanBillingManager appPlansBillingManager,
                               IUserResolver userResolver)
            : base(store, log)
        {
            Guard.NotNull(initialPatterns, nameof(initialPatterns));
            Guard.NotNull(userResolver, nameof(userResolver));
            Guard.NotNull(appPlansProvider, nameof(appPlansProvider));
            Guard.NotNull(appPlansBillingManager, nameof(appPlansBillingManager));

            this.userResolver           = userResolver;
            this.appPlansProvider       = appPlansProvider;
            this.appPlansBillingManager = appPlansBillingManager;
            this.initialPatterns        = initialPatterns;
        }
示例#3
0
        public AppGrainTests()
        {
            A.CallTo(() => user.Id)
            .Returns(contributorId);

            A.CallTo(() => userResolver.FindByIdOrEmailAsync(contributorId))
            .Returns(user);

            initialPatterns = new InitialPatterns
            {
                { patternId1, new AppPattern("Number", "[0-9]") },
                { patternId2, new AppPattern("Numbers", "[0-9]*") }
            };

            sut = new AppGrain(initialPatterns, Store, A.Dummy <ISemanticLog>(), appPlansProvider, appPlansBillingManager, userResolver);
            sut.OnActivateAsync(Id).Wait();
        }
示例#4
0
        public AppGrainTests()
        {
            A.CallTo(() => appProvider.GetAppAsync(AppName))
            .Returns((IAppEntity)null);

            A.CallTo(() => userResolver.FindByIdAsync(contributorId))
            .Returns(A.Fake <IUser>());

            initialPatterns = new InitialPatterns
            {
                { patternId1, new AppPattern("Number", "[0-9]") },
                { patternId2, new AppPattern("Numbers", "[0-9]*") }
            };

            sut = new AppGrain(initialPatterns, Store, appProvider, appPlansProvider, appPlansBillingManager, userResolver);
            sut.OnActivateAsync(Id).Wait();
        }
示例#5
0
        public AppGrain(
            InitialPatterns initialPatterns,
            IStore <Guid> store,
            ISemanticLog log,
            IAppPlansProvider appPlansProvider,
            IAppPlanBillingManager appPlansBillingManager,
            IUserResolver userResolver)
            : base(store, log)
        {
            Guard.NotNull(initialPatterns);
            Guard.NotNull(userResolver);
            Guard.NotNull(appPlansProvider);
            Guard.NotNull(appPlansBillingManager);

            this.userResolver           = userResolver;
            this.appPlansProvider       = appPlansProvider;
            this.appPlansBillingManager = appPlansBillingManager;
            this.initialPatterns        = initialPatterns;
        }
示例#6
0
        public void Create_should_specify_name_and_owner()
        {
            var id1 = Guid.NewGuid();
            var id2 = Guid.NewGuid();

            var initialPatterns = new InitialPatterns
            {
                { id1, new AppPattern("Number", "[0-9]") },
                { id2, new AppPattern("Numbers", "[0-9]*") }
            };

            var app = new AppDomainObject(initialPatterns);

            app.Create(CreateCommand(new CreateApp {
                Name = AppName, Actor = User, AppId = AppId
            }));

            Assert.Equal(AppName, app.Snapshot.Name);

            app.GetUncomittedEvents()
            .ShouldHaveSameEvents(
                CreateEvent(new AppCreated {
                Name = AppName
            }),
                CreateEvent(new AppContributorAssigned {
                ContributorId = User.Identifier, Permission = AppContributorPermission.Owner
            }),
                CreateEvent(new AppLanguageAdded {
                Language = Language.EN
            }),
                CreateEvent(new AppPatternAdded {
                PatternId = id1, Name = "Number", Pattern = "[0-9]"
            }),
                CreateEvent(new AppPatternAdded {
                PatternId = id2, Name = "Numbers", Pattern = "[0-9]*"
            })
                );
        }
示例#7
0
        public AppDomainObject(InitialPatterns initialPatterns)
        {
            Guard.NotNull(initialPatterns, nameof(initialPatterns));

            this.initialPatterns = initialPatterns;
        }