public void SetInMemoryDataSource_GivenServiceProvider_RequestsInMemoryRulesStorageAndSetsOnSelector()
        {
            // Arrange
            InMemoryRulesStorage <ContentType, ConditionType> inMemoryRulesStorage = Mock.Of <InMemoryRulesStorage <ContentType, ConditionType> >();

            IServiceCollection serviceDescriptors = new ServiceCollection();

            serviceDescriptors.AddSingleton(inMemoryRulesStorage);
            IServiceProvider serviceProvider = serviceDescriptors.BuildServiceProvider();

            IRulesDataSourceSelector <ContentType, ConditionType> rulesDataSourceSelector = Mock.Of <IRulesDataSourceSelector <ContentType, ConditionType> >();

            IRulesDataSource <ContentType, ConditionType> actualRulesDataSource = null;

            Mock.Get(rulesDataSourceSelector)
            .Setup(x => x.SetDataSource(It.IsAny <IRulesDataSource <ContentType, ConditionType> >()))
            .Callback <IRulesDataSource <ContentType, ConditionType> >((rds) =>
            {
                actualRulesDataSource = rds;
            });

            // Act
            rulesDataSourceSelector.SetInMemoryDataSource(serviceProvider);

            // Assert
            actualRulesDataSource.Should().NotBeNull();
            actualRulesDataSource.Should().BeOfType <InMemoryProviderRulesDataSource <ContentType, ConditionType> >();
            Mock.Get(rulesDataSourceSelector)
            .Verify();
        }
Пример #2
0
 public CarInsuranceAdvisorTests()
 {
     this.inMemoryRulesStorage = new InMemoryRulesStorage <ContentTypes, ConditionTypes>();
     this.LoadInMemoryStorage <ContentTypes, ConditionTypes, CarInsuranceAdvices>(
         DataSourceFilePath,
         this.inMemoryRulesStorage,
         (c) => this.Parse <CarInsuranceAdvices>((string)c));
 }
Пример #3
0
        public BuildingSecuritySystemControlTests()
        {
            this.inMemoryRulesStorage = new InMemoryRulesStorage <SecuritySystemActionables, SecuritySystemConditions>();

            this.LoadInMemoryStorage <SecuritySystemActionables, SecuritySystemConditions, SecuritySystemAction>(
                DataSourceFilePath,
                this.inMemoryRulesStorage,
                (c) => JsonConvert.DeserializeObject <SecuritySystemAction>((string)c));
        }
        internal IRulesDataSource <TContentType, TConditionType> CreateRulesDataSourceTest <TContentType, TConditionType>(InMemoryRulesStorage <TContentType, TConditionType> inMemoryRulesStorage)
        {
            IRuleFactory <TContentType, TConditionType> ruleFactory = new RuleFactory <TContentType, TConditionType>();

            return(new InMemoryProviderRulesDataSource <TContentType, TConditionType>(inMemoryRulesStorage, ruleFactory));
        }