コード例 #1
0
 public void CanSetDefaultValue()
 {
     var source = new TestStore();
     source.Set("IsSomething", Layer.Defaults, true);
     
     source.IsSomething.ShouldBeTrue();
 }
コード例 #2
0
 public void TestBind()
 {
     var store = (TestStore)null;
      // invalid bind
      AssertException(
     () => ConnectionString.Parse("Store=Test;Prop=value;").Bind(null)
      );
      AssertException(
     () => ConnectionString.Parse("Store=Test;Prop=value;").Bind(new EmptyStore())
      );
      AssertException(
     () => ConnectionString.Parse("Store=Test;Property3=value;").Bind(new TestStore())
      );
      AssertException(
     () => ConnectionString.Parse("Store=Test;Property1=invalid;").Bind(new TestStore())
      );
      // valid bind
      store = new TestStore() { Property1 = 42, Property2 = "value2" };
      ConnectionString.Parse("Store=Test;").Bind(store);
      Assert.AreEqual(store.Property1, 42);
      Assert.AreEqual(store.Property2, "value2");
      store = new TestStore() { Property1 = 42, Property2 = "value2" };
      ConnectionString.Parse("Store=Test;Property1=43;").Bind(store);
      Assert.AreEqual(store.Property1, 43);
      Assert.AreEqual(store.Property2, "value2");
      store = new TestStore() { Property1 = 42, Property2 = "value2" };
      ConnectionString.Parse("Store=Test;pRoPeRtY1=43;PrOpErTy2=value3;").Bind(store);
      Assert.AreEqual(store.Property1, 43);
      Assert.AreEqual(store.Property2, "value3");
 }
コード例 #3
0
        public void CanCheckIfAttributeIsSpecified()
        {

            var store = new TestStore();            
            store.IsSpecified("IsSomething").ShouldBeFalse();
            store.Set("IsSomething", Layer.Defaults, true);
            store.IsSpecified("IsSomething").ShouldBeTrue();
        }
コード例 #4
0
        public void UnsetValuesAreNotCopied()
        {
            var source = new TestStore();
            var target = new TestStore();
            target.Set("IsSomething", Layer.Defaults, true);
            source.CopyTo(target);

            target.IsSomething.ShouldBeTrue();
        }
コード例 #5
0
        public void CanCopyAttributes()
        {
            var source = new TestStore();
            source.Set("IsSomething", Layer.Defaults, true);

            var target = new TestStore();
            source.CopyTo(target);

            target.IsSomething.ShouldBeTrue();
        }
コード例 #6
0
        public void CopyingAttributesReplacesOldValues()
        {
            var source = new TestStore();
            source.Set("IsSomething", Layer.Defaults, false);

            var target = new TestStore();
            target.Set("IsSomething", Layer.Defaults, true);
            source.CopyTo(target);

            target.IsSomething.ShouldBeFalse();
        }
コード例 #7
0
        public void Load_EmptyConfig()
        {
            var testStore = new TestStore();
            var configuration = Configuration.Load.From(new TestStore()).Select(typeof(EmptyConfig));

            configuration.Type.Verify().IsTrue(x => x == typeof(EmptyConfig));
            configuration.SettingProperties.Count().Verify().IsEqual(0);

            testStore.GetSettingsParameters.Count.Verify().IsEqual(0);
            testStore.SaveSettingsParameters.Count.Verify().IsEqual(0);
        }
コード例 #8
0
            public DbContextOptions CreateOptions(
                Action <ModelBuilder> onModelCreating = null, object additionalModelCacheKey = null, bool seed = true)
            {
                OnModelCreatingAction   = onModelCreating;
                AdditionalModelCacheKey = additionalModelCacheKey;
                var options = CreateOptions(TestStore);

                TestStore.Initialize(ServiceProvider, () => new EmbeddedTransportationContext(options), c =>
                {
                    if (seed)
                    {
                        ((TransportationContext)c).Seed();
                    }
                });

                ListLoggerFactory.Clear();
                return(options);
            }
