Ejemplo n.º 1
0
        public void TestDiscardPolicy()
        {
            StreamConfiguration.StreamConfigurationBuilder builder = StreamConfiguration.Builder();
            Assert.Equal(DiscardPolicy.Old, builder.Build().DiscardPolicy);

            builder.WithDiscardPolicy(DiscardPolicy.New);
            Assert.Equal(DiscardPolicy.New, builder.Build().DiscardPolicy);

            builder.WithDiscardPolicy(null);
            Assert.Equal(DiscardPolicy.Old, builder.Build().DiscardPolicy);
        }
Ejemplo n.º 2
0
        public void TestStorageType()
        {
            StreamConfiguration.StreamConfigurationBuilder builder = StreamConfiguration.Builder();
            Assert.Equal(StorageType.File, builder.Build().StorageType);

            builder.WithStorageType(StorageType.Memory);
            Assert.Equal(StorageType.Memory, builder.Build().StorageType);

            builder.WithStorageType(null);
            Assert.Equal(StorageType.File, builder.Build().StorageType);
        }
Ejemplo n.º 3
0
        public void TestRetentionPolicy()
        {
            StreamConfiguration.StreamConfigurationBuilder builder = StreamConfiguration.Builder();
            Assert.Equal(RetentionPolicy.Limits, builder.Build().RetentionPolicy);

            builder.WithRetentionPolicy(RetentionPolicy.Interest);
            Assert.Equal(RetentionPolicy.Interest, builder.Build().RetentionPolicy);

            builder.WithRetentionPolicy(RetentionPolicy.WorkQueue);
            Assert.Equal(RetentionPolicy.WorkQueue, builder.Build().RetentionPolicy);

            builder.WithRetentionPolicy(null);
            Assert.Equal(RetentionPolicy.Limits, builder.Build().RetentionPolicy);
        }
Ejemplo n.º 4
0
        public void TestConstruction()
        {
            StreamConfiguration testSc = getTestConfiguration();

            // from json
            Validate(testSc);

            // Validate(new StreamConfiguration(testSc.ToJsonNode()));
            Validate(new StreamConfiguration(testSc.ToJsonNode().ToString()));

            StreamConfiguration.StreamConfigurationBuilder builder = StreamConfiguration.Builder(testSc);
            Validate(builder.Build());

            builder.WithName(testSc.Name)
            .WithSubjects(testSc.Subjects)
            .WithRetentionPolicy(testSc.RetentionPolicy)
            .WithMaxConsumers(testSc.MaxConsumers)
            .WithMaxMessages(testSc.MaxMsgs)
            .WithMaxMessagesPerSubject(testSc.MaxMsgsPerSubject)
            .WithMaxBytes(testSc.MaxBytes)
            .WithMaxAge(testSc.MaxAge)
            .WithMaxMsgSize(testSc.MaxValueSize)
            .WithStorageType(testSc.StorageType)
            .WithReplicas(testSc.Replicas)
            .WithNoAck(testSc.NoAck)
            .WithTemplateOwner(testSc.TemplateOwner)
            .WithDiscardPolicy(testSc.DiscardPolicy)
            .WithDuplicateWindow(testSc.DuplicateWindow)
            .WithPlacement(testSc.Placement)
            .WithMirror(testSc.Mirror)
            .WithSources(testSc.Sources)
            ;
            Validate(builder.Build());
            Validate(builder.AddSources((Source)null).Build());

            List <Source> sources = new List <Source>(testSc.Sources);

            sources.Add(null);
            Source copy = new Source(sources[0].ToJsonNode());

            sources.Add(copy);
            Validate(builder.AddSources(sources).Build());
        }
Ejemplo n.º 5
0
        public void TestSubjects()
        {
            StreamConfiguration.StreamConfigurationBuilder builder = StreamConfiguration.Builder();

            // subjects(...) replaces
            builder.WithSubjects(Subject(0));
            AssertSubjects(builder.Build(), 0);

            // subjects(...) replaces
            builder.WithSubjects();
            AssertSubjects(builder.Build());

            // subjects(...) replaces
            builder.WithSubjects(Subject(1));
            AssertSubjects(builder.Build(), 1);

            // Subjects(...) replaces
            builder.WithSubjects((string)null);
            AssertSubjects(builder.Build());

            // Subjects(...) replaces
            builder.WithSubjects(Subject(2), Subject(3));
            AssertSubjects(builder.Build(), 2, 3);

            // Subjects(...) replaces
            builder.WithSubjects(Subject(101), null, Subject(102));
            AssertSubjects(builder.Build(), 101, 102);

            // Subjects(...) replaces
            List <String> list45 = new List <String>();

            list45.Add(Subject(4));
            list45.Add(Subject(5));
            builder.WithSubjects(list45);
            AssertSubjects(builder.Build(), 4, 5);

            // AddSubjects(...) adds unique
            builder.AddSubjects(Subject(5), Subject(6));
            AssertSubjects(builder.Build(), 4, 5, 6);

            // AddSubjects(...) adds unique
            List <String> list678 = new List <String>();

            list678.Add(Subject(6));
            list678.Add(Subject(7));
            list678.Add(Subject(8));
            builder.AddSubjects(list678);
            AssertSubjects(builder.Build(), 4, 5, 6, 7, 8);

            // AddSubjects(...) null check
            builder.AddSubjects((String[])null);
            AssertSubjects(builder.Build(), 4, 5, 6, 7, 8);

            // AddSubjects(...) null check
            builder.AddSubjects((List <String>)null);
            AssertSubjects(builder.Build(), 4, 5, 6, 7, 8);
        }