Exemple #1
0
        public void CreatesSubScope()
        {
            // arrange
            var    id       = Guid.NewGuid();
            string name     = Guid.NewGuid().ToString();
            var    parentId = Guid.NewGuid();
            var    subId    = Guid.NewGuid();
            var    subName  = Guid.NewGuid().ToString();
            var    options  = Options.Create(new ChronoscopeOptions());
            var    context  = new FakeChronoscopeContext
            {
                Sink         = new FakeSinks(),
                EventFactory = new FakeTrackingEventFactory(),
                Clock        = new FakeSystemClock(),
                ScopeFactory = new FakeTrackingScopeFactory()
            };
            var scope = new TrackingScope(options, context, id, name, parentId);

            // act
            var result = scope.CreateScope(subId, subName);

            // assert
            Assert.Equal(subId, result.Id);
            Assert.Equal(subName, result.Name);
            Assert.Equal(id, result.ParentId);
        }
Exemple #2
0
        public void UsesDefaultName()
        {
            // arrange
            var options = Options.Create(new ChronoscopeOptions
            {
                DefaultTaskScopeNameFormat = "Format {0}"
            });
            var context = new FakeChronoscopeContext
            {
                Sink         = new FakeSinks(),
                EventFactory = new FakeTrackingEventFactory(),
                Clock        = new FakeSystemClock()
            };
            var    id       = Guid.NewGuid();
            string name     = null;
            var    parentId = Guid.NewGuid();

            // act
            var scope = new TrackingScope(options, context, id, name, parentId);

            // assert
            Assert.Equal(string.Format(CultureInfo.InvariantCulture, options.Value.DefaultTaskScopeNameFormat, id), scope.Name);
        }