コード例 #9
0
ファイル: AddFeature.cs プロジェクト: vipwan/Fluxor
        public void WhenFeatureWithSameNameAlreadyExists_ThenThrowsArgumentException()
        {
            const string featureName = "1234";
            var          mockFeature = new Mock <IFeature>();

            mockFeature
            .Setup(x => x.GetName())
            .Returns(featureName);

            var subject = new TestStore();

            subject.AddFeature(mockFeature.Object);

            Assert.Throws <ArgumentException>(() =>
            {
                subject.AddFeature(mockFeature.Object);
            });
        }
コード例 #10
0
        protected TestStore CreateTestStore(Action <ModelBuilder> onModelCreating = null, bool seed = true)
        {
            TestStore = TestStoreFactory.Create(DatabaseName);

            ServiceProvider = TestStoreFactory.AddProviderServices(new ServiceCollection())
                              .AddSingleton(TestModelSource.GetFactory(onModelCreating ?? (_ => { })))
                              .AddSingleton <ILoggerFactory>(TestSqlLoggerFactory)
                              .BuildServiceProvider(validateScopes: true);

            TestStore.Initialize(ServiceProvider, CreateContext, c =>
            {
                if (seed)
                {
                    ((TransportationContext)c).Seed();
                }
            });

            TestSqlLoggerFactory.Clear();

            return(TestStore);
        }
コード例 #11
0
        public void WhenCalled_ThenExecutesOnAllRegisteredMiddlewares()
        {
            int disposeCount   = 0;
            var mockMiddleware = new Mock <IMiddleware>();

            mockMiddleware
            .Setup(x => x.BeginInternalMiddlewareChange())
            .Returns(new DisposableCallback("Test", () => disposeCount++));

            var subject = new TestStore();

            subject.AddMiddleware(mockMiddleware.Object);

            var disposable1 = subject.BeginInternalMiddlewareChange();
            var disposable2 = subject.BeginInternalMiddlewareChange();

            disposable1.Dispose();
            Assert.Equal(0, disposeCount);

            disposable2.Dispose();
            Assert.Equal(1, disposeCount);
        }
コード例 #12
0
 public void CanGetAndSetAttribute()
 {
     var store = new TestStore();
     store.Set("IsSomething", Layer.Defaults, true);
     store.IsSomething.ShouldBeTrue();            
 }
コード例 #13
0
 public void UnsetAttributeShouldBeDefault()
 {
     var store = new TestStore();
     store.IsSomething.ShouldBeFalse();
 }
コード例 #14
0
        private User PopulateAuthData(TestStore store)
        {
            User user = new User { Username = "******" };
            store.Users.Add(user);

            Role parent = new Role { Name = "Parent" };
            Role child = new Role { Name = "Child" };
            store.Roles.Add(parent);
            store.Roles.Add(child);
            RoleTests.MakeMember(parent, child);

            RoleUserMembership ru = new RoleUserMembership { User = user, Role = parent };
            parent.Users.Add(ru);
            user.Roles.Add(ru);

            Authorization auth = new Authorization { Permission = PermissionType.EditMember, Role = child, RoleId = child.Id };
            store.Authorization.Add(auth);

            return user;
        }
コード例 #15
0
 private TransactionValidator CreateValidator(IDictionary<string, long> accounts, params Mutation[] mutations)
 {
     this.store = new TestStore(accounts, false);
     return new TransactionValidator(
         this.store,
         new TestValidator(false, mutations),
         validNamespace);
 }
コード例 #16
0
        public async Task PostTransaction_ValidationException()
        {
            this.store = new TestStore(defaultAccounts, false);
            TransactionValidator validator = new TransactionValidator(
                this.store,
                new TestValidator(true),
                validNamespace);

            ByteString mutation = CreateMutation(validNamespace);

            TransactionInvalidException exception = await Assert.ThrowsAsync<TransactionInvalidException>(
                () => validator.PostTransaction(mutation, new SignatureEvidence[0]));
            Assert.Equal("Test", exception.Reason);
            Assert.Equal(null, store.AddedTransactions);
        }